diff options
author | ivan <ivan> | 2004-12-11 20:41:38 +0000 |
---|---|---|
committer | ivan <ivan> | 2004-12-11 20:41:38 +0000 |
commit | 08d3918e91ee3438af37345c94a002dec77fe9bb (patch) | |
tree | cfabf2c9314f2c7d3241440f4303e2317e4d20fd /FS | |
parent | c21b6e69583bec632de7fcd340c29982c868f73d (diff) |
add 'send_if_newest' invoice event, closes: Bug#977
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_bill.pm | 23 | ||||
-rw-r--r-- | FS/FS/part_bill_event.pm | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 5b5d3765d..0306c010c 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -377,6 +377,29 @@ sub send { } +=item send_if_newest [ TEMPLATENAME [ , AGENTNUM [ , INVOICE_FROM ] ] ] + +Like B<send>, but only sends the invoice if it is the newest open invoice for +this customer. + +=cut + +sub send_if_newest { + my $self = shift; + + return '' + if scalar( + grep { $_->owed > 0 } + qsearch('cust_bill', { + 'custnum' => $self->custnum, + #'_date' => { op=>'>', value=>$self->_date }, + 'invnum' => { op=>'>', value=>$self->invnum }, + } ) + ); + + $self->send(@_); +} + =item send_csv OPTIONS Sends invoice as a CSV data-file to a remote host with the specified protocol. diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm index f90882817..7dfea5066 100644 --- a/FS/FS/part_bill_event.pm +++ b/FS/FS/part_bill_event.pm @@ -126,7 +126,7 @@ sub check { or $c =~ /^\s*\$cust_bill\->(comp|realtime_(card|ach|lec)|batch_card|send)\(\);\s*$/ - or $c =~ /^\s*\$cust_bill\->send\(\'[\w\-\s]+\'\s*(,\s*\d+\s*,\s*'[\w\@\.\-\+]*'\s*)?\);\s*$/ + or $c =~ /^\s*\$cust_bill\->send(_if_newest)?\(\'[\w\-\s]+\'\s*(,\s*\d+\s*,\s*'[\w\@\.\-\+]*'\s*)?\);\s*$/ or $c =~ /^\s*\$cust_main\->apply_payments; \$cust_main->apply_credits; "";\s*$/ |