summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2018-11-06 13:57:35 -0500
committerChristopher Burger <burgerc@freeside.biz>2018-11-06 14:08:09 -0500
commitd5205ac7d2d2f2f8207d77715e20f7f750e6176c (patch)
tree5df919be7bb9c4c6089c6e85c66e27e9d2962d1d /FS/FS/cust_main
parent1fcb4ef3e4e3ad7eae7067d37e7675efa37680fb (diff)
RT# 76093 - added ability for processing fee to be used with batch processing.
Diffstat (limited to 'FS/FS/cust_main')
-rw-r--r--FS/FS/cust_main/Billing_Batch.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/FS/FS/cust_main/Billing_Batch.pm b/FS/FS/cust_main/Billing_Batch.pm
index f771329..2975dff 100644
--- a/FS/FS/cust_main/Billing_Batch.pm
+++ b/FS/FS/cust_main/Billing_Batch.pm
@@ -165,6 +165,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,