tax engine
This commit is contained in:
@@ -4,7 +4,8 @@ namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\Base\TaxRuleQuery as BaseTaxRuleQuery;
|
||||
|
||||
use Thelia\Model\Map\TaxRuleCountryTableMap;
|
||||
use Thelia\Model\Map\TaxTableMap;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'tax_rule' table.
|
||||
@@ -18,14 +19,26 @@ use Thelia\Model\Base\TaxRuleQuery as BaseTaxRuleQuery;
|
||||
*/
|
||||
class TaxRuleQuery extends BaseTaxRuleQuery
|
||||
{
|
||||
public function getTaxCalculatorCollection(Product $product, Country $country)
|
||||
{
|
||||
$search = TaxRuleCountryQuery::create()
|
||||
->filterByCountry($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($product->getTaxRuleId())
|
||||
->orderByPosition()
|
||||
->find();
|
||||
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
|
||||
const ALIAS_FOR_TAX_RATE_SUM = 'taxRateSum';
|
||||
|
||||
return $search;
|
||||
public function getTaxCalculatorGroupedCollection(Product $product, Country $country)
|
||||
{
|
||||
$search = TaxQuery::create()
|
||||
->filterByTaxRuleCountry(
|
||||
TaxRuleCountryQuery::create()
|
||||
->filterByCountry($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($product->getTaxRuleId())
|
||||
->groupByPosition()
|
||||
->orderByPosition()
|
||||
->find()
|
||||
)
|
||||
->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)
|
||||
->withColumn('ROUND(SUM(' . TaxTableMap::RATE . '), 2)', self::ALIAS_FOR_TAX_RATE_SUM)
|
||||
;
|
||||
|
||||
//var_dump($search->toString());
|
||||
|
||||
return $search->find();
|
||||
}
|
||||
} // TaxRuleQuery
|
||||
|
||||
Reference in New Issue
Block a user