- # Test for the simple case where all packages on the invoice
- # are eligible for the same set of discounts. If not, we need
- # to list eligibility in the ext_description.
- my $list_pkgnums = ( $pkgnums_times_discounts != $pkgnums * keys(%total) );
-
- foreach my $hash (values %total) {
- my $discount = $hash->{discount};
- my ($amount, $term_total, $percent, $permonth);
- my $months = $discount->months;
- $hash->{months} = $months;
-
- if ( $discount->percent ) {
-
- # per discount_Mixin, percent discounts are calculated on the base
- # recurring fee, not the prorated fee.
- $percent = $discount->percent;
- $amount = sprintf('%.2f', 0.01 * $percent * $hash->{base_permonth});
- # percent discounts apply to setup fee
- if ( $discount->setup ) {
- $hash->{setup} *= (1 - 0.01*$percent);
- }
+ # tricky, because packages may not all be eligible for the same discounts
+ foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
+ my $cust_pkg = $cust_bill_pkg->cust_pkg or next;
+ my $part_pkg = $cust_pkg->part_pkg or next;