summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2018-08-08 19:35:34 -0400
committerChristopher Burger <burgerc@freeside.biz>2018-08-08 19:35:34 -0400
commita3c654c1ae9ea07726aba9899a9b2e1d4dbd12c6 (patch)
treeb429165bf91d1193b064a899eb22118bf907273c /httemplate
parent038b31793f290f65222ae748df05e703c6ae035d (diff)
RT# 34134 - updated select invoice to actually pay the invoice being selected not the oldest one.
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/elements/tr-select-invoice.html9
-rw-r--r--httemplate/elements/tr-select-payment_options.html5
-rw-r--r--httemplate/misc/process/payment.cgi4
3 files changed, 14 insertions, 4 deletions
diff --git a/httemplate/elements/tr-select-invoice.html b/httemplate/elements/tr-select-invoice.html
index 434042c9b..d35813fc5 100644
--- a/httemplate/elements/tr-select-invoice.html
+++ b/httemplate/elements/tr-select-invoice.html
@@ -26,10 +26,14 @@ Example:
<OPTION VALUE="select">Select an invoice to pay</OPTION>
% foreach my $record (@invoices) {
% my $read_date = time2str("%b %o, %Y", $record->_date);
- <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION>
+% $hidden .= '<INPUT TYPE="hidden" ID="inv'.$record->invnum.'" NAME="inv'.$record->invnum.'" VALUE="'.$record->owed.'">';
+ <OPTION VALUE="<% $record->invnum %>"><% $record->invnum %> (<% $read_date %>) - <% $record->owed %></OPTION>
% }
- </SELECT>
+ </SELECT>
+
+ <% $hidden %>
+
</TD>
</TR>
@@ -37,6 +41,7 @@ Example:
my %opt = @_;
my $status = $opt{'status'} ? $opt{'status'} : 'all';
+my $hidden;
my @invoices;
if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; }
diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html
index 35e6def94..f86f3edfd 100644
--- a/httemplate/elements/tr-select-payment_options.html
+++ b/httemplate/elements/tr-select-payment_options.html
@@ -131,11 +131,12 @@ Example:
function <% $opt{prefix} %>invoice_select_changed(what) {
var surcharge;
+ var invdue = document.getElementById("<% $opt{prefix} %>inv" + what.value);
if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) {
- surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
+ surcharge = (+invdue.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
}
else { surcharge = 0; }
- var amount = +what.value + +surcharge;
+ var amount = +invdue.value + +surcharge;
if ( what.value == 'select' ) {
$('#payment_amount_row').hide();
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index 5620b5b4b..939fc38c2 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -39,6 +39,8 @@ my $cust_main = qsearchs({
'extra_sql' => ' AND '. $curuser->agentnums_sql,
}) or die "unknown custnum $custnum";
+my $invoice = ($cgi->param('invoice') =~ /^(\d+)$/) ? $cgi->param('invoice') : '';
+
$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/
or errorpage("illegal amount ". $cgi->param('amount'));
my $amount = $1;
@@ -224,6 +226,7 @@ if ( $cgi->param('batch') ) {
'payinfo' => $payinfo,
'paydate' => $paydate,
'payname' => $payname,
+ 'invnum' => $invoice,
map { $_ => scalar($cgi->param($_)) }
@{$payby2fields{$payby}}
);
@@ -246,6 +249,7 @@ if ( $cgi->param('batch') ) {
'discount_term' => $discount_term,
'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
'no_invnum' => 1,
+ 'invnum' => $invoice,
map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
);
errorpage($error) if $error;