/** * Save Tax Rule * * @param TaxRule $rule * @return TaxRuleModel * @throws InputException * @throws ModelException */ protected function saveTaxRule(TaxRule $rule) { $this->validate($rule); $taxRuleModel = $this->converter->createTaxRuleModel($rule); try { $taxRuleModel->save(); } catch (ModelException $e) { if ($e->getCode() == ModelException::ERROR_CODE_ENTITY_ALREADY_EXISTS) { throw new InputException($e->getMessage()); } else { throw $e; } } $this->taxRuleRegistry->registerTaxRule($taxRuleModel); return $taxRuleModel; }