From 33b372baa48b3799566a37bbd3912520f591c7de Mon Sep 17 00:00:00 2001 From: levinse Date: Wed, 6 Jul 2011 04:15:36 +0000 Subject: [PATCH] modify backdated payment application behaviour, RT11870 --- FS/FS/cust_main/Billing.pm | 7 +++++-- httemplate/edit/process/cust_pay.cgi | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index d565a327c..0133164ec 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -2147,11 +2147,14 @@ sub apply_payments { my $amount = min( $payment->unapplied, $owed ); - my $cust_bill_pay = new FS::cust_bill_pay ( { + my $cbp = { 'paynum' => $payment->paynum, 'invnum' => $cust_bill->invnum, 'amount' => $amount, - } ); + }; + $cbp->{_date} = $payment->_date + if $options{'manual'} && $options{'backdate_application'}; + my $cust_bill_pay = new FS::cust_bill_pay($cbp); $cust_bill_pay->pkgnum( $payment->pkgnum ) if $conf->exists('pkg-balances') && $payment->pkgnum; my $error = $cust_bill_pay->insert(%options); diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index 2c77e6b57..e74f9022f 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -7,7 +7,8 @@ % if ( $cgi->param('apply') eq 'yes' ) { % my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) % or die "unknown custnum $linknum"; -% $cust_main->apply_payments( 'manual' => 1 ); +% $cust_main->apply_payments( 'manual' => 1, +% 'backdate_application' => ($_date < time-86400) ); % } % if ( $link eq 'popup' ) { % -- 2.11.0