RT# 80488 Ensure WA distrct taxes are properly applied
authorMitch Jackson <mitch@freeside.biz>
Wed, 12 Jun 2019 07:22:57 +0000 (03:22 -0400)
committerMitch Jackson <mitch@freeside.biz>
Wed, 12 Jun 2019 07:22:57 +0000 (03:22 -0400)
FS/FS/TaxEngine/internal.pm
FS/FS/cust_main/Billing.pm

index 6fb1ca7..d680af8 100644 (file)
@@ -39,10 +39,28 @@ sub add_sale {
   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
index 5f8dd9b..aadc8e1 100644 (file)
@@ -1649,10 +1649,28 @@ sub _handle_taxes {
     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