Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[-] BO: FIX #PSCFV-5088 - cant add a tax rule to a group if one have …

…already defined as unique
  • Loading branch information...
commit ee62ed8d27c0cf545e8064a6dd613296782d4b88 1 parent 4aa0a69
@rGaillard rGaillard authored
Showing with 13 additions and 1 deletion.
  1. +3 −1 classes/tax/TaxRule.php
  2. +10 −0 classes/tax/TaxRulesGroup.php
View
4 classes/tax/TaxRule.php
@@ -89,7 +89,9 @@ public static function getTaxRulesByGroupId($id_lang, $id_group)
t.`rate`,
g.`zipcode_from`, g.`zipcode_to`,
g.`description`,
- g.`behavior`
+ g.`behavior`,
+ g.`id_country`,
+ g.`id_state`
FROM `'._DB_PREFIX_.'tax_rule` g
LEFT JOIN `'._DB_PREFIX_.'country_lang` c ON (g.`id_country` = c.`id_country` AND `id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'state` s ON (g.`id_state` = s.`id_state`)
View
10 classes/tax/TaxRulesGroup.php
@@ -113,6 +113,16 @@ public static function getIdByName($name)
WHERE `name` = \''.pSQL($name).'\''
);
}
+
+ public function hasUniqueTaxRuleForCountry($id_country, $id_state)
+ {
+ $rules = TaxRule::getTaxRulesByGroupId((int)Context::getContext()->language->id, (int)$this->id);
+ foreach ($rules as $rule)
+ if ($rule['id_country'] == $id_country && $id_state == $rule['id_state'] && !$rule['behavior'])
+ return true;
+
+ return false;
+ }
/**
* @deprecated since 1.5
Please sign in to comment.
Something went wrong with that request. Please try again.