</TR>
% }
-
<%init>
+
my %opt = @_;
my $custnum = $opt{'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;