- Issue created by @Pandepoulus
- Status changed to Fixed
8 months ago 9:22am 10 May 2024 - 🇮🇱Israel jsacksick
There should be something to select the default tax, or to limit the taxes to stores.
You can add conditions to tax types? See the attached screenshot.
- 🇪🇸Spain Pandepoulus
I do have IGI configured just for the Andorran store. Anyway, in the Spanish store, when someone buys from outside the EU where there is no appliable tax, as the "prices includes tax" is selected, the resolver tries to look for a "default tax" to substract to the price. And it selects the andorran IGI.
When there is no tax, getDefaultTaxType from StoreTax is called.
the code, which i add here:public function getDefaultTaxType(StoreInterface $store) { $store_id = $store->id(); if (!array_key_exists($store_id, $this->storeTaxTypes)) { $store_address = $store->getAddress(); $tax_types = $this->getTaxTypes(); $this->storeTaxTypes[$store_id] = NULL; foreach ($tax_types as $tax_type) { /** @var \Drupal\commerce_tax\Plugin\Commerce\TaxType\LocalTaxTypeInterface $tax_type_plugin */ $tax_type_plugin = $tax_type->getPlugin(); $matching_zones = $tax_type_plugin->getMatchingZones($store_address); if ($matching_zones) { $this->storeTaxTypes[$store_id] = $tax_type; break; } } } return $this->storeTaxTypes[$store_id]; }
Just iterates for al taxes ($this->getTaxTypes()) and checks for addresses. As IGI is a universal tax, its zone matches and is returned as the default tax for the spanish tax to subsctract the price when there is no tax configured. (outside EU).
There is no validation that the tax is appliable for the store.
Hope i have explained it better. Automatically closed - issue fixed for 2 weeks with no activity.