[freeside-commits] branch master updated. 163d6b01bcfcd1fc78724248ebe6b451ae402d45

Mark Wells mark at 420.am
Mon Jan 25 16:48:41 PST 2016


The branch, master has been updated
       via  163d6b01bcfcd1fc78724248ebe6b451ae402d45 (commit)
      from  3cdd4af468c2c93e1fe4ab6a0ac95537aca5068e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 163d6b01bcfcd1fc78724248ebe6b451ae402d45
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Jan 25 15:03:02 2016 -0800

    update batch payment for multiple payment methods, etc., #17878 and #23741

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 1e975dc..3849443 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2683,6 +2683,7 @@ sub tables_hashref {
         #'exp',          @date_type,                  '', '',
         'exp',           'varchar', 'NULL',      11, '', '', 
         'payname',       'varchar', 'NULL', $char_d, '', '', 
+        'paytype',       'varchar', 'NULL', $char_d, '', '', 
         'amount',      @money_type,                  '', '', 
         'currency',         'char', 'NULL',       3, '', '',
         'status',        'varchar', 'NULL', $char_d, '', '', 
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index ee70dea..a202e3d 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -5482,6 +5482,20 @@ sub _upgrade_data { #class method
 
       }
 
+      # at the time we do this, also migrate paytype into cust_pay_batch
+      # so that batches that are open before the migration can still be 
+      # processed
+      my @cust_pay_batch = qsearch('cust_pay_batch', {
+          'custnum' => $cust_main->custnum,
+          'payby'   => 'CHEK',
+          'paytype' => '',
+      });
+      foreach my $cust_pay_batch (@cust_pay_batch) {
+        $cust_pay_batch->set('paytype', $cust_main->get('paytype'));
+        my $error = $cust_pay_batch->replace;
+        die "$error (setting cust_pay_batch.paytype)" if $error;
+      }
+
       $cust_main->complimentary('Y') if $cust_main->payby eq 'COMP';
 
       $cust_main->invoice_attn( $cust_main->payname )
diff --git a/FS/FS/cust_main/Billing_Batch.pm b/FS/FS/cust_main/Billing_Batch.pm
index 7612df3..d8e6f8a 100644
--- a/FS/FS/cust_main/Billing_Batch.pm
+++ b/FS/FS/cust_main/Billing_Batch.pm
@@ -140,6 +140,7 @@ sub batch_card {
     'payinfo'  => $options{payinfo}  || $cust_payby->payinfo,
     'exp'      => $options{paydate}  || $cust_payby->paydate,
     'payname'  => $options{payname}  || $cust_payby->payname,
+    'paytype'  => $options{paytype}  || $cust_payby->paytype,
     'amount'   => $amount,                         # consolidating
   } );
   
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 20d0145..3396ec4 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -185,6 +185,15 @@ A third-party transaction will return a hashref containing:
 =cut
 
 # some helper routines
