[-] BO: Fix tax rule edition - unique tax rule can't be edited
This commit is contained in:
@@ -113,11 +113,11 @@ class TaxRulesGroupCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
public function hasUniqueTaxRuleForCountry($id_country, $id_state)
|
||||
public function hasUniqueTaxRuleForCountry($id_country, $id_state, $id_tax_rule = false)
|
||||
{
|
||||
$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'])
|
||||
if ($rule['id_country'] == $id_country && $id_state == $rule['id_state'] && !$rule['behavior'] && (int)$id_tax_rule != $rule['id_tax_rule'])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -404,7 +404,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
|
||||
{
|
||||
foreach ($this->selected_states as $id_state)
|
||||
{
|
||||
if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state))
|
||||
if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state, $id_rule))
|
||||
{
|
||||
$this->errors[] = Tools::displayError('A tax rule already exists for this country/state with tax only behavior');
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user