change the way product is created
This commit is contained in:
@@ -100,6 +100,27 @@ class Calculator
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadTaxRuleWithoutProduct(TaxRule $taxRule, Country $country)
|
||||
{
|
||||
$this->product = null;
|
||||
$this->country = null;
|
||||
$this->taxRulesCollection = null;
|
||||
|
||||
if ($taxRule->getId() === null) {
|
||||
throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
|
||||
}
|
||||
if ($country->getId() === null) {
|
||||
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
|
||||
}
|
||||
|
||||
$this->country = $country;
|
||||
$this->product = new Product();
|
||||
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null)
|
||||
{
|
||||
return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice;
|
||||
|
||||
@@ -47,6 +47,7 @@ class FeatureFixAmountTaxType extends BaseTaxType
|
||||
|
||||
public function fixAmountRetriever(Product $product)
|
||||
{
|
||||
$taxAmount = 0;
|
||||
$featureId = $this->getRequirement("feature");
|
||||
|
||||
$query = FeatureProductQuery::create()
|
||||
@@ -54,14 +55,17 @@ class FeatureFixAmountTaxType extends BaseTaxType
|
||||
->filterByFeatureId($featureId)
|
||||
->findOne();
|
||||
|
||||
$taxAmount = $query->getFreeTextValue();
|
||||
if (null !== $query) {
|
||||
$taxAmount = $query->getFreeTextValue();
|
||||
|
||||
$testInt = new FloatType();
|
||||
if (!$testInt->isValid($taxAmount)) {
|
||||
throw new TaxEngineException(
|
||||
$testInt = new FloatType();
|
||||
if (!$testInt->isValid($taxAmount)) {
|
||||
throw new TaxEngineException(
|
||||
Translator::getInstance()->trans('Feature value does not match FLOAT format'),
|
||||
TaxEngineException::FEATURE_BAD_EXPECTED_VALUE
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $taxAmount;
|
||||
|
||||
Reference in New Issue
Block a user