// Fix #PSCFV-4543
This commit is contained in:
1 parent
6c4d6e4901
commit
f434e29792
2 files changed
+21
-4
No files matched your search
@@ -318,7 +318,7 @@ class OrderDetailCore extends ObjectModel
|
|||||||
* @since 1.5.0.1
|
* @since 1.5.0.1
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function saveTaxCalculator(Order $order)
|
public function saveTaxCalculator(Order $order, $replace = false)
|
||||||
{
|
{
|
||||||
// Nothing to save
|
// Nothing to save
|
||||||
if ($this->tax_calculator == null)
|
if ($this->tax_calculator == null)
|
||||||
@@ -345,6 +345,9 @@ class OrderDetailCore extends ObjectModel
|
|||||||
$values .= '('.(int)$this->id.','.(float)$id_tax.','.$unit_amount.','.(float)$total_amount.'),';
|
$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, ',');
|
$values = rtrim($values, ',');
|
||||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'order_detail_tax` (id_order_detail, id_tax, unit_amount, total_amount)
|
$sql = 'INSERT INTO `'._DB_PREFIX_.'order_detail_tax` (id_order_detail, id_tax, unit_amount, total_amount)
|
||||||
VALUES '.$values;
|
VALUES '.$values;
|
||||||
@@ -352,6 +355,16 @@ class OrderDetailCore extends ObjectModel
|
|||||||
return Db::getInstance()->execute($sql);
|
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
|
* Get a detailed order list of an id_order
|
||||||
* @param int $id_order
|
* @param int $id_order
|
||||||
|
|||||||
@@ -1821,10 +1821,10 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Return value
|
// Return value
|
||||||
$res = true;
|
$res = true;
|
||||||
|
|
||||||
$order = new Order(Tools::getValue('id_order'));
|
$order = new Order((int)Tools::getValue('id_order'));
|
||||||
$order_detail = new OrderDetail(Tools::getValue('product_id_order_detail'));
|
$order_detail = new OrderDetail((int)Tools::getValue('product_id_order_detail'));
|
||||||
if (Tools::isSubmit('product_invoice'))
|
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
|
// Check fields validity
|
||||||
$this->doEditProductValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null);
|
$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;
|
$old_quantity = $order_detail->product_quantity;
|
||||||
|
|
||||||
$order_detail->product_quantity = $product_quantity;
|
$order_detail->product_quantity = $product_quantity;
|
||||||
|
|
||||||
|
// update taxes
|
||||||
|
$res &= $order_detail->updateTaxAmount($order);
|
||||||
|
|
||||||
// Save order detail
|
// Save order detail
|
||||||
$res &= $order_detail->update();
|
$res &= $order_detail->update();
|
||||||
// Save order invoice
|
// Save order invoice
|
||||||
|
|||||||
Reference in new issue
Block a user