summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-05-06 18:53:46 -0700
committerIvan Kohler <ivan@freeside.biz>2014-05-06 18:53:46 -0700
commit028c83edfa000f6bdbcd32ee3ffd5ee5561110d2 (patch)
tree8145b5b1d9d316d0bdd8b4150d867fcb566e7f45
parent4bedcbc1559746f5aa2d2bbb9b26d6519ae47829 (diff)
config to turn on term discounts feature, fixing perf problems entering payments / manually processing cards, RT#27038
-rw-r--r--FS/FS/Conf.pm7
-rwxr-xr-xhttemplate/edit/cust_pay.cgi10
-rw-r--r--httemplate/elements/tr-select-discount_term.html5
-rw-r--r--httemplate/misc/payment.cgi10
4 files changed, 23 insertions, 9 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 4b55f65a1..f1893b7a4 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 d4414e44e..ec7391b20 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 d4218f848..171c1037a 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 5b9f63dc0..90b03c7e8 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' ) {
%