+#
+# _bop_recurring_billing: Checks whether this payment should have the 
+# recurring_billing flag used by some B:OP interfaces (IPPay, PlugnPay,
+# vSecure, etc.). This works in two different modes:
+# - actual_oncard (default): treat the payment as recurring if the customer
+#   has made a payment using this card before.
+# - transaction_is_recur: treat the payment as recurring if the invoice
+#   being paid has any recurring package charges.
+
 sub _bop_recurring_billing {
   my( $self, %opt ) = @_;
 
diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm
index 8dd6446..8127c6a 100644
--- a/FS/FS/cust_pay_batch.pm
+++ b/FS/FS/cust_pay_batch.pm
@@ -63,6 +63,8 @@ following fields are currently supported:
 
 =item payname - name on card 
 
+=item paytype - account type ((personal|business) (checking|savings))
+
 =item first - name 
 
 =item last - name 
@@ -156,6 +158,18 @@ sub check {
   $error = $self->payinfo_check();
   return $error if $error;
 
+  if ( $self->payby eq 'CHEK' ) {
+    # because '' is on the list of paytypes:
+    my $paytype = $self->paytype or return "Bank account type required";
+    if (grep { $_ eq $paytype} FS::cust_payby->paytypes) {
+      #ok
+    } else {
+      return "Bank account type '$paytype' is not allowed"
+    }
+  } else {
+    $self->set('paytype', '');
+  }
+
   if ( $self->exp eq '' ) {
     return "Expiration date required"
       unless $self->payby =~ /^(CHEK|DCHK|WEST)$/;
@@ -408,12 +422,23 @@ sub request_item {
     $self->payinfo =~ /(\d+)@(\d+)/; # or else what?
     $payment{account_number} = $1;
     $payment{routing_code} = $2;
-    $payment{account_type} = $cust_main->paytype;
+    $payment{account_type} = $self->paytype;
     # XXX what if this isn't their regular payment method?
   } else {
     die "unsupported BatchPayment method: ".$pay_batch->payby;
   }
 
+  my $recurring;
+  if ( $cust_main->status =~ /^active|suspended|ordered$/ ) {
+    if ( $self->payinfo_used ) {
+      $recurring = 'S'; # subsequent
+    } else {
+      $recurring = 'F'; # first use
+    }
+  } else {
+    $recurring = 'N'; # non-recurring
+  }
+
   Business::BatchPayment->create(Item =>
     # required
     action      => 'payment',
@@ -429,6 +454,7 @@ sub request_item {
     ( map { $_ => $location->$_ } qw(address2 city state country zip) ),
     
     invoice_number  => $self->invnum,
+    recurring_billing => $recurring,
     %payment,
   );
 }
diff --git a/FS/FS/pay_batch/nacha.pm b/FS/FS/pay_batch/nacha.pm
index befba09..23dda4c 100644
--- a/FS/FS/pay_batch/nacha.pm
+++ b/FS/FS/pay_batch/nacha.pm
@@ -136,8 +136,9 @@ $DEBUG = 0;
 
     #XXX paytype should actually be in the batch, but this will do for now
     #27 checking debit, 37 savings debit
-    my $transaction_code = ( $cust_main->paytype =~ /savings/i ? '37' : '27' );
+    my $transaction_code = ( $cust_pay_batch->paytype =~ /savings/i ? '37' : '27' );
 
+    # not $self->payname?
     my $cust_name = substr($cust_main->name. (' 'x22), 0, 22);
     $i++;
     my $tracenum = $dest. substr(('0'x7). $i, -6);
diff --git a/FS/FS/pay_batch/paymentech.pm b/FS/FS/pay_batch/paymentech.pm
index 91abbf2..1282507 100644
--- a/FS/FS/pay_batch/paymentech.pm
+++ b/FS/FS/pay_batch/paymentech.pm
@@ -128,7 +128,7 @@ my %paymentech_countries = map { $_ => 1 } qw( US CA GB UK );
         ) : (
           ecpCheckRT      => ($_->payinfo =~ /@(\d+)/),
           ecpCheckDDA     => ($_->payinfo =~ /(\d+)@/),
-          ecpBankAcctType => $paytype{lc($_->cust_main->paytype)},
+          ecpBankAcctType => $paytype{lc($_->paytype)},
           ecpDelvMethod   => 'A',
         ),
         avsZip          => bytes_substr($_->zip,      0, 10),
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index 5cd5d31..0b0dffd 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -190,6 +190,7 @@ if ( $cgi->param('save') ) {
     'payinfo'       => $payinfo,
     'paymask'       => $paymask,
     'payname'       => $payname,
+    'paytype        => $paytype,
     %saveopt
   );
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm                     |    1 +
 FS/FS/cust_main.pm                  |   14 ++++++++++++++
 FS/FS/cust_main/Billing_Batch.pm    |    1 +
 FS/FS/cust_main/Billing_Realtime.pm |    9 +++++++++
 FS/FS/cust_pay_batch.pm             |   28 +++++++++++++++++++++++++++-
 FS/FS/pay_batch/nacha.pm            |    3 ++-
 FS/FS/pay_batch/paymentech.pm       |    2 +-
 httemplate/misc/process/payment.cgi |    1 +
 8 files changed, 56 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list