#3194070: LocalTaxTypeBase::checkRegistrations() does not consider Jurisdictions with multiple tax zones changed the implementation of LocalTaxTypeBase::checkRegistrations() to a more simplified version of country code matching. This is causing a regression for certain zones. The funny side of this is, that our customer fulfilled the new EU law conditions by accident with this bug :D It's however not working as expected. So let's have a look at the setup

  • The store address is located in Austria
  • Billing and shipping countries are set to Austria and Germany
  • Tax registration however was only set to Austria (now, it's legally only correct to select Germany as well, but only Austria was selected though)

Before the mentioned change, for German customers the Austrian VAT rate of 20% was calculated, but after the change the German 19% are calculated, even if Germany is not within the tax registration countries. Why? Because the German zone does not only include Germany, but also includes a handful of Austrian postal codes. After the change, only the country code is compared and that's why the 19% are used. So the change may have solved the Madeira-like excluded postal codes problem, but introduced a new one for included postal codes :(

Issue fork commerce-3263578

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

agoradesign created an issue. See original summary.

jsacksick’s picture

IMO, even though reverting the fix from the issue linked fixes the problem... That isn't where the problem lies.

I think the problem is coming from resolveZones() that affects this particular usecase, because of the following code:

 // Physical products use the origin zone, unless the store is
      // registered to pay taxes in the destination zone. This is required
      // when the total yearly transactions breach the defined threshold.
      // See http://www.vatlive.com/eu-vat-rules/vat-registration-threshold/
      $resolved_zones = $store_zones;
      $customer_zone = reset($customer_zones);
      if ($this->checkRegistrations($store, $customer_zone)) {
        $resolved_zones = $customer_zones;
      }

I think this part should be rewritten to call a different method that doesn't only check the country code.

agoradesign’s picture

Status: Active » Needs review
StatusFileSize
new3.24 KB

let's try this one, if it breaks any test

jsacksick’s picture

StatusFileSize
new1.02 KB

The attached patch should hopefully fix your usecase.

agoradesign’s picture

yes it does :)

Status: Needs review » Needs work

The last submitted patch, 6: 3263578-6.patch, failed testing. View results

jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

Status: Needs review » Needs work

The last submitted patch, 9: 3263578-9.patch, failed testing. View results

agoradesign’s picture

to not forget it, my last comment on Slack:

I really believe that this isn't really resolvable with the current architecture...
so either, the zone must know it's tax registration country, or it's wrong that the store entity is only referencing country codes - maybe we need to reference explicit tax zones instead?

jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new2.48 KB

I have a fix that seems to work, however if it is the right fix, it needs better comment... And perhaps the fix itself can be improved :)....

jsacksick’s picture

StatusFileSize
new2.48 KB

Same patch, with a coding standard fix.

jsacksick’s picture

StatusFileSize
new2.62 KB

Same patch in an attempt to make it more readable :p.

jsacksick’s picture

StatusFileSize
new3.18 KB

Last patch of the day...

agoradesign’s picture

Status: Needs review » Reviewed & tested by the community

greeeeeeeeeeeeeeaaaaaaaaat job!

agoradesign’s picture

it only took a whole day and > 255 replies in the Slack thread for both of us :D

dwkitchen’s picture

StatusFileSize
new4.28 KB
new970 bytes

Add additional test for Switzerland with German customers in Büsingen

jsacksick’s picture

-

jsacksick’s picture

agoradesign’s picture

makes sense anyway, because there are German postal codes within Swiss zone.. we have seen so many WTF's today. so this additional test is great

agoradesign’s picture

why should they fail, when they're inside SwissVatTest?

jsacksick’s picture

StatusFileSize
new4.29 KB
jsacksick’s picture

StatusFileSize
new4.28 KB
agoradesign’s picture

it's green :)

dwkitchen’s picture

StatusFileSize
new4.8 KB
new1.05 KB

@jsacksick here is a patch with the additional test we discussed on the EU VAT to check that DE VAT is not applied to a customer in Büsingen

jsacksick’s picture

@dwkitchen: We need to configure the Swiss VAT tax in the test if we want to make sure of that.

dwkitchen’s picture

No, the test assumes that the Swiss Tax Type is not enabled.

This new test is testing EuTaxType line 300; that Büsingen is excluded from Germany

['country_code' => 'DE', 'excluded_postal_codes' => '27498, 78266'],

  • jsacksick committed 1c86a78 on 8.x-2.x
    Issue #3263578 by jsacksick, agoradesign, dwkitchen: Changed logic in...

  • jsacksick committed d01c4f0 on 3.0.x
    Issue #3263578 by jsacksick, agoradesign, dwkitchen: Changed logic in...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.