[-] FO : Bug Fixed #PSFV-315 - Incorrect products prices in order history
This commit is contained in:
1 parent
4c8b6583cf
commit
4758939b9a
4 files changed
+32
-119
No files matched your search
@@ -2531,8 +2531,6 @@ class ProductCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function convertPriceWithCurrency($params, &$smarty)
|
public static function convertPriceWithCurrency($params, &$smarty)
|
||||||
{
|
{
|
||||||
if (!isset($params['convert']))
|
|
||||||
$params['convert'] = true;
|
|
||||||
return Tools::displayPrice($params['price'], $params['currency'], false);
|
return Tools::displayPrice($params['price'], $params['currency'], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-46
@@ -471,63 +471,29 @@ class OrderCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Marked as deprecated but should not throw any "deprecated" message
|
||||||
* @deprecated 1.5.0.1
|
* This function is used in order to keep front office backward compatibility 14 -> 1.5
|
||||||
* @see OrderInvoice::setProductPrices
|
* (Order History)
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function setProductPrices(&$row)
|
public function setProductPrices(&$row)
|
||||||
{
|
{
|
||||||
//Tools::displayAsDeprecated();
|
|
||||||
$tax_calculator = OrderDetail::getTaxCalculatorStatic((int)$row['id_order_detail']);
|
$tax_calculator = OrderDetail::getTaxCalculatorStatic((int)$row['id_order_detail']);
|
||||||
$row['tax_calculator'] = $tax_calculator;
|
$row['tax_calculator'] = $tax_calculator;
|
||||||
$row['tax_rate'] = $tax_calculator->getTotalRate();
|
$row['tax_rate'] = $tax_calculator->getTotalRate();
|
||||||
|
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
$row['product_price'] = Tools::ps_round($row['unit_price_tax_excl'], 2);
|
||||||
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
$row['product_price_wt'] = Tools::ps_round($row['unit_price_tax_incl'], 2);
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['product_price']), 2);
|
|
||||||
|
|
||||||
$group_reduction = 1;
|
$group_reduction = 1;
|
||||||
if ($row['group_reduction'] > 0)
|
if ($row['group_reduction'] > 0)
|
||||||
$group_reduction = 1 - $row['group_reduction'] / 100;
|
$group_reduction = 1 - $row['group_reduction'] / 100;
|
||||||
|
|
||||||
if ($row['reduction_percent'] != 0)
|
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'] - $row['ecotax'];
|
||||||
{
|
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = ($row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01));
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01)), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['reduction_amount'] != 0)
|
$row['total_wt'] = $row['total_price_tax_incl'];
|
||||||
{
|
$row['total_price'] = $row['total_price_tax_excl'];
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = ($row['product_price'] - ($tax_calculator->removeTaxes($row['reduction_amount'])));
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['reduction_amount']), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['group_reduction'] > 0)
|
|
||||||
{
|
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = $row['product_price'] * $group_reduction;
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] * $group_reduction , 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($row['reduction_percent'] OR $row['reduction_amount'] OR $row['group_reduction']) AND $this->_taxCalculationMethod == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
|
||||||
|
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['product_price']), 2) + Tools::ps_round($row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100), 2);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'];
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] + $row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
$row['total_wt'] = $row['product_quantity'] * $row['product_price_wt'];
|
|
||||||
$row['total_price'] = $row['product_quantity'] * $row['product_price'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -552,14 +518,17 @@ class OrderCore extends ObjectModel
|
|||||||
$row['product_quantity'] = 0;
|
$row['product_quantity'] = 0;
|
||||||
foreach ($selectedProducts AS $key => $id_product)
|
foreach ($selectedProducts AS $key => $id_product)
|
||||||
if ($row['id_order_detail'] == $id_product)
|
if ($row['id_order_detail'] == $id_product)
|
||||||
$row['product_quantity'] = (int)($selectedQty[$key]);
|
$row['producsvt_quantity'] = (int)($selectedQty[$key]);
|
||||||
if (!$row['product_quantity'])
|
if (!$row['product_quantity'])
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setProductImageInformations($row);
|
$this->setProductImageInformations($row);
|
||||||
$this->setProductCurrentStock($row);
|
$this->setProductCurrentStock($row);
|
||||||
$this->setProductPrices($row);
|
|
||||||
|
// Backward compatibility 1.4 -> 1.5
|
||||||
|
$this->setProductPrices($row);
|
||||||
|
|
||||||
$this->setProductCustomizedDatas($row, $customized_datas);
|
$this->setProductCustomizedDatas($row, $customized_datas);
|
||||||
|
|
||||||
// Add information for virtual product
|
// Add information for virtual product
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ class OrderInvoiceCore extends ObjectModel
|
|||||||
|
|
||||||
$this->setProductImageInformations($row);
|
$this->setProductImageInformations($row);
|
||||||
$this->setProductCurrentStock($row);
|
$this->setProductCurrentStock($row);
|
||||||
$this->setProductPrices($row, $order);
|
|
||||||
$this->setProductCustomizedDatas($row, $customized_datas);
|
$this->setProductCustomizedDatas($row, $customized_datas);
|
||||||
|
|
||||||
// Add information for virtual product
|
// Add information for virtual product
|
||||||
@@ -218,60 +217,6 @@ class OrderInvoiceCore extends ObjectModel
|
|||||||
$product['image'] = new Image($id_image);
|
$product['image'] = new Image($id_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setProductPrices(&$row, $order)
|
|
||||||
{
|
|
||||||
$tax_calculator = OrderDetail::getTaxCalculatorStatic((int)$row['id_order_detail']);
|
|
||||||
$row['tax_calculator'] = $tax_calculator;
|
|
||||||
$row['tax_rate'] = $tax_calculator->getTotalRate();
|
|
||||||
|
|
||||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['product_price']), 2);
|
|
||||||
|
|
||||||
$group_reduction = 1;
|
|
||||||
if ($row['group_reduction'] > 0)
|
|
||||||
$group_reduction = 1 - $row['group_reduction'] / 100;
|
|
||||||
|
|
||||||
if ($row['reduction_percent'] != 0)
|
|
||||||
{
|
|
||||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = ($row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01));
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01)), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['reduction_amount'] != 0)
|
|
||||||
{
|
|
||||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = ($row['product_price'] - ($tax_calculator->removeTaxes($row['reduction_amount'])));
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round(($row['product_price_wt'] - $row['reduction_amount']), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['group_reduction'] > 0)
|
|
||||||
{
|
|
||||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = $row['product_price'] * $group_reduction;
|
|
||||||
else
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] * $group_reduction , 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($row['reduction_percent'] OR $row['reduction_amount'] OR $row['group_reduction']) AND $order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
|
||||||
|
|
||||||
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['product_price']), 2) + Tools::ps_round($row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100), 2);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'];
|
|
||||||
$row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] + $row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
$row['total_wt'] = $row['product_quantity'] * $row['product_price_wt'];
|
|
||||||
$row['total_price'] = $row['product_quantity'] * $row['product_price'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns true if at least one order details uses the
|
* This method returns true if at least one order details uses the
|
||||||
* One After Another tax computation method.
|
* One After Another tax computation method.
|
||||||
|
|||||||
@@ -151,13 +151,13 @@
|
|||||||
{if $priceDisplay && $use_tax}
|
{if $priceDisplay && $use_tax}
|
||||||
<tr class="item">
|
<tr class="item">
|
||||||
<td colspan="{if $return_allowed}6{else}5{/if}">
|
<td colspan="{if $return_allowed}6{else}5{/if}">
|
||||||
{l s='Total products (tax excl.):'} <span class="price">{displayWtPriceWithCurrency price=$order->getTotalProductsWithoutTaxes() currency=$currency convert=0}</span>
|
{l s='Total products (tax excl.):'} <span class="price">{displayWtPriceWithCurrency price=$order->getTotalProductsWithoutTaxes() currency=$currency}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
<tr class="item">
|
<tr class="item">
|
||||||
<td colspan="{if $return_allowed}6{else}5{/if}">
|
<td colspan="{if $return_allowed}6{else}5{/if}">
|
||||||
{l s='Total products'} {if $use_tax}{l s='(tax incl.)'}{/if}: <span class="price">{displayWtPriceWithCurrency price=$order->getTotalProductsWithTaxes() currency=$currency convert=0}</span>
|
{l s='Total products'} {if $use_tax}{l s='(tax incl.)'}{/if}: <span class="price">{displayWtPriceWithCurrency price=$order->getTotalProductsWithTaxes() currency=$currency}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{if $order->total_discounts > 0}
|
{if $order->total_discounts > 0}
|
||||||
@@ -170,22 +170,23 @@
|
|||||||
{if $order->total_wrapping > 0}
|
{if $order->total_wrapping > 0}
|
||||||
<tr class="item">
|
<tr class="item">
|
||||||
<td colspan="{if $return_allowed}6{else}5{/if}">
|
<td colspan="{if $return_allowed}6{else}5{/if}">
|
||||||
{l s='Total gift-wrapping:'} <span class="price-wrapping">{displayWtPriceWithCurrency price=$order->total_wrapping currency=$currency convert=0}</span>
|
{l s='Total gift-wrapping:'} <span class="price-wrapping">{displayWtPriceWithCurrency price=$order->total_wrapping currency=$currency}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
<tr class="item">
|
<tr class="item">
|
||||||
<td colspan="{if $return_allowed}6{else}5{/if}">
|
<td colspan="{if $return_allowed}6{else}5{/if}">
|
||||||
{l s='Total shipping'} {if $use_tax}{l s='(tax incl.)'}{/if}: <span class="price-shipping">{displayWtPriceWithCurrency price=$order->total_shipping currency=$currency convert=0}</span>
|
{l s='Total shipping'} {if $use_tax}{l s='(tax incl.)'}{/if}: <span class="price-shipping">{displayWtPriceWithCurrency price=$order->total_shipping currency=$currency}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="totalprice item">
|
<tr class="totalprice item">
|
||||||
<td colspan="{if $return_allowed}6{else}5{/if}">
|
<td colspan="{if $return_allowed}6{else}5{/if}">
|
||||||
{l s='Total:'} <span class="price">{displayWtPriceWithCurrency price=$order->total_paid currency=$currency convert=0}</span>
|
{l s='Total:'} <span class="price">{displayWtPriceWithCurrency price=$order->total_paid currency=$currency}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
GROUP={$group_use_tax}
|
||||||
{foreach from=$products item=product name=products}
|
{foreach from=$products item=product name=products}
|
||||||
{if !isset($product.deleted)}
|
{if !isset($product.deleted)}
|
||||||
{assign var='productId' value=$product.product_id}
|
{assign var='productId' value=$product.product_id}
|
||||||
@@ -207,9 +208,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<label for="cb_{$product.id_order_detail|intval}">
|
<label for="cb_{$product.id_order_detail|intval}">
|
||||||
{if $group_use_tax}
|
{if $group_use_tax}
|
||||||
{convertPriceWithCurrency price=$product.product_price_wt currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency}
|
||||||
{else}
|
{else}
|
||||||
{convertPriceWithCurrency price=$product.product_price currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency}
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
@@ -217,15 +218,15 @@
|
|||||||
<label for="cb_{$product.id_order_detail|intval}">
|
<label for="cb_{$product.id_order_detail|intval}">
|
||||||
{if isset($customizedDatas.$productId.$productAttributeId)}
|
{if isset($customizedDatas.$productId.$productAttributeId)}
|
||||||
{if $group_use_tax}
|
{if $group_use_tax}
|
||||||
{convertPriceWithCurrency price=$product.total_customization_wt currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_customization_wt currency=$currency}
|
||||||
{else}
|
{else}
|
||||||
{convertPriceWithCurrency price=$product.total_customization currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_customization currency=$currency}
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
{if $group_use_tax}
|
{if $group_use_tax}
|
||||||
{convertPriceWithCurrency price=$product.total_wt currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_price_tax_incl currency=$currency}
|
||||||
{else}
|
{else}
|
||||||
{convertPriceWithCurrency price=$product.total_price currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_price_tax_excl currency=$currency}
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
@@ -288,18 +289,18 @@
|
|||||||
<td>
|
<td>
|
||||||
<label for="cb_{$product.id_order_detail|intval}">
|
<label for="cb_{$product.id_order_detail|intval}">
|
||||||
{if $group_use_tax}
|
{if $group_use_tax}
|
||||||
{convertPriceWithCurrency price=$product.product_price_wt currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency}
|
||||||
{else}
|
{else}
|
||||||
{convertPriceWithCurrency price=$product.product_price currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency}
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label for="cb_{$product.id_order_detail|intval}">
|
<label for="cb_{$product.id_order_detail|intval}">
|
||||||
{if $group_use_tax}
|
{if $group_use_tax}
|
||||||
{convertPriceWithCurrency price=$product.total_wt currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_price_tax_incl currency=$currency}
|
||||||
{else}
|
{else}
|
||||||
{convertPriceWithCurrency price=$product.total_price currency=$currency convert=0}
|
{convertPriceWithCurrency price=$product.total_price_tax_excl currency=$currency}
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
@@ -313,7 +314,7 @@
|
|||||||
<td>{l s='Voucher:'} {$discount.name|escape:'htmlall':'UTF-8'}</td>
|
<td>{l s='Voucher:'} {$discount.name|escape:'htmlall':'UTF-8'}</td>
|
||||||
<td><span class="order_qte_span editable">1</span></td>
|
<td><span class="order_qte_span editable">1</span></td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td>{if $discount.value != 0.00}{l s='-'}{/if}{convertPriceWithCurrency price=$discount.value currency=$currency convert=0}</td>
|
<td>{if $discount.value != 0.00}{l s='-'}{/if}{convertPriceWithCurrency price=$discount.value currency=$currency}</td>
|
||||||
{if $return_allowed}
|
{if $return_allowed}
|
||||||
<td> </td>
|
<td> </td>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in new issue
Block a user