summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2018-11-05 17:44:50 -0500
committerChristopher Burger <burgerc@freeside.biz>2018-11-06 17:02:02 -0500
commit959a59186f30a33d167b12e67d3c9cc4ce58a0f5 (patch)
treed61a05795fcdf4c40116ee3cca546577025165a3 /httemplate
parentad94da6a8b46ba0cb915a69307810c8a5bcf6749 (diff)
RT# 76093 - Added ability to charge a processing fee when taking a payment on the back end
Conflicts: FS/FS/Conf.pm FS/FS/cust_main/Billing_Batch.pm httemplate/elements/tr-amount_fee.html httemplate/elements/tr-select-payment_options.html httemplate/misc/process/payment.cgi
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/elements/tr-amount_fee.html44
-rw-r--r--httemplate/elements/tr-select-payment_options.html99
-rw-r--r--httemplate/misc/payment.cgi1
-rw-r--r--httemplate/misc/process/payment.cgi4
4 files changed, 47 insertions, 101 deletions
diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html
index e3b8d7800..1cd59bbc3 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 || $processing_fee) {
onChange = "amount_changed(this)"
onKeyDown = "amount_changed(this)"
onKeyUp = "amount_changed(this)"
@@ -32,7 +32,23 @@
</TD>
</TR>
-% if ( $fee ) {
+% if ( $processing_fee ) {
+ <TR>
+ <TH ALIGN="right"><% mt('Processing fee') |h %></TH>
+ <TD>
+ <TABLE><TR>
+ <TD BGCOLOR="#ffffff">
+ <INPUT TYPE="checkbox" NAME="processing_fee" ID="processing_fee" VALUE="<% $processing_fee %>" onclick="<% $opt{prefix} %>process_fee_changed()">
+ </TD>
+ <TD>
+ Apply a processing fee of <% $processing_fee %> .</FONT>
+ </TD>
+ </TR></TABLE>
+ </TD>
+ </TR>
+% }
+
+% if ($fee) {
<SCRIPT TYPE="text/javascript">
@@ -55,6 +71,27 @@
% }
+% if ($processing_fee) {
+
+ <SCRIPT TYPE="text/javascript">
+
+ function <% $opt{prefix} %>process_fee_changed(what) {
+
+ if (document.getElementById('processing_fee').checked == true) {
+ var amount = +document.getElementById('amount').value + +document.getElementById('processing_fee').value;
+ $('#amount').val(amount.toFixed(2));
+ }
+ else {
+ var amount = +document.getElementById('amount').value - +document.getElementById('processing_fee').value;
+ $('#amount').val(amount.toFixed(2));
+ }
+
+ }
+
+ </SCRIPT>
+
+% }
+
<%init>
my %opt = @_;
@@ -66,6 +103,7 @@ my $fee = '';
my $fee_pkg = '';
my $fee_display = '';
my $fee_op = '';
+my $processing_fee = 0;
if ( $opt{'process-pkgpart'}
and ! $opt{'process-skip_first'} || $opt{'num_payments'}
@@ -97,6 +135,8 @@ if ( $amount > 0 ) {
$amount += $opt{'surcharge_flatfee'}
if $opt{'surcharge_flatfee'} > 0;
+ $processing_fee = $opt{'processing_fee'} if $opt{'processing_fee'} > 0;
+
$amount = sprintf("%.2f", $amount);
}
diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html
deleted file mode 100644
index 8859b9b36..000000000
--- a/httemplate/elements/tr-select-payment_options.html
+++ /dev/null
@@ -1,99 +0,0 @@
-<%doc>
-
-Example:
-
- include( '/elements/tr-select-payment_options.html',
-
- #opt - most get used in /elements/tr-amount-fee
- 'custnum' => 4, # customer number needed for selecting invoices
- 'prefix' => 'pre', # prefix to fields and row ID's
- 'amount' => 1, # payment amount
- 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
- 'process-display' => scalar($conf->config('manual_process-display')),
- 'process-skip_first' => $conf->exists('manual_process-skip_first'),
- 'num_payments' => scalar($cust_main->cust_pay),
- 'surcharge_percentage' =>
- ( $payby eq 'CARD'
- ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
- : 0
- ),
- 'surcharge_flatfee' =>
- ( $payby eq 'CARD'
- ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
- : 0
- ),
- )
-
-</%doc>
-
- <TR STYLE="display:block">
- <TH ALIGN="right"><% mt('Payment options') |h %></TH>
- <TD COLSPAN=7>
- <SELECT
- ID = "<% $opt{prefix} %>payment_option"
- NAME = "<% $opt{prefix} %>payment_option"
- onChange = "<% $opt{prefix} %>payment_option_changed(this)"
- <% $opt{disabled} %>
- >
- <OPTION VALUE="select">Select payment option</OPTION>
- <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION>
- <OPTION VALUE="invoice">Pay specific invoice</OPTION>
- <OPTION VALUE="">Pay specific amount</OPTION>
- </SELECT>
- </TD>
- </TR>
-
- <& /elements/tr-select-invoice.html,
- 'custnum' => $opt{custnum},
- 'prefix' => $opt{prefix},
- &>
-
- <& /elements/tr-amount_fee.html,
- 'row_style' => 'STYLE="display:none;"',
- %opt
- &>
-
- <SCRIPT TYPE="text/javascript">
-
- function <% $opt{prefix} %>payment_option_changed(what) {
-
- if ( what.value == 'select' ) {
- document.getElementById('payment_amount_row').style.display = 'none';
- document.getElementById('invoice_row').style.display = 'none';
- document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
- document.getElementById('amount').value = '';
- }
- else if ( what.value == 'invoice' ) {
- document.getElementById('payment_amount_row').style.display = 'none';
- document.getElementById('invoice_row').style.display = 'block';
- document.getElementById('amount').value = '';
- }
- else {
- document.getElementById('payment_amount_row').style.display = 'block';
- document.getElementById('invoice_row').style.display = 'none';
- document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
- document.getElementById('amount').value = what.value;
- }
-
- }
-
- function <% $opt{prefix} %>invoice_select_changed(what) {
-
- if ( what.value == 'select' ) {
- document.getElementById('payment_amount_row').style.display = 'none';
- document.getElementById('amount').value = '';
- }
- else {
- document.getElementById('payment_amount_row').style.display = 'block';
- document.getElementById('amount').value = what.value;
- }
-
- }
-
-</SCRIPT>
-
-<%init>
-
-my %opt = @_;
-
-</%init> \ No newline at end of file
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index b882da061..6a1fd550b 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -27,6 +27,7 @@
? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
: 0
),
+ 'processing_fee' => scalar($conf->config('processing-fee', $cust_main->agentnum)),
&>
% if ( $conf->exists('part_pkg-term_discounts') ) {
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index 6163b93dd..4d4e62a32 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -32,6 +32,8 @@ my $custnum = $1;
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
die "unknown custnum $custnum" unless $cust_main;
+my $processing_fee = $cgi->param('processing_fee') ? $cgi->param('processing_fee') : '';
+
$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/
or errorpage("illegal amount ". $cgi->param('amount'));
my $amount = $1;
@@ -204,6 +206,7 @@ if ( $cgi->param('batch') ) {
'payinfo' => $payinfo,
'paydate' => "$year-$month-01",
'payname' => $payname,
+ 'processing-fee' => $processing_fee,
map { $_ => scalar($cgi->param($_)) }
@{$payby2fields{$payby}}
);
@@ -225,6 +228,7 @@ if ( $cgi->param('batch') ) {
'discount_term' => $discount_term,
'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
'no_invnum' => 1,
+ 'processing-fee' => $processing_fee,
map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
);
errorpage($error) if $error;