JBAS-2101 Refundable xact address handling improvements
authorBill Erickson <berickxx@gmail.com>
Fri, 2 Nov 2018 14:44:49 +0000 (10:44 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
If no mailing/billing address is linked to the account, use the first
address found for the user.

If no addresses exist, use "NONE" for required refundable xact fields.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/RefundablePayment.pm

index 8327a46..f4fa171 100644 (file)
@@ -210,13 +210,23 @@ sub create_refundable_payment {
             flesh => 2,
             flesh_fields => {
                 circ => ['usr', 'target_copy'],
-                au => [qw/card billing_address mailing_address/]
+                au => [qw/card billing_address mailing_address addresses/]
             }
         }
     ]) or return $e->die_event;
 
     my $usr = $circ->usr;
-    my $addr = $usr->mailing_address || $usr->billing_address;
+
+    my $addr = $usr->billing_address || 
+        $usr->mailing_address || $usr->addresses->[0];
+
+    if (!$addr) {
+        $addr = Fieldmapper::actor::user_address->new;
+        $addr->street1('NONE');
+        $addr->city('NONE');
+        $addr->state('NONE');
+        $addr->post_code('NONE');
+    }
 
     my $mrx = $e->search_money_refundable_xact({xact => $payment->xact->id})->[0];