Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / elements / tr-select-discount_term.html
index e9faeb2..171c103 100644 (file)
@@ -24,7 +24,9 @@ function change_discount_term(what) {
         id      => 'discount_term',
         options => [ '', @discount_term ],
         labels  => { '' => mt('1 month'), 
-                     map { $_ => mt('[_1] months', $_) } @discount_term },
+                     map { $_ => mt('[_1] months', sprintf('%.0f', $_)) }
+                      @discount_term
+                   },
         curr_value => '',
         onchange => $amount_id ? 'change_discount_term(this)' : '',
       &>
@@ -32,8 +34,8 @@ function change_discount_term(what) {
   </TR>
 
 % }
-
 <%init>
+
 my %opt = @_;
 
 my $custnum = $opt{'custnum'};
@@ -43,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;