From 5250c44bd7f282c7d782bf0e8349af12376929df Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 22 Sep 2010 19:16:20 +0000 Subject: prepayment discounts rt#5318 --- httemplate/misc/process/batch-cust_pay.cgi | 13 +++++++------ httemplate/misc/process/payment.cgi | 26 +++++++++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'httemplate/misc/process') diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi index 4da00c63d..aefc00654 100644 --- a/httemplate/misc/process/batch-cust_pay.cgi +++ b/httemplate/misc/process/batch-cust_pay.cgi @@ -11,12 +11,13 @@ % #while ( exists($param->{"custnum$row"}) ) { % for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { % push @cust_pay, new FS::cust_pay { -% 'custnum' => $param->{"custnum$row"}, -% 'paid' => $param->{"paid$row"}, -% 'payby' => 'BILL', -% 'payinfo' => $param->{"payinfo$row"}, -% 'paybatch' => $paybatch, -% } +% 'custnum' => $param->{"custnum$row"}, +% 'paid' => $param->{"paid$row"}, +% 'payby' => 'BILL', +% 'payinfo' => $param->{"payinfo$row"}, +% 'discount_term' => $param->{"discount_term$row"}, +% 'paybatch' => $paybatch, +% } % if $param->{"custnum$row"} % || $param->{"paid$row"} % || $param->{"payinfo$row"}; diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 665001ea9..c1c9071f9 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -119,19 +119,26 @@ if ( $payby eq 'CHEK' ) { die "unknown payby $payby"; } +$cgi->param('discount_term') =~ /^\d*$/ + or errorpage("illegal discount_term"); +my $discount_term = $1; + my $error = ''; my $paynum = ''; if ( $cgi->param('batch') ) { - $error = $cust_main->batch_card( - 'payby' => $payby, - 'amount' => $amount, - 'payinfo' => $payinfo, - 'paydate' => "$year-$month-01", - 'payname' => $payname, - map { $_ => $cgi->param($_) } - @{$payby2fields{$payby}} - ); + $error = 'Prepayment discounts not supported with batched payments' + if $discount_term; + + $error ||= $cust_main->batch_card( + 'payby' => $payby, + 'amount' => $amount, + 'payinfo' => $payinfo, + 'paydate' => "$year-$month-01", + 'payname' => $payname, + map { $_ => $cgi->param($_) } + @{$payby2fields{$payby}} + ); errorpage($error) if $error; } else { @@ -146,6 +153,7 @@ if ( $cgi->param('batch') ) { 'payunique' => $payunique, 'paycvv' => $paycvv, 'paynum_ref' => \$paynum, + 'discount_term' => $discount_term, map { $_ => $cgi->param($_) } @{$payby2fields{$payby}} ); errorpage($error) if $error; -- cgit v1.2.1