<% emt('Prepayment for') %> |
% if ( $amount_id ) {
% }
<& select.html,
field => 'discount_term',
id => 'discount_term',
options => [ '', @discount_term ],
labels => { '' => mt('1 month'),
map { $_ => mt('[_1] months', sprintf('%.0f', $_)) }
@discount_term
},
curr_value => '',
onchange => $amount_id ? 'change_discount_term(this)' : '',
&>
|
% }
<%init>
my %opt = @_;
my $custnum = $opt{'custnum'};
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
or die "unknown custnum $custnum\n";
my @discount_term = ();
my %discounted_total = ();
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;
%discounted_total = map { $_, $plans{$_}->discounted_total } @discount_term;
}
# the DOM id of an input to be disabled/populated with the amount due
my $amount_id = $opt{'amount_id'};
%init>