[-] PDF : Bug Fixed #PSCFV-168 - Invoice discount & shipping are now correctly displayed

This commit is contained in:
fBrignoli
2012-05-15 14:22:22 +00:00
parent b7e56dcb82
commit 9b15e074da
2 changed files with 14 additions and 5 deletions
+7 -3
View File
@@ -292,7 +292,7 @@ class OrderDetailCore extends ObjectModel
* @since 1.5.0.1
* @return boolean
*/
public function saveTaxCalculator()
public function saveTaxCalculator(Order $order)
{
// Nothing to save
if ($this->tax_calculator == null)
@@ -304,8 +304,12 @@ class OrderDetailCore extends ObjectModel
if (count($this->tax_calculator->taxes) == 0)
return true;
$ratio = $this->unit_price_tax_excl / $order->total_products;
$order_reduction_amount = $order->total_discounts_tax_excl * $ratio;
$discounted_price_tax_excl = $this->unit_price_tax_excl - $order_reduction_amount;
$values = '';
foreach ($this->tax_calculator->getTaxesAmount($this->unit_price_tax_excl) as $id_tax => $amount)
foreach ($this->tax_calculator->getTaxesAmount($discounted_price_tax_excl) as $id_tax => $amount)
{
$unit_amount = (float)Tools::ps_round($amount, 2);
$total_amount = $unit_amount * $this->product_quantity;
@@ -531,7 +535,7 @@ class OrderDetailCore extends ObjectModel
$this->save();
if ($use_taxes)
$this->saveTaxCalculator();
$this->saveTaxCalculator($order);
unset($this->tax_calculator);
}
+7 -2
View File
@@ -250,7 +250,7 @@ class OrderInvoiceCore extends ObjectModel
if ($this->useOneAfterAnotherTaxComputationMethod())
{
// sum by taxes
$taxes_by_tax = Db::getInstance()->executeS('
$taxes_infos = Db::getInstance()->executeS('
SELECT odt.`id_order_detail`, t.`name`, t.`rate`, SUM(`total_amount`) AS `total_amount`
FROM `'._DB_PREFIX_.'order_detail_tax` odt
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = odt.`id_tax`)
@@ -292,12 +292,17 @@ class OrderInvoiceCore extends ObjectModel
'total_price_tax_excl' => 0
);
$ratio = $tax_infos['total_price_tax_excl'] / $this->total_products;
$order_reduction_amount = $this->total_discount_tax_excl * $ratio;
$tmp_tax_infos[$tax_infos['rate']]['total_amount'] += $tax_infos['total_amount'];
$tmp_tax_infos[$tax_infos['rate']]['name'] = $tax_infos['name'];
$tmp_tax_infos[$tax_infos['rate']]['total_price_tax_excl'] += $tax_infos['total_price_tax_excl'];
$tmp_tax_infos[$tax_infos['rate']]['total_price_tax_excl'] += ($tax_infos['total_price_tax_excl'] - $order_reduction_amount);
}
}
return $tmp_tax_infos;
}