Zen4All-nl / VAT-mod-for-european-companies-on-Zen-Cart

This code has not been tested yet. Do not use in a live store. This mod checks customer's VAT (Value Added Tax) number regarding his country and displays VAT on invoice and packingslip as well as removes tax when shipping to companies in countries within the EU.
GNU General Public License v2.0
0 stars 1 forks source link

Not calculating VAT right #2

Closed IngeVanGemert closed 9 years ago

IngeVanGemert commented 9 years ago

Installed in 1.5.4. A customer with a validated VAT number inside the EU, and outside the Shop country should not be charged VAT. At the moment this is not working, as there is VAT calculated in this case. This is the whole point of this mod. How can we fix it?

Zen4All commented 9 years ago

As stated, on the first page, I have not tested the code yet. I only updated it to the latest ZC release. I will try to make a test site this weekend.

IngeVanGemert commented 9 years ago

I inserted a line in orders.php:

function zen_get_country_geo_zone_id($country_id){ global $db; $country_geo_zone_query = "select geo_zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where zone_country_id = '" . (int)$country_id . "' limit 1"; $country_geo_zone_id = $db->Execute($country_geo_zone_query); return $country_geo_zone_id->fields['geo_zone_id']; }

function zen_tva_geo_tax($tax_country_id, $billing_company, $billing_tva_intracom){ $tax_geo_zone_id = $this->zen_get_country_geo_zone_id($tax_country_id); if($tax_country_id == STORE_COUNTRY ) { return true; // store } if($tax_geo_zone_id == 0) { return true; // no geo-zone } if($tax_geo_zone_id != 0 && $billing_tva_intracom) return true; //added by me if($tax_geo_zone_id != 0 && !$billing_tva_intracom) { return true; // geo-zone & no vat } elseif(!$billing_company && !$billing_tva_intracom) { return false; // no vat } else { return false; } }