// Fix #PSCFV-4543

This commit is contained in:
rGaillard
2012-10-03 14:05:21 +00:00
parent 42bc64bbe3
commit a3ca8c326d
2 changed files with 22 additions and 5 deletions
+15 -2
View File
@@ -318,7 +318,7 @@ class OrderDetailCore extends ObjectModel
* @since 1.5.0.1
* @return boolean
*/
public function saveTaxCalculator(Order $order)
public function saveTaxCalculator(Order $order, $replace = false)
{
// Nothing to save
if ($this->tax_calculator == null)
@@ -345,12 +345,25 @@ class OrderDetailCore extends ObjectModel
$values .= '('.(int)$this->id.','.(float)$id_tax.','.$unit_amount.','.(float)$total_amount.'),';
}
if ($replace)
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_detail_tax` WHERE id_order_detail='.(int)$this->id);
$values = rtrim($values, ',');
$sql = 'INSERT INTO `'._DB_PREFIX_.'order_detail_tax` (id_order_detail, id_tax, unit_amount, total_amount)
VALUES '.$values;
return Db::getInstance()->execute($sql);
}
public function updateTaxAmount($order)
{
$this->setContext((int)$this->id_shop);
$address = new Address((int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$tax_manager = TaxManagerFactory::getManager($address, (int)Product::getIdTaxRulesGroupByIdProduct((int)$this->product_id, $this->context));
$this->tax_calculator = $tax_manager->getTaxCalculator();
return $this->saveTaxCalculator($order, true);
}
/**
* Get a detailed order list of an id_order
+7 -3
View File
@@ -1821,10 +1821,10 @@ class AdminOrdersControllerCore extends AdminController
// Return value
$res = true;
$order = new Order(Tools::getValue('id_order'));
$order_detail = new OrderDetail(Tools::getValue('product_id_order_detail'));
$order = new Order((int)Tools::getValue('id_order'));
$order_detail = new OrderDetail((int)Tools::getValue('product_id_order_detail'));
if (Tools::isSubmit('product_invoice'))
$order_invoice = new OrderInvoice(Tools::getValue('product_invoice'));
$order_invoice = new OrderInvoice((int)Tools::getValue('product_invoice'));
// Check fields validity
$this->doEditProductValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null);
@@ -1908,6 +1908,10 @@ class AdminOrdersControllerCore extends AdminController
$old_quantity = $order_detail->product_quantity;
$order_detail->product_quantity = $product_quantity;
// update taxes
$res &= $order_detail->updateTaxAmount($order);
// Save order detail
$res &= $order_detail->update();
// Save order invoice