[freeside-commits] branch master updated. 028c83edfa000f6bdbcd32ee3ffd5ee5561110d2

Ivan ivan at 420.am
Tue May 6 18:53:47 PDT 2014


The branch, master has been updated
       via  028c83edfa000f6bdbcd32ee3ffd5ee5561110d2 (commit)
      from  4bedcbc1559746f5aa2d2bbb9b26d6519ae47829 (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 028c83edfa000f6bdbcd32ee3ffd5ee5561110d2
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue May 6 18:53:46 2014 -0700

    config to turn on term discounts feature, fixing perf problems entering payments / manually processing cards, RT#27038

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 4b55f65..f1893b7 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -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" },
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi
index d4414e4..ec7391b 100755
--- a/httemplate/edit/cust_pay.cgi
+++ b/httemplate/edit/cust_pay.cgi
@@ -56,10 +56,12 @@
   <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>
diff --git a/httemplate/elements/tr-select-discount_term.html b/httemplate/elements/tr-select-discount_term.html
index d4218f8..171c103 100644
--- a/httemplate/elements/tr-select-discount_term.html
+++ b/httemplate/elements/tr-select-discount_term.html
@@ -34,8 +34,8 @@ function change_discount_term(what) {
   </TR>
 
 % }
-
 <%init>
+
 my %opt = @_;
 
 my $custnum = $opt{'custnum'};
@@ -45,7 +45,10 @@ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
 
 my @discount_term = ();
 my %discounted_total = ();
+
+#this is inefficient for many years worth of invoices
 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;
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 5b9f63d..90b03c7 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -20,10 +20,12 @@
        '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' ) {
 %

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

Summary of changes:
 FS/FS/Conf.pm                                    |    7 +++++++
 httemplate/edit/cust_pay.cgi                     |   10 ++++++----
 httemplate/elements/tr-select-discount_term.html |    5 ++++-
 httemplate/misc/payment.cgi                      |   10 ++++++----
 4 files changed, 23 insertions(+), 9 deletions(-)




More information about the freeside-commits mailing list