modify backdated payment application behaviour, RT11870
authorlevinse <levinse>
Wed, 6 Jul 2011 04:16:06 +0000 (04:16 +0000)
committerlevinse <levinse>
Wed, 6 Jul 2011 04:16:06 +0000 (04:16 +0000)
FS/FS/cust_main/Billing.pm
httemplate/edit/process/cust_pay.cgi

index 70d2e7f..a4603df 100644 (file)
@@ -2110,11 +2110,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);
index d6bbf06..38f1616 100755 (executable)
@@ -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' ) {
 %