Merge pull request #506 from lovenunu/lovenunu-improvements

Add load requirements in getTypeInstance
This commit is contained in:
Manuel Raynaud
2014-06-28 11:59:14 +02:00
2 changed files with 3 additions and 3 deletions

View File

@@ -59,13 +59,15 @@ class Tax extends BaseTax
if (!class_exists($class)) {
throw new TaxEngineException('Recorded type `' . $class . '` does not exists', TaxEngineException::BAD_RECORDED_TYPE);
}
/** @var \Thelia\TaxEngine\BaseTaxType $instance */
$instance = new $class;
if (!$instance instanceof BaseTaxType) {
throw new TaxEngineException('Recorded type `' . $class . '` does not extends BaseTaxType', TaxEngineException::BAD_RECORDED_TYPE);
}
$instance->loadRequirements($this->getRequirements());
return $instance;
}

View File

@@ -154,7 +154,6 @@ class Calculator
$position = (int) $taxRule->getTaxRuleCountryPosition();
$taxType = $taxRule->getTypeInstance();
$taxType->loadRequirements( $taxRule->getRequirements() );
if ($currentPosition !== $position) {
$taxedPrice += $currentTax;
@@ -209,7 +208,6 @@ class Calculator
$position = (int) $taxRule->getTaxRuleCountryPosition();
$taxType = $taxRule->getTypeInstance();
$taxType->loadRequirements( $taxRule->getRequirements() );
if ($currentPosition !== $position) {
$untaxedPrice -= $currentFixTax;