diff --git a/admin/themes/default/template/controllers/orders/_product_line.tpl b/admin/themes/default/template/controllers/orders/_product_line.tpl
index 6f002813f..2223946c2 100644
--- a/admin/themes/default/template/controllers/orders/_product_line.tpl
+++ b/admin/themes/default/template/controllers/orders/_product_line.tpl
@@ -235,10 +235,10 @@
{/if}
{if isset($isCancelledRoom) && $isCancelledRoom}
|
{$data['room_num']}
diff --git a/classes/order/Order.php b/classes/order/Order.php
index eefa3bfe7..73d0a801e 100644
--- a/classes/order/Order.php
+++ b/classes/order/Order.php
@@ -1781,7 +1781,7 @@ class OrderCore extends ObjectModel
// We put autodate parameter of add method to true if date_add field is null
if ($res = $order_payment->add(is_null($order_payment->date_add))) {
if ($update_payment_detail) {
- $res &= $this->addOrderPaymentDetail($order_payment, $amount_paid, $order_invoice);
+ $res = $res && $this->addOrderPaymentDetail($order_payment, $amount_paid, $order_invoice);
}
}
@@ -2605,58 +2605,4 @@ class OrderCore extends ObjectModel
'SELECT `id` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_order` = '.(int)$this->id.' ORDER BY `id` ASC'
);
}
-
- // Recalculate order split amount for booking room, service product and additional features
- public function recalculateOrderSplitAmount()
- {
- if ($this->id && $this->total_paid_real) {
- $objHotelBookingDetail = new HotelBookingDetail();
- $objHotelBookingDemands = new HotelBookingDemands();
- $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
-
- // recalculate booking room split amount
- $bookingInfo = $objHotelBookingDetail->getBookingDataByOrderId($this->id);
- foreach ($bookingInfo as $info) {
- $roomSplitAmountPercent = ($info['total_price_tax_incl']*100)/$this->total_paid_tax_incl;
- $roomSplitAmount = ($this->total_paid_real*$roomSplitAmountPercent)/100;
- $objHotelBookingDetail = new HotelBookingDetail($info['id']);
- $objHotelBookingDetail->total_paid_amount = Tools::math_round($roomSplitAmount, 6);
- $objHotelBookingDetail->save();
-
- // recalculate booking demand split amount
- $roomSelectedDemands = $objHotelBookingDemands->getSelectedRoomDemandPaidAmount(
- $objHotelBookingDetail->id
- );
- if (count($roomSelectedDemands)) {
- foreach ($roomSelectedDemands as $demand) {
- $roomDemandSplitAmountPercent = ($demand['total_price_tax_incl']*100)/$this->total_paid_tax_incl;
- $roomDemandSplitAmount = ($this->total_paid_real*$roomDemandSplitAmountPercent)/100;
- $objHotelBookingDemands = new HotelBookingDemands($demand['id_booking_demand']);
- $objHotelBookingDemands->total_paid_amount = Tools::math_round($roomDemandSplitAmount, 6);
- $objHotelBookingDemands->save();
- }
- }
-
- // recalculate booking service product split amount
- $roomSelectedServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
- $objHotelBookingDetail->id
- );
- foreach ($roomSelectedServices['additional_services'] as $serviceProduct) {
- if (isset($serviceProduct['id_room_type_service_product_order_detail'])
- && isset($serviceProduct['id_room_type_service_product_order_detail'])
- ) {
- $roomServiceProductPercent = ($serviceProduct['total_price_tax_incl']*100)/$this->total_paid_tax_incl;
- $roomServiceProductAmount = ($this->total_paid_real*$roomServiceProductPercent)/100;
- $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(
- $serviceProduct['id_room_type_service_product_order_detail']
- );
- $objRoomTypeServiceProductOrderDetail->total_paid_amount = Tools::math_round(
- $roomServiceProductAmount, 6
- );
- $objRoomTypeServiceProductOrderDetail->save();
- }
- }
- }
- }
- }
}
\ No newline at end of file
diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php
index 90db69816..0b20d44e5 100644
--- a/classes/order/OrderReturn.php
+++ b/classes/order/OrderReturn.php
@@ -198,22 +198,40 @@ class OrderReturnCore extends ObjectModel
$objBookingDemands = new HotelBookingDemands();
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
+ $objOrder = new Order($idOrder);
foreach ($returnDetails as &$bookingRow) {
$bookingRow['extra_demand_service_total_paid_amount'] = 0;
- $roomSelectedDemands = $objBookingDemands->getSelectedRoomDemandPaidAmount($bookingRow['id_htl_booking']);
- if (count($roomSelectedDemands)) {
- foreach ($roomSelectedDemands as $demand) {
- $bookingRow['extra_demand_service_total_paid_amount'] += $demand['total_paid_amount'];
+ $bookingRow['room_paid_amount'] = 0;
+ if ($objOrder->total_paid_real > 0) {
+ if ($bookingRow['total_price_tax_incl'] > 0) {
+ $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
+ }
+ $roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands(
+ $idOrder,
+ $bookingRow['id_product'],
+ $bookingRow['id_room'],
+ $bookingRow['date_from'],
+ $bookingRow['date_to'],
+ 0
+ );
+ if (count($roomSelectedDemands)) {
+ foreach ($roomSelectedDemands as $demand) {
+ if ($demand['total_price_tax_incl'] > 0) {
+ $bookingRow['extra_demand_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
+ }
+ }
+ }
+
+ if ($roomSelectedServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom($bookingRow['id_htl_booking'])) {
+ if (count($roomSelectedServices['additional_services'])) {
+ foreach ($roomSelectedServices['additional_services'] as $service) {
+ if ($service['total_price_tax_incl'] > 0) {
+ $bookingRow['extra_demand_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl;
+ }
+ }
+ }
}
}
-
- $roomSelectedServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom($bookingRow['id_htl_booking']);
- if (count($roomSelectedServices['additional_services'])) {
- foreach ($roomSelectedServices['additional_services'] as $serviceProduct) {
- $bookingRow['extra_demand_service_total_paid_amount'] += $serviceProduct['total_paid_amount'];
- }
- }
-
if ($customerView) {
$dateJoin = $bookingRow['id_product'].'_'.strtotime($bookingRow['date_from']).strtotime($bookingRow['date_to']);
if (isset($returnsCustView[$dateJoin]['num_rooms'])) {
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index ae5dcb3e6..03e3d1167 100644
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -853,7 +853,6 @@ class AdminOrdersControllerCore extends AdminController
$this->errors[] = Tools::displayError('An error occurred during payment.');
}
} else {
- $order->recalculateOrderSplitAmount();
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
}
}
@@ -1663,7 +1662,7 @@ class AdminOrdersControllerCore extends AdminController
$objHotelBookingDetail = new HotelBookingDetail();
$htlBookingDetail = $objHotelBookingDetail->getOrderCurrentDataByOrderId($order->id);
- $isCancelledRoom = in_array(HotelBookingDetail::ORDER_CANCELLED, array_column($htlBookingDetail, 'is_cancelled'));
+ $isCancelledRoom = in_array(1, array_column($htlBookingDetail, 'is_cancelled'));
// hotel booking statuses
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
@@ -1762,7 +1761,6 @@ class AdminOrdersControllerCore extends AdminController
'products' => $products,
'customer' => $customer)
),
- 'orderCancelled' => HotelBookingDetail::ORDER_CANCELLED,
'isCancelledRoom' => $isCancelledRoom,
);
@@ -3101,7 +3099,6 @@ class AdminOrdersControllerCore extends AdminController
// delete cart feature prices after room addition success
HotelRoomTypeFeaturePricing::deleteByIdCart($cart->id);
- $order->recalculateOrderSplitAmount();
die(json_encode(array(
'result' => true,
//'view' => $this->createTemplate('_product_line.tpl')->fetch(),
@@ -3644,7 +3641,6 @@ class AdminOrdersControllerCore extends AdminController
}
$this->sendChangedNotification($order);
- $order->recalculateOrderSplitAmount();
die(json_encode(array(
'result' => $res,
'view' => $view,
@@ -4088,7 +4084,6 @@ class AdminOrdersControllerCore extends AdminController
));
$this->sendChangedNotification($order);
- $order->recalculateOrderSplitAmount();
die(json_encode(array(
'result' => $res,
'order' => $order,
diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php
index 0ce9722ea..dca2c4266 100644
--- a/controllers/front/GuestTrackingController.php
+++ b/controllers/front/GuestTrackingController.php
@@ -228,7 +228,6 @@ class GuestTrackingControllerCore extends FrontController
$total_demands_price_ti = 0;
$total_convenience_fee_te = 0;
$total_convenience_fee_ti = 0;
- // ddd($orderProducts);
foreach ($orderProducts as $type_key => $type_value) {
if (in_array($type_value['product_id'], $processedProducts)) {
continue;
diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php
index bdbc51175..3c35e0a08 100644
--- a/controllers/front/OrderDetailController.php
+++ b/controllers/front/OrderDetailController.php
@@ -247,9 +247,7 @@ class OrderDetailControllerCore extends FrontController
if ((int)$order->total_paid_real == 0){
foreach ($bookingRefunds as $idHtlBooking) {
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
- $objHtlBooking->is_cancelled = HotelBookingDetail::ORDER_CANCELLED;
$objHtlBooking->save();
-
}
}
@@ -590,7 +588,7 @@ class OrderDetailControllerCore extends FrontController
$objHotelBookingDetail = new HotelBookingDetail();
$htlBookingDetail = $objHotelBookingDetail->getOrderCurrentDataByOrderId($order->id);
- $isCancelledRoom = in_array(HotelBookingDetail::ORDER_CANCELLED, array_column($htlBookingDetail, 'is_cancelled'));
+ $isCancelledRoom = in_array(true, array_column($htlBookingDetail, 'is_cancelled'));
$this->context->smarty->assign(
array(
@@ -607,7 +605,6 @@ class OrderDetailControllerCore extends FrontController
'cart_htl_data' => $cartHotelData,
'cart_service_products' => $cartServiceProducts,
'non_requested_rooms' => $nonRequestedRooms,
- 'orderCancelled' => HotelBookingDetail::ORDER_CANCELLED,
'isCancelledRoom' => $isCancelledRoom,
)
);
diff --git a/modules/hotelreservationsystem/classes/HotelBookingDemands.php b/modules/hotelreservationsystem/classes/HotelBookingDemands.php
index c812ff89d..b243dfc73 100644
--- a/modules/hotelreservationsystem/classes/HotelBookingDemands.php
+++ b/modules/hotelreservationsystem/classes/HotelBookingDemands.php
@@ -26,7 +26,6 @@ class HotelBookingDemands extends ObjectModel
public $unit_price_tax_incl;
public $total_price_tax_excl;
public $total_price_tax_incl;
- public $total_paid_amount;
public $id_tax_rules_group;
public $tax_computation_method;
public $price_calc_method;
@@ -45,7 +44,6 @@ class HotelBookingDemands extends ObjectModel
'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT),
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT),
'total_price_tax_incl' => array('type' => self::TYPE_FLOAT),
- 'total_paid_amount' => array('type' => self::TYPE_FLOAT),
'name' => array(
'type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128
),
@@ -303,12 +301,4 @@ class HotelBookingDemands extends ObjectModel
{
return Db::getInstance()->delete('htl_booking_demands_tax', 'id_booking_demand = '.(int)$idBookingDemand);
}
-
- public function getSelectedRoomDemandPaidAmount($idHotelBooking)
- {
- return Db::getInstance()->executeS(
- 'SELECT hbd.`id_booking_demand`, hbd.`total_paid_amount`, hbd.`total_price_tax_incl` FROM `'._DB_PREFIX_.'htl_booking_demands` hbd
- WHERE `id_htl_booking` = '.(int)$idHotelBooking
- );
- }
}
diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
index ce625a0a1..8f2b3ad49 100644
--- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php
+++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
@@ -74,8 +74,6 @@ class HotelBookingDetail extends ObjectModel
const ALLOTMENT_AUTO = 1;
const ALLOTMENT_MANUAL = 2;
- const ORDER_CANCELLED = 1;
-
// Search algorithm: Exact room types reults, All room types
const SEARCH_EXACT_ROOM_TYPE_ALGO = 1;
const SEARCH_ALL_ROOM_TYPE_ALGO = 2;
diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
index 491c82c29..f1ccac19c 100644
--- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
+++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
@@ -153,17 +153,10 @@ class HotelOrderRefundRules extends ObjectModel
1
);
- $totalServicesPrice = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
- $objHtlBooking->id_order,
- 0,
- 0,
- $objHtlBooking->id_product,
- $objHtlBooking->date_from,
- $objHtlBooking->date_to,
- $objHtlBooking->id_room,
+ $totalServicesPrice = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
+ $objHtlBooking->id,
1,
- 1,
- null
+ 1
);
if ($refundRules = $objHtlRefundRules->getHotelRefundRules($objHtlBooking->id_hotel, 0, 1)) {
diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
index 069ca850f..0e9d09668 100644
--- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
+++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
@@ -199,7 +199,6 @@ class HotelReservationSystemDb
`unit_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000',
`total_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000',
`total_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000',
- `total_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.000000',
`price_calc_method` int(11) unsigned DEFAULT '0',
`id_tax_rules_group` int(11) unsigned DEFAULT '0',
`tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0',
@@ -419,7 +418,6 @@ class HotelReservationSystemDb
`unit_price_tax_incl` decimal(20,6) NOT NULL,
`total_price_tax_excl` decimal(20,6) NOT NULL,
`total_price_tax_incl` decimal(20,6) NOT NULL,
- `total_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.000000',
`name` varchar(255) DEFAULT NULL,
`quantity` INT(11) UNSIGNED NOT NULL,
`auto_added` tinyint(1) unsigned NOT NULL,
diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
index 968a39d02..2baeaab31 100644
--- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
+++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
@@ -30,7 +30,6 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
public $unit_price_tax_incl;
public $total_price_tax_excl;
public $total_price_tax_incl;
- public $total_paid_amount;
public $name;
public $quantity;
public $auto_added;
@@ -50,7 +49,6 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'total_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
- 'total_paid_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'name' => array('type' => self::TYPE_STRING, 'required' => true),
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'auto_added' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
@@ -201,9 +199,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
$sql .= ', hbd.`id_product` as `room_type_id_product`, od.`product_allow_multiple_quantity`, hbd.`id_room`, od.`product_auto_add`, od.`product_price_addition_type`';
}
$sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
- $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`product_id` = rsod.`id_product`)';
+ $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = rsod.`id_order_detail`)';
$sql .= ' WHERE hbd.`id` = '.(int)$idHotelBookingDetail;
@@ -234,7 +232,6 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'product_price_addition_type' => $product['product_price_addition_type'],
'total_price_tax_excl' => $product['total_price_tax_excl'],
'total_price_tax_incl' => $product['total_price_tax_incl'],
- 'total_paid_amount' => $product['total_paid_amount'],
);
} else {
$selectedAdditionalServices['id_order'] = $product['id_order'];
@@ -256,7 +253,6 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'product_price_addition_type' => $product['product_price_addition_type'],
'total_price_tax_excl' => $product['total_price_tax_excl'],
'total_price_tax_incl' => $product['total_price_tax_incl'],
- 'total_paid_amount' => $product['total_paid_amount'],
),
);
}
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
index 7e15d749e..c63e3ea2a 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
@@ -326,6 +326,8 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
$totalRefundedAmount = 0;
if ($objRefundState->refunded || $objRefundState->denied) {
+ $objHotelBookingDemands = new HotelBookingDemands();
+ $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
foreach ($idsReturnDetail as $idRetDetail) {
$objOrderReturnDetail = new OrderReturnDetail($idRetDetail);
@@ -333,6 +335,12 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
$idHtlBooking = $objOrderReturnDetail->id_htl_booking;
$numDays = 1;
$idOrderDetail = 0;
+ $reduction_amount = array(
+ 'total_price_tax_excl' => 0,
+ 'total_price_tax_incl' => 0,
+ 'total_products_tax_excl' => 0,
+ 'total_products_tax_incl' => 0,
+ );
if (Validate::isLoadedObject($objHtlBooking = new HotelBookingDetail($idHtlBooking))) {
$objHtlBooking->is_refunded = 1;
$numDays = $objHtlBooking->getNumberOfDays(
@@ -340,6 +348,62 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
$objHtlBooking->date_to
);
+ if ((float) $orderTotalPaid <= 0) {
+ $reduction_amount['total_price_tax_excl'] = $objHtlBooking->total_price_tax_excl;
+ $reduction_amount['total_products_tax_excl'] = $objHtlBooking->total_price_tax_excl;
+ $reduction_amount['total_price_tax_incl'] = $objHtlBooking->total_price_tax_incl;
+ $reduction_amount['total_products_tax_incl'] = $objHtlBooking->total_price_tax_incl;
+ // reduce facilities amount from order and services_detail
+ if ($roomDemands = $objHotelBookingDemands->getRoomTypeBookingExtraDemands(
+ $objHtlBooking->id_order,
+ $objHtlBooking->id_product,
+ $objHtlBooking->id_room,
+ $objHtlBooking->date_from,
+ $objHtlBooking->date_to,
+ 0
+ )) {
+ foreach ($roomDemands as $roomDemand) {
+ $objHotelBookingDemands = new HotelBookingDemands($roomDemand['id_booking_demand']);
+ $reduction_amount['total_price_tax_excl'] += $objHotelBookingDemands->total_price_tax_excl;
+ $reduction_amount['total_price_tax_incl'] += $objHotelBookingDemands->total_price_tax_incl;
+ $objHotelBookingDemands->total_price_tax_excl = 0;
+ $objHotelBookingDemands->total_price_tax_incl = 0;
+ $objHotelBookingDemands->save();
+ }
+ }
+
+ // reduce services amount from order and services_detail
+ if ($roomServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom(
+ $objHtlBooking->id
+ )) {
+ foreach ($roomServices['additional_services'] as $roomService) {
+ $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(
+ $roomService['id_room_type_service_product_order_detail']
+ );
+ $reduction_amount['total_price_tax_excl'] += $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
+ $reduction_amount['total_products_tax_excl'] += $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
+ $reduction_amount['total_price_tax_incl'] += $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
+ $reduction_amount['total_products_tax_incl'] += $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
+
+ if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($objRoomTypeServiceProductOrderDetail->id_order_detail))) {
+ $objOrderDetail->product_quantity_refunded += $objRoomTypeServiceProductOrderDetail->quantity;
+ if ($objOrderDetail->product_quantity_refunded > $objOrderDetail->product_quantity) {
+ $objOrderDetail->product_quantity_refunded = $objOrderDetail->product_quantity;
+ }
+
+ $objOrderDetail->total_price_tax_excl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
+ $objOrderDetail->total_price_tax_incl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
+ $objOrderDetail->save();
+ }
+
+ $objRoomTypeServiceProductOrderDetail->total_price_tax_excl = 0;
+ $objRoomTypeServiceProductOrderDetail->total_price_tax_incl = 0;
+ $objRoomTypeServiceProductOrderDetail->save();
+ }
+ }
+
+ }
+
// enter refunded quantity in the order detail table
$idOrderDetail = $objHtlBooking->id_order_detail;
if (Validate::isLoadedObject($objOrderDetail = new OrderDetail($idOrderDetail))) {
@@ -349,20 +413,22 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
}
if ((float) $orderTotalPaid <= 0) {
+ // reduce room amount from order and order detail
$objOrderDetail->total_price_tax_incl -= $objHtlBooking->total_price_tax_incl;
$objOrderDetail->total_price_tax_excl -= $objHtlBooking->total_price_tax_excl;
if (Validate::isLoadedObject($objOrder = new Order($objHtlBooking->id_order))) {
- $objOrder->total_paid -= $objHtlBooking->total_price_tax_incl;
- $objOrder->total_paid_tax_excl -= $objHtlBooking->total_price_tax_excl;
- $objOrder->total_paid_tax_incl -= $objHtlBooking->total_price_tax_incl;
- $objOrder->total_products -= $objHtlBooking->total_price_tax_excl;
- $objOrder->total_products_wt -= $objHtlBooking->total_price_tax_incl;
+ $objOrder->total_paid -= $reduction_amount['total_price_tax_incl'];
+ $objOrder->total_paid_tax_excl -= $reduction_amount['total_price_tax_excl'];
+ $objOrder->total_paid_tax_incl -= $reduction_amount['total_price_tax_incl'];
+ $objOrder->total_products -= $reduction_amount['total_products_tax_excl'];
+ $objOrder->total_products_wt -= $reduction_amount['total_products_tax_incl'];
$objOrder->save();
}
}
$objOrderDetail->save();
}
if ((float) $orderTotalPaid <= 0) {
+ // reduce room amount from htl_booking_detail
$objHtlBooking->is_cancelled = 1;
$objHtlBooking->total_price_tax_excl = 0;
$objHtlBooking->total_price_tax_incl = 0;
diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl
index ec9f94b31..1f603533d 100644
--- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl
+++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl
@@ -136,7 +136,7 @@
| {$booking['room_type_name']|escape:'htmlall':'UTF-8'} |
{$booking['hotel_name']|escape:'htmlall':'UTF-8'} |
{$booking['date_from']|date_format:"%d-%m-%Y"} {l s='To' mod='hotelreservationsystem'} {$booking['date_to']|date_format:"%d-%m-%Y"} |
- {displayPrice price=$booking['total_paid_amount'] currency=$orderCurrency['id']} |
+ {displayPrice price=$booking['room_paid_amount'] currency=$orderCurrency['id']} |
{displayPrice price=$booking['extra_demand_service_total_paid_amount'] currency=$orderCurrency['id']} |
{if !$isRefundCompleted}
{displayPrice price=$booking['cancelation_charge'] currency=$orderCurrency['id']} |
@@ -148,7 +148,7 @@
{displayPrice price=$booking['refunded_amount'] currency=$orderCurrency['id']}
{else}
{$orderCurrency['sign']|escape:'html':'UTF-8'}
-
+
{l s='tax incl.' mod='hotelreservationsystem'}
{/if}
diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl
index b57940698..4c5e21d17 100644
--- a/themes/hotel-reservation-theme/order-detail.tpl
+++ b/themes/hotel-reservation-theme/order-detail.tpl
@@ -363,10 +363,10 @@
{l s='Room Capacity'} |
{l s='Check-in Date'} |
{l s='Check-out Date'} |
- {l s='Extra Services'} |
{if isset($isCancelledRoom) && $isCancelledRoom}
{l s='Room Status'} |
{/if}
+ {l s='Extra Services'} |
{l s='Total'} |
@@ -380,7 +380,7 @@
{foreach $rm_v['ids_htl_booking_detail'] as $key => $id_htl_booking}