diff options
author | Christopher Burger <burgerc@freeside.biz> | 2018-05-14 10:21:15 -0400 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2018-05-14 10:21:15 -0400 |
commit | 88371c24e0b727646f0b01288f01439a06967fe7 (patch) | |
tree | f665111af01c7059d3dc0f9e706f3aee656a8f6c /httemplate/elements/tr-amount_fee.html | |
parent | 2eea268a59cf357853e31ff8d5db6033e4bdc8ea (diff) |
RT# 34134 - fixed error with credit surchage not attached to total
Diffstat (limited to 'httemplate/elements/tr-amount_fee.html')
-rw-r--r-- | httemplate/elements/tr-amount_fee.html | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html index 9e6d9e96d..3ad2cdf06 100644 --- a/httemplate/elements/tr-amount_fee.html +++ b/httemplate/elements/tr-amount_fee.html @@ -8,7 +8,7 @@ VALUE = "<% $amount %>" SIZE = 8 STYLE = "text-align:right;" -% if ( $fee ) { +% if ( $fee || $surcharge ) { onChange = "amount_changed(this)" onKeyDown = "amount_changed(this)" onKeyUp = "amount_changed(this)" @@ -28,17 +28,23 @@ <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT> % } +% if ( $surcharge ) { + <INPUT TYPE="hidden" NAME="surcharge_percentage" ID="surcharge_percentage" VALUE="<% $surcharge_percentage %>"> + <INPUT TYPE="hidden" NAME="surcharge_flatfee" ID="surcharge_flatfee" VALUE="<% $surcharge_flatfee %>"> + </TD><TD ID="ajax_surcharge_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue"> + <FONT SIZE="+1">A credit card surcharge of <% $money_char. sprintf('%.2f', ($amount * $surcharge_percentage) + $surcharge_flatfee) %> is included in this payment</FONT> +% } </TD></TR></TABLE> </TD> </TR> -% if ( $fee ) { +% if ($fee || $surcharge) { <SCRIPT TYPE="text/javascript"> function amount_changed(what) { - +% if ( $fee ) { var total = ''; if ( what.value.length ) { total = parseFloat(what.value) <% $fee_op %> <% $fee %>; @@ -48,6 +54,13 @@ var total_cell = document.getElementById('ajax_total_cell'); total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT>'; +% } + +% if ( $surcharge ) { + var surcharge_cell = document.getElementById('ajax_surcharge_cell'); + var surcharge = ((what.value - <% $surcharge_flatfee %>) * <% $surcharge_percentage %>) + <% $surcharge_flatfee %>; + surcharge_cell.innerHTML = '<FONT SIZE="+1">A credit card surcharge of ' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; +% } } @@ -66,6 +79,9 @@ my $fee = ''; my $fee_pkg = ''; my $fee_display = ''; my $fee_op = ''; +my $surcharge = ''; +my $surcharge_percentage = 0; +my $surcharge_flatfee = 0; if ( $opt{'process-pkgpart'} and ! $opt{'process-skip_first'} || $opt{'num_payments'} @@ -91,11 +107,13 @@ if ( $amount > 0 ) { if $fee && $fee_display eq 'subtract'; #&{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; - $amount += $amount * $opt{'surcharge_percentage'}/100 - if $opt{'surcharge_percentage'} > 0; - $amount += $opt{'surcharge_flatfee'} - if $opt{'surcharge_flatfee'} > 0; + $surcharge_percentage = $opt{'surcharge_percentage'}/100 if $opt{'surcharge_percentage'} > 0; + $surcharge_flatfee = $opt{'surcharge_flatfee'} if $opt{'surcharge_flatfee'} > 0; + $surcharge = $amount * $surcharge_percentage if $surcharge_percentage > 0; + $surcharge += $surcharge_flatfee if $surcharge_flatfee > 0; + + $amount += $surcharge; $amount = sprintf("%.2f", $amount); } |