-
- my $cust_pkg = $cust_bill_pkg->cust_pkg;
- my $part_pkg = $cust_bill_pkg->part_pkg;
-
- my @new_exemptions;
- my $taxable_charged = $cust_bill_pkg->setup + $cust_bill_pkg->recur
- or next; # don't create zero-amount exemptions
-
- # XXX the following procedure should probably be in cust_bill_pkg
-
- if ( $exempt_cust ) {
-
- push @new_exemptions, FS::cust_tax_exempt_pkg->new({
- amount => $taxable_charged,
- exempt_cust => 'Y',
- });
- $taxable_charged = 0;
-
- } elsif ( $exempt_cust_taxname ) {
-
- push @new_exemptions, FS::cust_tax_exempt_pkg->new({
- amount => $taxable_charged,
- exempt_cust_taxname => 'Y',
- });
- $taxable_charged = 0;
-
+ # careful... may be a cust_bill_pkg or a quotation_pkg
+
+ my $taxable_charged = $cust_bill_pkg->setup + $cust_bill_pkg->recur;
+ foreach ( grep { $_->taxnum == $self->taxnum }
+ @{ $cust_bill_pkg->cust_tax_exempt_pkg }
+ ) {
+ # deal with exemptions that have been set on this line item, and
+ # pertain to this tax def
+ $taxable_charged -= $_->amount;