+ $months = 1; # XXX really? not $chg_months?
+ }
+ #elsif ( $discount->setup
+ # && ($discount->months || 0) == 1
+ # && $discount->amount > 0
+ # ) {
+ # next;
+ #
+ # RT #11512: bugfix to prevent applying flat discount to both setup
+ # and recur. The original implementation ignored discount_left_recur
+ # if it was zero, so if the setup fee used up the entire flat
+ # discount, the recurring charge would get to use the entire flat
+ # discount also. This bugfix was a kludge. Instead, we now allow
+ # discount_left_recur to be zero in that case, and then the available
+ # recur discount is zero.
+ #}
+
+ # transfer remainder of discount, if any, to setup
+ # this is used when the recur phase wants to add a setup fee
+ # (prorate_defer_bill): the "discount_left_setup" amount will
+ # be subtracted in _make_lines.
+ if ( $discount->setup && $discount->amount > 0
+ && ($discount->months || 0) != 1
+ )
+ {
+ # $amount is no longer permonth at this point! correct. very good.
+ $discount_left = $amount - $recur_charge; # backward, as above
+ if ( $discount_left > 0 ) {
+ $amount = $recur_charge;
+ $param->{'discount_left_setup'}{$discount->discountnum} =
+ 0 - $discount_left;
+ }
+ }