my ($self, $cust_bill_pkg) = @_;
my $part_item = $cust_bill_pkg->part_X;
- my $location = $cust_bill_pkg->tax_location;
+ my $location = $cust_bill_pkg->tax_location
+ or return;
my $custnum = $self->{cust_main}->custnum;
push @{ $self->{items} }, $cust_bill_pkg;
my $taxable_charged = $cust_bill_pkg->setup + $cust_bill_pkg->recur
or next; # don't create zero-amount exemptions
+ ## re-add the discounted amount if the tax needs to be charged pre discount
+ if ($tax_object->charge_prediscount) {
+ my $discount_amount = 0;
+ foreach my $discount (@{$cust_bill_pkg->discounts}) {
+ $discount_amount += $discount->amount;
+ }
+ $taxable_charged += $discount_amount;
+ }
+
# XXX the following procedure should probably be in cust_bill_pkg
if ( $exempt_cust ) {