Merge pull request #506 from lovenunu/lovenunu-improvements
Add load requirements in getTypeInstance
This commit is contained in:
@@ -59,12 +59,14 @@ class Tax extends BaseTax
|
|||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new TaxEngineException('Recorded type `' . $class . '` does not exists', TaxEngineException::BAD_RECORDED_TYPE);
|
throw new TaxEngineException('Recorded type `' . $class . '` does not exists', TaxEngineException::BAD_RECORDED_TYPE);
|
||||||
}
|
}
|
||||||
|
/** @var \Thelia\TaxEngine\BaseTaxType $instance */
|
||||||
$instance = new $class;
|
$instance = new $class;
|
||||||
|
|
||||||
if (!$instance instanceof BaseTaxType) {
|
if (!$instance instanceof BaseTaxType) {
|
||||||
throw new TaxEngineException('Recorded type `' . $class . '` does not extends BaseTaxType', TaxEngineException::BAD_RECORDED_TYPE);
|
throw new TaxEngineException('Recorded type `' . $class . '` does not extends BaseTaxType', TaxEngineException::BAD_RECORDED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$instance->loadRequirements($this->getRequirements());
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ class Calculator
|
|||||||
$position = (int) $taxRule->getTaxRuleCountryPosition();
|
$position = (int) $taxRule->getTaxRuleCountryPosition();
|
||||||
|
|
||||||
$taxType = $taxRule->getTypeInstance();
|
$taxType = $taxRule->getTypeInstance();
|
||||||
$taxType->loadRequirements( $taxRule->getRequirements() );
|
|
||||||
|
|
||||||
if ($currentPosition !== $position) {
|
if ($currentPosition !== $position) {
|
||||||
$taxedPrice += $currentTax;
|
$taxedPrice += $currentTax;
|
||||||
@@ -209,7 +208,6 @@ class Calculator
|
|||||||
$position = (int) $taxRule->getTaxRuleCountryPosition();
|
$position = (int) $taxRule->getTaxRuleCountryPosition();
|
||||||
|
|
||||||
$taxType = $taxRule->getTypeInstance();
|
$taxType = $taxRule->getTypeInstance();
|
||||||
$taxType->loadRequirements( $taxRule->getRequirements() );
|
|
||||||
|
|
||||||
if ($currentPosition !== $position) {
|
if ($currentPosition !== $position) {
|
||||||
$untaxedPrice -= $currentFixTax;
|
$untaxedPrice -= $currentFixTax;
|
||||||
|
|||||||
Reference in New Issue
Block a user