Merge pull request #1172 from vishal-singh-webkul/gli-2232
Fixed: Errors occurring while updating the order from back office.
This commit is contained in:
@@ -317,6 +317,8 @@ class OrderHistoryCore extends ObjectModel
|
||||
// if order is created by API then create a direct object instead of creating an object from module
|
||||
if ($order->module == 'wsorder') {
|
||||
$payment_method = new WebserviceOrder();
|
||||
} else if ($order->module == 'bo_order') {
|
||||
$payment_method = new BoOrder();
|
||||
} else {
|
||||
$payment_method = Module::getInstanceByName($order->module);
|
||||
}
|
||||
|
||||
@@ -397,6 +397,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
$type_value['id_order_detail']
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
@@ -408,6 +409,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
$type_value['id_order_detail']
|
||||
);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
|
||||
@@ -4656,8 +4656,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$res = true;
|
||||
$id_order = (int) Tools::getValue('id_order');
|
||||
$order = new Order($id_order);
|
||||
$cart = new Cart($order->id_cart);
|
||||
$customer = new Cart($order->id_customer);
|
||||
//$order_detail = new OrderDetail((int)Tools::getValue('product_id_order_detail'));
|
||||
$order_detail = new OrderDetail((int) Tools::getValue('id_order_detail'));//by webkul id_order_detail from our table
|
||||
$this->doEditRoomValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null);
|
||||
@@ -4666,6 +4664,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order_invoice = new OrderInvoice((int) Tools::getValue('product_invoice'));
|
||||
}
|
||||
/*By webkul To edit Order and cart entries when edit rooms from the orderLine when editing the order*/
|
||||
$obj_booking_detail = new HotelBookingDetail((int) Tools::getValue('id_booking_detail'));
|
||||
$cart = new Cart($obj_booking_detail->id_cart);
|
||||
|
||||
$product_informations = $_POST['edit_product'];
|
||||
$new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from'])));
|
||||
$new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to'])));
|
||||
@@ -4675,7 +4676,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$id_room = trim(Tools::getValue('id_room'));
|
||||
$id_product = trim(Tools::getValue('id_product'));
|
||||
$room_unit_price = trim(Tools::getValue('room_unit_price'));
|
||||
$obj_booking_detail = new HotelBookingDetail();
|
||||
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
@@ -4857,6 +4857,17 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$res &= $order_invoice->update();
|
||||
}
|
||||
|
||||
if ($qty_diff != 0) {
|
||||
$cartQty = $qty_diff;
|
||||
$op = 'up';
|
||||
if ($qty_diff < 0) {
|
||||
$op = 'down';
|
||||
$cartQty = -$cartQty;
|
||||
}
|
||||
|
||||
$cart->updateQty($cartQty, $obj_booking_detail->id_product, null, false, $op, 0, null, true);
|
||||
}
|
||||
|
||||
// Update product available quantity
|
||||
StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id, ($old_quantity - $order_detail->product_quantity), $order->id_shop);
|
||||
|
||||
@@ -4926,7 +4937,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$id_room,
|
||||
0,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
$obj_booking_detail->id
|
||||
);
|
||||
|
||||
$extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
@@ -4934,7 +4948,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
0,
|
||||
$id_room,
|
||||
$old_date_from,
|
||||
$old_date_to
|
||||
$old_date_to,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
$obj_booking_detail->id
|
||||
);
|
||||
|
||||
// set occupancy details
|
||||
@@ -4950,7 +4968,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'tax_incl' => $totalRoomPriceAfterTI,
|
||||
);
|
||||
|
||||
if ($update_htl_tables = $obj_booking_detail->UpdateHotelCartHotelOrderOnOrderEdit(
|
||||
if ($obj_booking_detail->updateHotelCartHotelOrderOnOrderEdit(
|
||||
$id_order,
|
||||
$id_room,
|
||||
$old_date_from,
|
||||
@@ -4958,7 +4976,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$new_date_from,
|
||||
$new_date_to,
|
||||
$occupancy,
|
||||
$new_total_price
|
||||
$new_total_price,
|
||||
$obj_booking_detail->id
|
||||
)) {
|
||||
// update extra demands total prices if dates are changes (price calc method for each day)
|
||||
if ($extraDemands) {
|
||||
@@ -5495,6 +5514,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
// delete refund request of the room if exists.
|
||||
OrderReturnDetail::deleteReturnDetailByIdBookingDetail($id_order, $idHotelBooking);
|
||||
|
||||
// Reducing the quantity from the cart after removing the room from the order
|
||||
$objCart = new Cart($objBookingDetail->id_cart);
|
||||
$objCart->updateQty($product_quantity, $objBookingDetail->id_product, null, false, 'down', 0, null, true);
|
||||
|
||||
// Assign to smarty informations in order to show the new product line
|
||||
$this->context->smarty->assign(array(
|
||||
'order' => $order,
|
||||
@@ -6238,7 +6261,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$oldTotalPriceTaxExcl = $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
|
||||
$oldTotalPriceTaxIncl = $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
|
||||
$oldQuantity = $objRoomTypeServiceProductOrderDetail->quantity;
|
||||
if ($oldPriceTaxExcl > 0) {
|
||||
if ($oldUnitPriceTaxExcl > 0) {
|
||||
$oldTaxMultiplier = $oldUnitPriceTaxIncl / $oldUnitPriceTaxExcl;
|
||||
} else {
|
||||
$oldTaxMultiplier = 1;
|
||||
@@ -6424,10 +6447,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
);
|
||||
|
||||
// add services in room
|
||||
$order = new Order($objHotelBookingDetail->id_order);
|
||||
if (!$response['hasError']) {
|
||||
$this->context->currency = new Currency($order->id_currency);
|
||||
foreach ($selectedServices as $service) {
|
||||
$order = new Order($objHotelBookingDetail->id_order);
|
||||
|
||||
// Create new cart
|
||||
$cart = new Cart();
|
||||
$cart->id_shop_group = $order->id_shop_group;
|
||||
@@ -6499,49 +6522,33 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$roomHtlCartInfo['id'])
|
||||
) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $id_room_type_service_product_cart_detail);
|
||||
$totalPriceChangeTaxExcl += $totalPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$objRoomTypeServiceProductCartDetail->quantity,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
false,
|
||||
$cart->id
|
||||
);
|
||||
$totalPriceChangeTaxIncl += $totalPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$objRoomTypeServiceProductCartDetail->quantity,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
true,
|
||||
$cart->id
|
||||
);
|
||||
|
||||
$numDays = 1;
|
||||
if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to);
|
||||
}
|
||||
$product['cart_quantity'] = $objRoomTypeServiceProductCartDetail->quantity * $numDays;
|
||||
|
||||
$product['cart_quantity'] = $objRoomTypeServiceProductCartDetail->quantity * $numDays;
|
||||
$unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$roomHtlCartInfo['id_product'],
|
||||
1,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
$cart->id
|
||||
)/ $numDays;
|
||||
);
|
||||
$unitPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
$roomHtlCartInfo['id_product'],
|
||||
1,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
$cart->id
|
||||
)/ $numDays;
|
||||
);
|
||||
|
||||
$totalPriceChangeTaxExcl += $totalPriceTaxExcl = ($unitPriceTaxExcl * $product['cart_quantity']);
|
||||
$totalPriceChangeTaxIncl += $totalPriceTaxIncl = ($unitPriceTaxIncl * $product['cart_quantity']);
|
||||
switch (Configuration::get('PS_ROUND_TYPE')) {
|
||||
case Order::ROUND_TOTAL:
|
||||
$product['total'] = $totalPriceTaxExcl;
|
||||
|
||||
@@ -75,8 +75,8 @@ class HotelBookingDemands extends ObjectModel
|
||||
$groupByRoom = 1,
|
||||
$getTotalPrice = 0,
|
||||
$useTax = 1,
|
||||
$idOrderDetail = 0,
|
||||
$idHtlBookingDetail = 0
|
||||
$idHtlBookingDetail = 0,
|
||||
$idOrderDetail = 0
|
||||
) {
|
||||
$moduleObj = Module::getInstanceByName('hotelreservationsystem');
|
||||
$context = Context::getContext();
|
||||
|
||||
@@ -2369,7 +2369,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public function UpdateHotelCartHotelOrderOnOrderEdit(
|
||||
public function updateHotelCartHotelOrderOnOrderEdit(
|
||||
$idOrder,
|
||||
$idRoom,
|
||||
$oldDateFrom,
|
||||
@@ -2377,11 +2377,10 @@ class HotelBookingDetail extends ObjectModel
|
||||
$newDateFrom,
|
||||
$newDateTo,
|
||||
$occupancy,
|
||||
$newTotalPrice = null
|
||||
$newTotalPrice = null,
|
||||
$idHotelBookingDetail
|
||||
) {
|
||||
// retrieve HotelBookingDetail row
|
||||
$roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $oldDateFrom, $oldDateTo);
|
||||
$objHotelBookingDetail = new self($roomBookingData['id']);
|
||||
$objHotelBookingDetail = new self((int) $idHotelBookingDetail);
|
||||
if (Validate::isLoadedObject($objHotelBookingDetail)) {
|
||||
// retrieve HotelCartBookingData row
|
||||
$idHotelCartBookingData = Db::getInstance()->getValue(
|
||||
|
||||
@@ -336,8 +336,10 @@ class HotelRoomTypeDemand extends ObjectModel
|
||||
$price = $objGlobalDemand->price;
|
||||
}
|
||||
}
|
||||
|
||||
$price = Tools::convertPrice($price, $idCurrency);
|
||||
}
|
||||
$price = Tools::convertPrice($price, $idCurrency);
|
||||
|
||||
// Tax calculation section
|
||||
$address->id_country = $idCountry;
|
||||
$address->id_state = $idState;
|
||||
|
||||
@@ -69,9 +69,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
$useTax = null,
|
||||
$autoAddToCart = 0,
|
||||
$priceAdditionType = null,
|
||||
$idOrderDetail = 0
|
||||
$idOrderDetail = 0,
|
||||
$idHtlBookingDetail = 0
|
||||
) {
|
||||
|
||||
if ($useTax === null) {
|
||||
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
|
||||
}
|
||||
@@ -111,6 +111,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
if ($idRoom) {
|
||||
$sql .= ' AND hbd.`id_room`='.(int) $idRoom;
|
||||
}
|
||||
if ($idHtlBookingDetail) {
|
||||
$sql .= ' AND hbd.`id` = '.(int)$idHtlBookingDetail;
|
||||
}
|
||||
$sql .= ' ORDER BY hbd.`id`';
|
||||
|
||||
if ($getTotalPrice) {
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
{$service['name']}
|
||||
</td>
|
||||
<td class="center">
|
||||
{if $service['product_tax_label']}{$service['product_tax_label']}{else}{l s='No tax' pdf='true'}{/if}
|
||||
{if isset($service['product_tax_label']) && $service['product_tax_label']}{$service['product_tax_label']}{else}{l s='No tax' pdf='true'}{/if}
|
||||
</td>
|
||||
<td class="center">
|
||||
{if $service['allow_multiple_quantity']}
|
||||
|
||||
Reference in New Issue
Block a user