[-] PDF : Bug Fixed #PSCFV-168 - Invoice discount & shipping are now correctly displayed
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15313 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -292,7 +292,7 @@ class OrderDetailCore extends ObjectModel
|
|||||||
* @since 1.5.0.1
|
* @since 1.5.0.1
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function saveTaxCalculator()
|
public function saveTaxCalculator(Order $order)
|
||||||
{
|
{
|
||||||
// Nothing to save
|
// Nothing to save
|
||||||
if ($this->tax_calculator == null)
|
if ($this->tax_calculator == null)
|
||||||
@@ -304,8 +304,12 @@ class OrderDetailCore extends ObjectModel
|
|||||||
if (count($this->tax_calculator->taxes) == 0)
|
if (count($this->tax_calculator->taxes) == 0)
|
||||||
return true;
|
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 = '';
|
$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);
|
$unit_amount = (float)Tools::ps_round($amount, 2);
|
||||||
$total_amount = $unit_amount * $this->product_quantity;
|
$total_amount = $unit_amount * $this->product_quantity;
|
||||||
@@ -531,7 +535,7 @@ class OrderDetailCore extends ObjectModel
|
|||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
if ($use_taxes)
|
if ($use_taxes)
|
||||||
$this->saveTaxCalculator();
|
$this->saveTaxCalculator($order);
|
||||||
unset($this->tax_calculator);
|
unset($this->tax_calculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ class OrderInvoiceCore extends ObjectModel
|
|||||||
if ($this->useOneAfterAnotherTaxComputationMethod())
|
if ($this->useOneAfterAnotherTaxComputationMethod())
|
||||||
{
|
{
|
||||||
// sum by taxes
|
// 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`
|
SELECT odt.`id_order_detail`, t.`name`, t.`rate`, SUM(`total_amount`) AS `total_amount`
|
||||||
FROM `'._DB_PREFIX_.'order_detail_tax` odt
|
FROM `'._DB_PREFIX_.'order_detail_tax` odt
|
||||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = odt.`id_tax`)
|
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
|
'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']]['total_amount'] += $tax_infos['total_amount'];
|
||||||
$tmp_tax_infos[$tax_infos['rate']]['name'] = $tax_infos['name'];
|
$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;
|
return $tmp_tax_infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user