[-] BO: FIX #PSCFV-5088 - cant add a tax rule to a group if one have already defined as unique

This commit is contained in:
rGaillard
2012-11-16 16:48:23 +00:00
parent 4aa0a69953
commit ee62ed8d27
2 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -89,7 +89,9 @@ class TaxRuleCore extends ObjectModel
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`)
+10
View File
@@ -113,6 +113,16 @@ class TaxRulesGroupCore extends ObjectModel
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