RT# 77792 - Created method to decide if batch payname should be name on card or perso...
authorChristopher Burger <burgerc@freeside.biz>
Fri, 18 May 2018 15:41:21 +0000 (11:41 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Fri, 18 May 2018 15:41:21 +0000 (11:41 -0400)
FS/FS/cust_main.pm
FS/FS/pay_batch/RBC.pm

index 7c9868d..3bffa3a 100644 (file)
@@ -3922,6 +3922,27 @@ sub name {
   $name;
 }
 
+=item batch_payment_payname
+
+Returns a name string for this customer, either "cust_batch_payment->payname" or "First Last" or "Company,
+based on if a company name exists and is the account being used a business account.
+
+=cut
+
+sub batch_payment_payname {
+  my $self = shift;
+  my $cust_pay_batch = shift;
+  my $name;
+
+  if ($cust_pay_batch->{Hash}->{payby} eq "CARD") { $name = $cust_pay_batch->payname; }
+  else { $name = $self->first .' '. $self->last; }
+
+  $name = $self->company
+    if (($cust_pay_batch->{Hash}->{paytype} eq "Business checking" || $cust_pay_batch->{Hash}->{paytype} eq "Business savings") && $self->company);
+
+  $name;
+}
+
 =item service_contact
 
 Returns the L<FS::contact> object for this customer that has the 'Service'
index 1577a7f..dea89cd 100644 (file)
@@ -175,9 +175,7 @@ $name = 'RBC';
     }
 
     ## set custname to business name if business checking or savings account is used otherwise leave as first and last name.
-    my $custname = $cust_pay_batch->cust_main->first . ' ' . $cust_pay_batch->cust_main->last;
-    $custname = $cust_pay_batch->cust_main->company
-      if (($cust_pay_batch->{Hash}->{paytype} eq "Business checking" || $cust_pay_batch->{Hash}->{paytype} eq "Business savings") && $cust_pay_batch->cust_main->company);
+    my $custname = $cust_pay_batch->cust_main->batch_payment_payname($cust_pay_batch);
 
     $i++;