[-] FO : Notice undefined tax_rate
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9301 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+24
-16
@@ -32,11 +32,11 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
/** @var integer Invoice address id */
|
/** @var integer Invoice address id */
|
||||||
public $id_address_invoice;
|
public $id_address_invoice;
|
||||||
|
|
||||||
public $id_group_shop;
|
public $id_group_shop;
|
||||||
|
|
||||||
public $id_shop;
|
public $id_shop;
|
||||||
|
|
||||||
/** @var integer Cart id */
|
/** @var integer Cart id */
|
||||||
public $id_cart;
|
public $id_cart;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ class OrderCore extends ObjectModel
|
|||||||
'date_upd' => array(),
|
'date_upd' => array(),
|
||||||
),
|
),
|
||||||
'associations' => array(
|
'associations' => array(
|
||||||
'order_rows' => array('resource' => 'order_row', 'setter' => false, 'virtual_entity' => true,
|
'order_rows' => array('resource' => 'order_row', 'setter' => false, 'virtual_entity' => true,
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'id' => array(),
|
'id' => array(),
|
||||||
'product_id' => array('required' => true),
|
'product_id' => array('required' => true),
|
||||||
@@ -276,7 +276,7 @@ class OrderCore extends ObjectModel
|
|||||||
protected function _deleteProduct($orderDetail, $quantity)
|
protected function _deleteProduct($orderDetail, $quantity)
|
||||||
{
|
{
|
||||||
$tax_calculator = $orderDetail->getTaxCalculator();
|
$tax_calculator = $orderDetail->getTaxCalculator();
|
||||||
|
|
||||||
$price = $tax_calculator->addTaxes($orderDetail->product_price);
|
$price = $tax_calculator->addTaxes($orderDetail->product_price);
|
||||||
if ($orderDetail->reduction_percent != 0.00)
|
if ($orderDetail->reduction_percent != 0.00)
|
||||||
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
|
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
|
||||||
@@ -295,14 +295,14 @@ class OrderCore extends ObjectModel
|
|||||||
/* Update order */
|
/* Update order */
|
||||||
$shippingDiff = $this->total_shipping - $cart->getOrderShippingCost();
|
$shippingDiff = $this->total_shipping - $cart->getOrderShippingCost();
|
||||||
$this->total_products -= $productPriceWithoutTax;
|
$this->total_products -= $productPriceWithoutTax;
|
||||||
|
|
||||||
// After upgrading from old version
|
// After upgrading from old version
|
||||||
// total_products_wt is null
|
// total_products_wt is null
|
||||||
// removing a product made order total negative
|
// removing a product made order total negative
|
||||||
// and don't recalculating totals (on getTotalProductsWithTaxes)
|
// and don't recalculating totals (on getTotalProductsWithTaxes)
|
||||||
if ($this->total_products_wt != 0)
|
if ($this->total_products_wt != 0)
|
||||||
$this->total_products_wt -= $productPrice;
|
$this->total_products_wt -= $productPrice;
|
||||||
|
|
||||||
$this->total_shipping = $cart->getOrderShippingCost();
|
$this->total_shipping = $cart->getOrderShippingCost();
|
||||||
|
|
||||||
/* It's temporary fix for 1.3 version... */
|
/* It's temporary fix for 1.3 version... */
|
||||||
@@ -415,10 +415,10 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
public function setProductPrices(&$row)
|
public function setProductPrices(&$row)
|
||||||
{
|
{
|
||||||
$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)
|
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
||||||
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
$row['product_price'] = Tools::ps_round($row['product_price'], 2);
|
||||||
else
|
else
|
||||||
@@ -447,9 +447,9 @@ class OrderCore extends ObjectModel
|
|||||||
if ($row['group_reduction'] > 0)
|
if ($row['group_reduction'] > 0)
|
||||||
{
|
{
|
||||||
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
if ($this->_taxCalculationMethod == PS_TAX_EXC)
|
||||||
$row['product_price'] = $row['product_price'] * $group_reduction;
|
$row['product_price'] = $row['product_price'] * $group_reduction;
|
||||||
else
|
else
|
||||||
$row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] * $group_reduction , 2);
|
$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)
|
if (($row['reduction_percent'] OR $row['reduction_amount'] OR $row['group_reduction']) AND $this->_taxCalculationMethod == PS_TAX_EXC)
|
||||||
@@ -477,7 +477,7 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$products)
|
if (!$products)
|
||||||
$products = $this->getProductsDetail();
|
$products = $this->getProductsDetail();
|
||||||
|
|
||||||
$resultArray = array();
|
$resultArray = array();
|
||||||
foreach ($products AS $row)
|
foreach ($products AS $row)
|
||||||
{
|
{
|
||||||
@@ -491,7 +491,7 @@ class OrderCore extends ObjectModel
|
|||||||
if (!$row['product_quantity'])
|
if (!$row['product_quantity'])
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setProductPrices($row);
|
$this->setProductPrices($row);
|
||||||
|
|
||||||
/* Add information for virtual product */
|
/* Add information for virtual product */
|
||||||
@@ -511,7 +511,7 @@ class OrderCore extends ObjectModel
|
|||||||
/* Stock product */
|
/* Stock product */
|
||||||
$resultArray[(int)$row['id_order_detail']] = $row;
|
$resultArray[(int)$row['id_order_detail']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $resultArray;
|
return $resultArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +537,7 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if order contains (only) virtual products
|
* Check if order contains (only) virtual products
|
||||||
*
|
*
|
||||||
* @param boolean $strict If false return true if there are at least one product virtual
|
* @param boolean $strict If false return true if there are at least one product virtual
|
||||||
* @return boolean true if is a virtual order or false
|
* @return boolean true if is a virtual order or false
|
||||||
*
|
*
|
||||||
@@ -646,7 +646,7 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT o.*, (SELECT SUM(od.`product_quantity`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = o.`id_order`) nb_products
|
SELECT o.*, (SELECT SUM(od.`product_quantity`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = o.`id_order`) nb_products
|
||||||
FROM `'._DB_PREFIX_.'orders` o
|
FROM `'._DB_PREFIX_.'orders` o
|
||||||
@@ -666,8 +666,10 @@ class OrderCore extends ObjectModel
|
|||||||
WHERE oh.`id_order` = '.(int)($val['id_order']).(!$showHiddenStatus ? ' AND os.`hidden` != 1' : '').'
|
WHERE oh.`id_order` = '.(int)($val['id_order']).(!$showHiddenStatus ? ' AND os.`hidden` != 1' : '').'
|
||||||
ORDER BY oh.`date_add` DESC, oh.`id_order_history` DESC
|
ORDER BY oh.`date_add` DESC, oh.`id_order_history` DESC
|
||||||
LIMIT 1');
|
LIMIT 1');
|
||||||
|
|
||||||
if ($res2)
|
if ($res2)
|
||||||
$res[$key] = array_merge($res[$key], $res2[0]);
|
$res[$key] = array_merge($res[$key], $res2[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -769,12 +771,18 @@ class OrderCore extends ObjectModel
|
|||||||
if ($this->total_products_wt != '0.00' AND !$products)
|
if ($this->total_products_wt != '0.00' AND !$products)
|
||||||
return $this->total_products_wt;
|
return $this->total_products_wt;
|
||||||
/* Retro-compatibility (now set directly on the validateOrder() method) */
|
/* Retro-compatibility (now set directly on the validateOrder() method) */
|
||||||
|
|
||||||
|
|
||||||
if (!$products)
|
if (!$products)
|
||||||
$products = $this->getProductsDetail();
|
$products = $this->getProductsDetail();
|
||||||
|
|
||||||
$return = 0;
|
$return = 0;
|
||||||
|
|
||||||
foreach ($products AS $row)
|
foreach ($products AS $row)
|
||||||
{
|
{
|
||||||
|
if (!isset($row['tax_rate']))
|
||||||
|
$row['tax_rate'] = 0;
|
||||||
|
|
||||||
$price = Tools::ps_round($row['product_price'] * (1 + $row['tax_rate'] / 100), 2);
|
$price = Tools::ps_round($row['product_price'] * (1 + $row['tax_rate'] / 100), 2);
|
||||||
if ($row['reduction_percent'])
|
if ($row['reduction_percent'])
|
||||||
$price -= $price * ($row['reduction_percent'] * 0.01);
|
$price -= $price * ($row['reduction_percent'] * 0.01);
|
||||||
|
|||||||
Reference in New Issue
Block a user