add (unfinished) credit card surcharge, part 1
[freeside.git] / httemplate / misc / payment.cgi
index d35e73f..aec68af 100644 (file)
 
 % }
 
+<% include('/elements/tr-select-discount_term.html',
+             'custnum' => $custnum,
+             'cgi'     => $cgi
+          )
+%>
 
 % if ( $payby eq 'CARD' ) {
 %
@@ -300,7 +305,14 @@ my $fee = '';
 my $fee_pkg = '';
 my $fee_display = '';
 my $fee_op = '';
-if ( $conf->config('manual_process-pkgpart') ) {
+my $num_payments = scalar($cust_main->cust_pay);
+#handle old cust_main.pm (remove...)
+$num_payments = scalar( @{ [ $cust_main->cust_pay ] } )
+  unless defined $num_payments;
+if ( $conf->config('manual_process-pkgpart')
+     and ! $conf->exists('manual_process-skip_first') || $num_payments
+   )
+{
 
   $fee_display = $conf->config('manual_process-display') || 'add';
   $fee_op = $fee_display eq 'add' ? '+' : '-';
@@ -320,6 +332,10 @@ if ( $balance > 0 ) {
   $amount = $balance;
   $amount += $fee
     if $fee && $fee_display eq 'subtract';
+
+  my $cc_surcharge_pct = $conf->config('credit-card-surcharge-percentage');
+  $amount += $amount * $cc_surcharge_pct/100 if $cc_surcharge_pct > 0;
+
   $amount = sprintf("%.2f", $amount);
 }