[-] BO: FIX #PSCFV-5088 - cant add a tax rule to a group if one have already defined as unique
This commit is contained in:
@@ -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`)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user