Skip to content
Permalink
Browse files

Fix tax rule collection query build

  • Loading branch information...
Franck Allimant authored and roadster31 committed Jul 2, 2019
1 parent f1e6c0f commit cbf1574ecf7b12958c4bc021741e43a7468f8a21
Showing with 10 additions and 8 deletions.
  1. +10 −8 core/lib/Thelia/Model/TaxRuleQuery.php
@@ -24,9 +24,10 @@ class TaxRuleQuery extends BaseTaxRuleQuery
/**
* @param TaxRule $taxRule
* @param Country $country
*
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
* @param Country|null $country
* @param State|null $state
* @return array|mixed|\Propel\Runtime\ActiveRecord\ActiveRecordInterface[]|\Propel\Runtime\Collection\ObjectCollection|Tax[]
* @throws \Propel\Runtime\Exception\PropelException
*/
public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country = null, State $state = null)
{
@@ -48,17 +49,18 @@ public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country =
$taxRuleQuery->filterByCountry($country, Criteria::EQUAL);
}
$synthetizedSateId = $state;
if (null !== $state) {
$taxRuleCount = clone $taxRuleQuery;
$taxRuleCount->filterByStateId($state->getId(), Criteria::EQUAL)
->count();
if (0 === $taxRuleCount) {
$taxRuleQuery->filterByStateId(null, Criteria::EQUAL);
if (0 === $taxRuleCount->filterByStateId($state->getId(), Criteria::EQUAL)->count()) {
$synthetizedSateId = null;
}
}
$taxRuleQuery->filterByStateId($synthetizedSateId, Criteria::EQUAL);
$search = TaxQuery::create()
->filterByTaxRuleCountry($taxRuleQuery->find())
->withColumn(TaxRuleCountryTableMap::COL_POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)

0 comments on commit cbf1574

Please sign in to comment.
You can’t perform that action at this time.