[freeside-commits] branch FREESIDE_3_BRANCH updated. 3e9862885750180d31ec85135a8c4e3d6571875a

Christopher Burger burgerc at freeside.biz
Thu May 24 07:12:49 PDT 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  3e9862885750180d31ec85135a8c4e3d6571875a (commit)
       via  c85d36a31cd15e8d06f9dfc7d2591f918d278d89 (commit)
      from  a8981b8fc11c032fd4fa1a3943c4785391a9ffb4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3e9862885750180d31ec85135a8c4e3d6571875a
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri May 11 20:43:48 2018 -0400

    RT# 79737 - fixed error in code

diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 36ae77bdf..44904fba6 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -22,7 +22,7 @@
              ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
              : 0
          ),
-       'surcharge_flatfee:Q' =>
+       'surcharge_flatfee' =>
          ( $payby eq 'CARD'
              ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
              : 0

commit c85d36a31cd15e8d06f9dfc7d2591f918d278d89
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri May 11 11:29:36 2018 -0400

    RT# 79737 - Added ability to us a cc surcharge of a flat fee.
    
    Conflicts:
            FS/FS/cust_main/Billing_Realtime.pm
            httemplate/elements/tr-select-payment_options.html

diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm
index 3a4bfe133..d615c271c 100644
--- a/FS/FS/ClientAPI/MasonComponent.pm
+++ b/FS/FS/ClientAPI/MasonComponent.pm
@@ -63,6 +63,7 @@ my %session_callbacks = (
       'process-skip_first' => $conf->exists('selfservice_process-skip_first'),
       'num_payments'       => scalar($cust_main->cust_pay), 
       'surcharge_percentage' => scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum)),
+      'surcharge_flatfee'  => scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum)),
     );
     @$argsref = ( %args );
 
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index d604491af..476ef0789 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -935,6 +935,7 @@ sub payment_info {
   $return{paybatch} = $return{payunique};  #back compat
 
   $return{credit_card_surcharge_percentage} = $conf->config('credit-card-surcharge-percentage', $cust_main->agentnum);
+  $return{credit_card_surcharge_flatfee} = $conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum);
 
   return { 'error' => '',
            %return,
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index c58ca33f4..8b18a3c3c 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -887,6 +887,14 @@ my $validate_email = sub { $_[0] =~
   },
 
   {
+    'key'         => 'credit-card-surcharge-flatfee',
+    'section'     => 'credit_cards',
+    'description' => 'Add a credit card surcharge to invoices, as a flat fee.',
+    'type'        => 'text',
+    'per_agent'   => 1,
+  },
+
+  {
     'key'         => 'discount-show-always',
     'section'     => 'billing',
     'description' => 'Generate a line item on an invoice even when a package is discounted 100%',
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 63ae777e6..ae41c70c4 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -358,16 +358,24 @@ sub realtime_bop {
     if $conf->config('credit-card-surcharge-percentage', $self->agentnum)
     && $options{method} eq 'CC';
 
+  my $cc_surcharge_flat = 0;
+  $cc_surcharge_flat = $conf->config('credit-card-surcharge-flatfee', $self->agentnum)
+    if $conf->config('credit-card-surcharge-flatfee', $self->agentnum)
+    && $options{method} eq 'CC';
+
   # always add cc surcharge if called from event 
-  if($options{'cc_surcharge_from_event'} && $cc_surcharge_pct > 0) {
-      $cc_surcharge = $options{'amount'} * $cc_surcharge_pct / 100;
+  if($options{'cc_surcharge_from_event'} && ($cc_surcharge_pct > 0 || $cc_surcharge_flat > 0)) {
+    if ($options{'amount'} > 0) {
+      $cc_surcharge = ($options{'amount'} * ($cc_surcharge_pct / 100)) + $cc_surcharge_flat;
       $options{'amount'} += $cc_surcharge;
       $options{'amount'} = sprintf("%.2f", $options{'amount'}); # round (again)?
+    }
   }
-  elsif($cc_surcharge_pct > 0) { # we're called not from event (i.e. from a 
-                                 # payment screen), so consider the given 
-				 # amount as post-surcharge
-    $cc_surcharge = $options{'amount'} - ($options{'amount'} / ( 1 + $cc_surcharge_pct/100 ));
+  elsif($cc_surcharge_pct > 0 || $cc_surcharge_flat > 0) {
+    # we're called not from event (i.e. from a
+    # payment screen), so consider the given
+		# amount as post-surcharge
+    $cc_surcharge = $options{'amount'} - (($options{'amount'} - $cc_surcharge_flat) / ( 1 + $cc_surcharge_pct/100 )) if $options{'amount'} > 0;
   }
   
   $cc_surcharge = sprintf("%.2f",$cc_surcharge) if $cc_surcharge > 0;
diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html
index 12488521a..e3b8d7800 100644
--- a/httemplate/elements/tr-amount_fee.html
+++ b/httemplate/elements/tr-amount_fee.html
@@ -94,6 +94,9 @@ if ( $amount > 0 ) {
   $amount += $amount * $opt{'surcharge_percentage'}/100
     if $opt{'surcharge_percentage'} > 0;
 
+  $amount += $opt{'surcharge_flatfee'}
+    if $opt{'surcharge_flatfee'} > 0;
+
   $amount = sprintf("%.2f", $amount);
 }
 
diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html
new file mode 100644
index 000000000..8859b9b36
--- /dev/null
+++ b/httemplate/elements/tr-select-payment_options.html
@@ -0,0 +1,99 @@
+<%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 4fa3df773..36ae77bdf 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -22,6 +22,11 @@
              ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
              : 0
          ),
+       'surcharge_flatfee:Q' =>
+         ( $payby eq 'CARD'
+             ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
+             : 0
+         ),
   &>
 
 % if ( $conf->exists('part_pkg-term_discounts') ) {

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MasonComponent.pm                  |  1 +
 FS/FS/ClientAPI/MyAccount.pm                       |  1 +
 FS/FS/Conf.pm                                      |  8 ++
 FS/FS/cust_main/Billing_Realtime.pm                | 20 +++--
 httemplate/elements/tr-amount_fee.html             |  3 +
 httemplate/elements/tr-select-payment_options.html | 99 ++++++++++++++++++++++
 httemplate/misc/payment.cgi                        |  5 ++
 7 files changed, 131 insertions(+), 6 deletions(-)
 create mode 100644 httemplate/elements/tr-select-payment_options.html




More information about the freeside-commits mailing list