my @taxes = (); # entries are cust_main_county objects
my %taxhash_elim = %taxhash;
my @elim = qw( district city county state );
+
+ # WA state district city names are not stable in the WA tax tables
+ # Allow districts to match with just a district id
+ if ( $taxhash{district} ) {
+ @taxes = qsearch( cust_main_county => {
+ district => $taxhash{district},
+ taxclass => $taxhash{taxclass},
+ });
+ if ( !scalar(@taxes) && $taxhash{taxclass} ) {
+ qsearch( cust_main_county => {
+ district => $taxhash{district},
+ taxclass => '',
+ });
+ }
+ }
+
do {
#first try a match with taxclass
- @taxes = qsearch( 'cust_main_county', \%taxhash_elim );
+ if ( !scalar(@taxes) ) {
+ @taxes = qsearch( 'cust_main_county', \%taxhash_elim );
+ }
if ( !scalar(@taxes) && $taxhash_elim{'taxclass'} ) {
#then try a match without taxclass
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 ) {