Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -20,26 +20,48 @@ class TaxRuleQuery extends BaseTaxRuleQuery
{
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
protected static $caches = [];
/**
* @param TaxRule $taxRule
* @param Country $country
*
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
*/
public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country)
public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country, State $state = null)
{
$key = sprintf(
'%s-%s-%s',
$taxRule->getId(),
$country->getId(),
($state !== null) ? $state->getId() : 0
);
if (array_key_exists($key, self::$caches)) {
return self::$caches[$key];
}
$taxRuleQuery = TaxRuleCountryQuery::create()
->filterByCountry($country, Criteria::EQUAL)
->filterByTaxRuleId($taxRule->getId());
if (null !== $state) {
$taxRuleCount = $taxRuleQuery
->filterByStateId($state->getId(), Criteria::EQUAL)
->count();
if (0 === $taxRuleCount) {
$taxRuleQuery->filterByStateId(null, Criteria::EQUAL);
}
}
$search = TaxQuery::create()
->filterByTaxRuleCountry(
TaxRuleCountryQuery::create()
->filterByCountry($country, Criteria::EQUAL)
->filterByTaxRuleId($taxRule->getId())
->orderByPosition()
->find()
)
->filterByTaxRuleCountry($taxRuleQuery->find())
->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)
->orderBy(self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION, Criteria::ASC);
;
return $search->find();
return self::$caches[$key] = $search->find();
}
} // TaxRuleQuery
}
// TaxRuleQuery