tax in loops

This commit is contained in:
Etienne Roudeix
2013-09-09 16:27:46 +02:00
parent fa36b64f51
commit ca4df15910
9 changed files with 91 additions and 17 deletions

View File

@@ -28,6 +28,6 @@ class Product extends BaseProduct
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this, $country)->getTaxedPrice();
return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
}
}

View File

@@ -3,8 +3,41 @@
namespace Thelia\Model;
use Thelia\Model\Base\ProductSaleElements as BaseProductSaleElements;
use Thelia\TaxEngine\Calculator;
class ProductSaleElements extends BaseProductSaleElements
class ProductSaleElements extends BaseProductSaleElements
{
public function getPrice($virtualColumnName = 'price_PRICE')
{
try {
$amount = $this->getVirtualColumn($virtualColumnName);
} catch(PropelException $e) {
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPrice");
}
return $amount;
}
public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE')
{
try {
$amount = $this->getVirtualColumn($virtualColumnName);
} catch(PropelException $e) {
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPromoPrice");
}
return $amount;
}
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice());
}
public function getTaxedPromoPrice(Country $country)
{
$taxCalculator = new Calculator();
return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice());
}
}

View File

@@ -37,8 +37,6 @@ class TaxRuleQuery extends BaseTaxRuleQuery
->withColumn('ROUND(SUM(' . TaxTableMap::RATE . '), 2)', self::ALIAS_FOR_TAX_RATE_SUM)
;
//var_dump($search->toString());
return $search->find();
}
} // TaxRuleQuery