[freeside-commits] branch master updated. a6848eb9a7c77de01a4daadb2bddcf7a3d0c3fbf

Christopher Burger burgerc at freeside.biz
Tue Nov 6 10:59:46 PST 2018


The branch, master has been updated
       via  a6848eb9a7c77de01a4daadb2bddcf7a3d0c3fbf (commit)
      from  94b60bb13c044e436800239be3e3c5a029bdff8e (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 a6848eb9a7c77de01a4daadb2bddcf7a3d0c3fbf
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Nov 6 13:57:35 2018 -0500

    RT# 76093 - added ability for processing fee to be used with batch processing.

diff --git a/FS/FS/cust_main/Billing_Batch.pm b/FS/FS/cust_main/Billing_Batch.pm
index 1ea069de4..0e713e937 100644
--- a/FS/FS/cust_main/Billing_Batch.pm
+++ b/FS/FS/cust_main/Billing_Batch.pm
@@ -170,6 +170,27 @@ sub batch_card {
   if ($options{'processing-fee'} > 0) {
     my $pf_cust_pkg;
     my $processing_fee_text = 'Payment Processing Fee';
+
+    unless ( $invnum ) { # probably from a payment screen
+      # do we have any open invoices? pick earliest
+      # uses the fact that cust_main->cust_bill sorts by date ascending
+      my @open = $self->open_cust_bill;
+      $invnum = $open[0]->invnum if scalar(@open);
+    }
+
+    unless ( $invnum ) {  # still nothing? pick last closed invoice
+      # again uses fact that cust_main->cust_bill sorts by date ascending
+      my @closed = $self->cust_bill;
+      $invnum = $closed[$#closed]->invnum if scalar(@closed);
+    }
+
+    unless ( $invnum ) {
+      # XXX: unlikely case - pre-paying before any invoices generated
+      # what it should do is create a new invoice and pick it
+      warn '\PROCESS FEE AND NO INVOICES PICKED TO APPLY IT!';
+      return '';
+    }
+
     my $pf_change_error = $self->charge({
             'amount'  => $options{'processing-fee'},
             'pkg'   => $processing_fee_text,

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

Summary of changes:
 FS/FS/cust_main/Billing_Batch.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)




More information about the freeside-commits mailing list