X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-discount_term.html;h=171c1037a3a7aa32a9dd2bb41aaeafad4aa42710;hp=d4218f848bd3a6dfadf81229db3a8530650970ac;hb=560af69840e7e3fcebf65d5d56ca4efc0851efec;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125 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) { % } - <%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;