Bug 8125 Sip addess should include all address fields
authorColin Campbell <colin.campbell@ptfs-europe.com>
Tue, 22 May 2012 10:11:33 +0000 (11:11 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 19 Dec 2012 12:59:53 +0000 (07:59 -0500)
Expansion of Liz Rea's original patch
Bug report specifically mentioned lack of the
Zip/Postal code but all used address fields should
be included. Moved the address
generation to its own sub.
Hopefully using an if else will read more clearly than
the original ternary operator proved to be

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/SIP/ILS/Patron.pm

index dc45d2a..8c00a11 100644 (file)
@@ -53,13 +53,11 @@ sub new {
         $kp->{opacnote} .= 'PATRON EXPIRED';
     }
     my %ilspatron;
-    my $adr     = $kp->{streetnumber} || '';
-    my $address = $kp->{address}      || '';
+    my $adr     = _get_address($kp);
     my $dob     = $kp->{dateofbirth};
     $dob and $dob =~ s/-//g;    # YYYYMMDD
     my $dexpiry     = $kp->{dateexpiry};
     $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
-    $adr .= ($adr && $address) ? " $address" : $address;
     my $fines_amount = $flags->{CHARGES}->{amount};
     $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
     {
@@ -349,6 +347,24 @@ sub charge_denied {
     return "Please contact library staff";
 }
 
+sub _get_address {
+    my $patron = shift;
+
+    my $address = $patron->{streetnumber} || q{};
+    for my $field (qw( roaddetails address address2 city state zipcode country))
+    {
+        next unless $patron->{$field};
+        if ($address) {
+            $address .= q{ };
+            $address .= $patron->{$field};
+        }
+        else {
+            $address .= $patron->{$field};
+        }
+    }
+    return $address;
+}
+
 1;
 __END__