config to turn on term discounts feature, fixing perf problems entering payments...
authorIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 01:53:46 +0000 (18:53 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 01:53:46 +0000 (18:53 -0700)
FS/FS/Conf.pm
httemplate/edit/cust_pay.cgi
httemplate/elements/tr-select-discount_term.html
httemplate/misc/payment.cgi

index 4b55f65..f1893b7 100644 (file)
@@ -5701,6 +5701,13 @@ and customer address. Include units.',
                         },
   },
 
                         },
   },
 
+  {
+    'key'         => 'part_pkg-term_discounts',
+    'section'     => 'billing',
+    'description' => 'Enable the term discounts feature.  Recommended to keep turned off unless actually using - not well optimized for large installations.',
+    'type'        => 'checkbox',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index d4414e4..ec7391b 100755 (executable)
   <TD><INPUT TYPE="text" NAME="paid" ID="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
 </TR>
 
   <TD><INPUT TYPE="text" NAME="paid" ID="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=9> <% mt('by') |h %> <B><% mt(FS::payby->payname($payby)) |h %></B></TD>
 </TR>
 
-  <& /elements/tr-select-discount_term.html,
-               'custnum' => $custnum,
-               'amount_id' => 'paid',
-  &>
+% if ( $conf->exists('part_pkg-term_discounts') ) {
+    <& /elements/tr-select-discount_term.html,
+         'custnum'   => $custnum,
+         'amount_id' => 'paid',
+    &>
+% }
 
 % if ( $payby eq 'BILL' ) { 
   <TR>
 
 % if ( $payby eq 'BILL' ) { 
   <TR>
index d4218f8..171c103 100644 (file)
@@ -34,8 +34,8 @@ function change_discount_term(what) {
   </TR>
 
 % }
   </TR>
 
 % }
-
 <%init>
 <%init>
+
 my %opt = @_;
 
 my $custnum = $opt{'custnum'};
 my %opt = @_;
 
 my $custnum = $opt{'custnum'};
@@ -45,7 +45,10 @@ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
 
 my @discount_term = ();
 my %discounted_total = ();
 
 my @discount_term = ();
 my %discounted_total = ();
+
+#this is inefficient for many years worth of invoices
 my $last_bill = ($cust_main->cust_bill)[-1];
 my $last_bill = ($cust_main->cust_bill)[-1];
+
 if ( $last_bill ) { # if not, there are no discounts possible
   my %plans = $last_bill->discount_plans;
   @discount_term = sort { $a <=> $b } keys %plans;
 if ( $last_bill ) { # if not, there are no discounts possible
   my %plans = $last_bill->discount_plans;
   @discount_term = sort { $a <=> $b } keys %plans;
index 5b9f63d..90b03c7 100644 (file)
        'surcharge_percentage' => scalar($conf->config('credit-card-surcharge-percentage')),
   &>
 
        'surcharge_percentage' => scalar($conf->config('credit-card-surcharge-percentage')),
   &>
 
-  <& /elements/tr-select-discount_term.html,
-       'custnum'   => $custnum,
-       'amount_id' => 'amount',
-  &>
+% if ( $conf->exists('part_pkg-term_discounts') ) {
+    <& /elements/tr-select-discount_term.html,
+         'custnum'   => $custnum,
+         'amount_id' => 'amount',
+    &>
+% }
 
 % if ( $payby eq 'CARD' ) {
 %
 
 % if ( $payby eq 'CARD' ) {
 %