if ( $discount->percent > 0 ) {
$amount = $discount->percent * $param->{'setup_charge'} / 100;
- } elsif ( $discount->amount > 0 && ($discount->months || 0) == 1) {
+ } elsif ( $discount->amount > 0 ) {
# apply the discount amount, up to a maximum of the setup charge
$amount = min($discount->amount, $param->{'setup_charge'});
$discount_left = sprintf('%.2f', $discount->amount - $amount);
# transfer remainder of discount, if any, to recur
$param->{'discount_left_recur'}{$discount->discountnum} = $discount_left;
- } else {
- # I guess we don't allow multiple-month flat amount discounts to
- # apply to setup?
- next;
- }
+ }
} else {
'empty_label' => ( $pkgdiscountnum ? '' : 'Select discount' ),
'onchange' => 'enable_discount_pkg()',
'cgi' => $cgi,
+ 'setup_only' => $setup_only,
)
%>
# " ( pkgnum ". cust_pkg->pkgnum. ")";
my $part_pkg = $cust_pkg->part_pkg;
+my $setup_only = ($part_pkg->freq eq '0') ? 1 : 0;
</%init>
)
%>
+% if ( $opt{'setup_only'} ) {
+ <& /elements/hidden.html,
+ 'field' => $name.'_setup',
+ 'id' => $name.'_setup',
+ 'value' => 'Y'
+ &>
+% } else { # normal case, allow the user to choose
<% include( '/elements/tr-input-text.html',
'label' => '<B>Discount duration (months)</B>',
'field' => $name. '_months',
'colspan' => $opt{'colspan'},
)
%>
+% }
%# <% include( '/elements/tr-checkbox.html',
%# 'label' => '<B>Apply discount to add-on packages</B>',