X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-discount_term.html;h=171c1037a3a7aa32a9dd2bb41aaeafad4aa42710;hb=1c3dfc13e3eaf4a0d2fc213111dcbf12608ee81c;hp=e9faeb228175bc840e3c56862e9a7ca658f21c89;hpb=ee2ee290c82013f870e2b23e4235e70998e59ee1;p=freeside.git diff --git a/httemplate/elements/tr-select-discount_term.html b/httemplate/elements/tr-select-discount_term.html index e9faeb228..171c1037a 100644 --- a/httemplate/elements/tr-select-discount_term.html +++ b/httemplate/elements/tr-select-discount_term.html @@ -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) { % } - <%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;