[freeside-commits] branch master updated. b0e67356e3a16101eb06a12e2a48cc6dc4233c29

Jonathan Prykop jonathan at 420.am
Wed Mar 4 21:14:18 PST 2015


The branch, master has been updated
       via  b0e67356e3a16101eb06a12e2a48cc6dc4233c29 (commit)
      from  61ea51152f19edd37043f6c29303bfe16809f0f6 (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 b0e67356e3a16101eb06a12e2a48cc6dc4233c29
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Mar 4 23:14:02 2015 -0600

    RT#33582: RBC return batch processing failure [handle multiple decline lines for same batchnum, and better error messages]

diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm
index a4b4957..da003d8 100644
--- a/FS/FS/cust_pay_batch.pm
+++ b/FS/FS/cust_pay_batch.pm
@@ -265,15 +265,15 @@ sub approve {
   my %opt = @_;
   my $paybatchnum = $new->paybatchnum;
   my $old = qsearchs('cust_pay_batch', { paybatchnum => $paybatchnum })
-    or return "paybatchnum $paybatchnum not found";
+    or return "cannot approve, paybatchnum $paybatchnum not found";
   # leave these restrictions in place until TD EFT is converted over
   # to B::BP
-  return "paybatchnum $paybatchnum already resolved ('".$old->status."')" 
+  return "cannot approve paybatchnum $paybatchnum, already resolved ('".$old->status."')" 
     if $old->status;
   $new->status('Approved');
   my $error = $new->replace($old);
   if ( $error ) {
-    return "error updating status of paybatchnum $paybatchnum: $error\n";
+    return "error approving paybatchnum $paybatchnum: $error\n";
   }
   my $cust_pay = new FS::cust_pay ( {
       'custnum'   => $new->custnum,
@@ -319,7 +319,7 @@ sub decline {
 
   my $paybatchnum = $new->paybatchnum;
   my $old = qsearchs('cust_pay_batch', { paybatchnum => $paybatchnum })
-    or return "paybatchnum $paybatchnum not found";
+    or return "cannot decline, paybatchnum $paybatchnum not found";
   if ( $old->status ) {
     # Handle the case where payments are rejected after the batch has been 
     # approved.  FS::pay_batch::import_results won't allow results to be 
@@ -344,9 +344,15 @@ sub decline {
       }
       $cust_pay->void($reason);
     }
+    elsif ( lc($old->status) eq 'declined' ) {
+      # batch files from RBC can have multiple lines for one decline
+      # if this causes problems elsewhere, try hacking pay_batch/RBC.pm instead
+      return '';
+    }
     else {
       # normal case: refuse to do anything
-      return "paybatchnum $paybatchnum already resolved ('".$old->status."')";
+      # should never happen...only statuses are approved or declined
+      return "cannot decline paybatchnum $paybatchnum, already resolved ('".$old->status."')";
     }
   } # !$old->status
   $new->status('Declined');
@@ -354,7 +360,7 @@ sub decline {
   $new->failure_status($failure_status);
   my $error = $new->replace($old);
   if ( $error ) {
-    return "error updating status of paybatchnum $paybatchnum: $error\n";
+    return "error declining paybatchnum $paybatchnum: $error\n";
   }
   my $due_cust_event = $new->cust_main->due_cust_event(
     'eventtable'  => 'cust_pay_batch',

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

Summary of changes:
 FS/FS/cust_pay_batch.pm |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list