diff --git a/admin/themes/default/template/controllers/products/prices.tpl b/admin/themes/default/template/controllers/products/prices.tpl
index c46bfa7d2..ec55ab447 100644
--- a/admin/themes/default/template/controllers/products/prices.tpl
+++ b/admin/themes/default/template/controllers/products/prices.tpl
@@ -413,21 +413,21 @@ $(document).ready(function () {
{$featurePlan['feature_price_name']}
- {if $featurePlan['impact_type'] == 1}
+ {if $featurePlan['impact_type'] == HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE}
{l s='Percentage'}
{else}
{l s='Fixed Amount'}
{/if}
|
- {if $featurePlan['impact_way'] == 1}
+ {if $featurePlan['impact_way'] == HotelRoomTypeFeaturePricing::IMPACT_WAY_DECREASE}
{l s='Decrease'}
{else}
{l s='Increase'}
{/if}
|
- {if $featurePlan['impact_type'] == 1}
+ {if $featurePlan['impact_type'] == HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE}
{$featurePlan['impact_value']|round:2}%
{else}
{displayPrice price=$featurePlan['impact_value']}
@@ -437,7 +437,7 @@ $(document).ready(function () {
{dateFormat date=$featurePlan['date_from'] full=0}
|
- {if $featurePlan['date_selection_type'] == 1}
+ {if $featurePlan['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE}
{dateFormat date=$featurePlan['date_to'] full=0}
{else}
{l s='Specific date'}
diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php
index ce3148009..3662f9be9 100644
--- a/classes/PaymentModule.php
+++ b/classes/PaymentModule.php
@@ -756,7 +756,7 @@ abstract class PaymentModuleCore extends Module
$objBookingDetail->email = $objHotelBranch->email;
$objBookingDetail->check_in_time = $objHotelBranch->check_in;
$objBookingDetail->check_out_time = $objHotelBranch->check_out;
- if ($hotelAddress = $objHotelBranch->getAddress($objCartBkData->id_hotel)) {
+ if ($hotelAddress = $objHotelBranch->getAddress($objCartBookingData->id_hotel)) {
$objBookingDetail->city = $hotelAddress['city'];
$objBookingDetail->state = $hotelAddress['state'];
$objBookingDetail->country = $hotelAddress['country'];
@@ -1353,20 +1353,17 @@ abstract class PaymentModuleCore extends Module
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code."-default", 'small_default');
}
- $unit_price = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
-
if (isset($customer->id)) {
$cart_obj = new Cart($order->id_cart);
- $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, $cart_obj->id_guest, $type_value['product_id'], $customer->id);
+ $cart_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $cart_obj->id_guest, $type_value['product_id'], $customer->id);
} else {
- $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, $customer->id_guest, $type_value['product_id']);
+ $cart_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
}
$rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']);
$cart_htl_data[$type_key]['id_product'] = $type_value['product_id'];
$cart_htl_data[$type_key]['cover_img'] = $cover_img;
$cart_htl_data[$type_key]['name'] = $product->name;
- $cart_htl_data[$type_key]['unit_price'] = $unit_price;
$cart_htl_data[$type_key]['hotel_name'] = $rm_dtl['hotel_name'];
$cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
$cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
@@ -1378,16 +1375,11 @@ abstract class PaymentModuleCore extends Module
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
- $vart_quant = (int)$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'];
- //$amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
- //$amount *= $vart_quant;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
-
- $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']);
-
-
- $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl']*$vart_quant;
// extra demands prices
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order->id,
@@ -1423,12 +1415,11 @@ abstract class PaymentModuleCore extends Module
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
- /*$amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
- $amount *= $num_days;*/
- $roomTypeDateRangePrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice($type_value['id_product'], $data_v['date_from'], $data_v['date_to']);
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
- $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl'];
// extra demands prices
$cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
$order->id,
@@ -1461,6 +1452,10 @@ abstract class PaymentModuleCore extends Module
$result['total_extra_demands_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
}
}
+ // calculate averages now
+ foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
+ $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
+ }
}
}
$result['cart_htl_data'] = $cart_htl_data;
diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php
index 8d2c7c0c9..7a669e9fe 100644
--- a/classes/pdf/HTMLTemplateInvoice.php
+++ b/classes/pdf/HTMLTemplateInvoice.php
@@ -402,12 +402,12 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
- $var_quant = (int)$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
- $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $data_v['total_price_tax_excl']*$var_quant;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += $data_v['total_price_tax_excl'];
// For order refund
$cart_htl_data[$type_key]['date_diff'][$date_join]['stage_name'] = $stage_name;
@@ -450,6 +450,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days;
+ $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
+
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $data_v['total_price_tax_excl'];
// For order refund
@@ -471,6 +473,11 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$cart_htl_data[$type_key]['order_detail_tax_label'] = HTMLTemplateInvoice::l('No tax');
}
}
+
+ // calculate averages now
+ foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
+ $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
+ }
}
unset($tax_temp);
diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php
index 2b7b9323b..52fc20330 100644
--- a/controllers/admin/AdminCartsController.php
+++ b/controllers/admin/AdminCartsController.php
@@ -911,13 +911,13 @@ class AdminCartsControllerCore extends AdminController
$hrt_feature_price->id_guest = (int) $this->context->cookie->id_guest;
$hrt_feature_price->id_room = $id_room;
$hrt_feature_price->feature_price_name = $feature_price_name;
- $hrt_feature_price->date_selection_type = 1; // date range
+ $hrt_feature_price->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
$hrt_feature_price->date_from = $date_from;
$hrt_feature_price->date_to = $date_to;
$hrt_feature_price->is_special_days_exists = 0;
$hrt_feature_price->special_days = json_encode(false);
- $hrt_feature_price->impact_way = 3; // fix price
- $hrt_feature_price->impact_type = 2; // fixed price
+ $hrt_feature_price->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
+ $hrt_feature_price->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
$hrt_feature_price->impact_value = $price;
$hrt_feature_price->active = 1;
$hrt_feature_price->groupBox = array_column(Group::getGroups($this->context->language->id), 'id_group');
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index b7864c952..8fde235f1 100644
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -1884,7 +1884,7 @@ class AdminOrdersControllerCore extends AdminController
$order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)}
);
- // creatie feature pricec if needed
+ // create feature price if needed
$createFeaturePrice = $product_informations['product_price_tax_incl'] != $initial_product_price_tax_incl;
$featurePriceParams = array();
if ($createFeaturePrice) {
@@ -2310,13 +2310,13 @@ class AdminOrdersControllerCore extends AdminController
$hrt_feature_price->id_guest = (int) $params['id_guest'];
$hrt_feature_price->id_room = (int) $params['id_room'];
$hrt_feature_price->feature_price_name = $feature_price_name;
- $hrt_feature_price->date_selection_type = 1; // date range
+ $hrt_feature_price->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
$hrt_feature_price->date_from = date('Y-m-d', strtotime($params['date_from']));
$hrt_feature_price->date_to = date('Y-m-d', strtotime($params['date_to']));
$hrt_feature_price->is_special_days_exists = 0;
$hrt_feature_price->special_days = json_encode(false);
- $hrt_feature_price->impact_way = 3; // fix price
- $hrt_feature_price->impact_type = 2; // fixed price
+ $hrt_feature_price->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
+ $hrt_feature_price->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE;
$hrt_feature_price->impact_value = $params['price'];
$hrt_feature_price->active = 1;
$hrt_feature_price->groupBox = array_column(Group::getGroups($this->context->language->id), 'id_group');
diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php
index 19c3a1def..120a32022 100644
--- a/controllers/front/OrderDetailController.php
+++ b/controllers/front/OrderDetailController.php
@@ -332,12 +332,13 @@ class OrderDetailControllerCore extends FrontController
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
- $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
- $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant;
- $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant;
+ $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
+ $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
+ $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
+ $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
if ($data_v['is_back_order']) {
$anyBackOrder = 1;
@@ -351,6 +352,8 @@ class OrderDetailControllerCore extends FrontController
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
+ $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
+ $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
@@ -406,6 +409,15 @@ class OrderDetailControllerCore extends FrontController
$cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name'];
}
+
+ // calculate averages now
+ foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) {
+ $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
+ $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
+
+ $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6));
+ $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6));
+ }
}
$redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id);
diff --git a/mails/en/hotel-booking-cart-data-text.tpl b/mails/en/hotel-booking-cart-data-text.tpl
index 5f70fa759..e43c96c5b 100644
--- a/mails/en/hotel-booking-cart-data-text.tpl
+++ b/mails/en/hotel-booking-cart-data-text.tpl
@@ -9,7 +9,7 @@
{$data_v['adult']} {l s='Adults'}, {$data_v['children']} {l s='Children'}
-{convertPrice price=$data_v['unit_price']}
+{convertPrice price=$rm_v['avg_paid_unit_price_tax_incl']}
{$rm_v['num_rm']}
@@ -17,7 +17,7 @@
{$rm_v['data_to']|date_format:"%d-%b-%G"}
-{$rm_v['amount']}
+{$rm_v['amount_tax_incl']}
{/foreach}
diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
index edb27ee45..69557aab5 100644
--- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php
+++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
@@ -1230,6 +1230,29 @@ class HotelBookingDetail extends ObjectModel
$newTotalPriceTI = $unitRoomPriceTI * $newNumDays;
}
+ // update `total_paid_amount` on database
+ $totalPaidAmount = 0;
+ $isAdvancePayment = Db::getInstance()->getValue(
+ 'SELECT o.`is_advance_payment`
+ FROM `'._DB_PREFIX_.'orders` o
+ WHERE o.`id_order` = '.(int) $id_order
+ );
+
+ if ($isAdvancePayment) {
+ $objHotelAdvancedPayment = new HotelAdvancedPayment();
+ $productAdvancePayment = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($rowByIdOrderIdRoom['id_product']);
+
+ if (!$productAdvancePayment || (isset($productAdvancePayment['payment_type']) && $productAdvancePayment['payment_type'])) {
+ $totalPaidAmount = $objHotelAdvancedPayment->getRoomMinAdvPaymentAmount(
+ $rowByIdOrderIdRoom['id_product'],
+ $new_date_from,
+ $new_date_to
+ );
+ }
+ } else {
+ $totalPaidAmount = $newTotalPriceTI;
+ }
+
$cart_booking = array(
'table' => 'htl_cart_booking_data',
'data' => array(
@@ -1246,6 +1269,7 @@ class HotelBookingDetail extends ObjectModel
'date_to' => $new_date_to,
'total_price_tax_excl' => $newTotalPriceTE,
'total_price_tax_incl' => $newTotalPriceTI,
+ 'total_paid_amount' => $totalPaidAmount,
),
);
diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php
index 452b754ee..dd0fb2cf8 100644
--- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php
+++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php
@@ -800,7 +800,7 @@ class HotelCartBookingData extends ObjectModel
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1
- AND fp.`date_selection_type`=2 AND fp.`date_from` = \''.pSQL($date).'\''
+ AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\''
)) {
return $featurePrice;
}
@@ -825,7 +825,7 @@ class HotelCartBookingData extends ObjectModel
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
- WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type`=1
+ WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
AND `is_special_days_exists`=0 AND `active`=1
AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''
)) {
diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
index 578ed3f26..d49354299 100644
--- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
+++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
@@ -128,20 +128,30 @@ class HotelOrderRefundRules extends ObjectModel
public function calculateDeductionAmountFromRefundRules($idOrder, $idOrderReturn = 0, $idHtlBooking = 0)
{
- $cancelationCharges = 0;
+ $totalCancelationCharges = 0;
+
+ $objHtlRefundRules = new HotelBranchRefundRules();
+ $objHotelBookingDemands = new HotelBookingDemands();
+
if ($bookingsToRefund = OrderReturn::getOrdersReturnDetail($idOrder, $idOrderReturn, $idHtlBooking)) {
foreach ($bookingsToRefund as $booking) {
+ $bookingCancellationCharge = 0;
+
if (Validate::isLoadedObject($objHtlBooking = new HotelBookingDetail($booking['id_htl_booking']))) {
$objOrder = new Order($objHtlBooking->id_order);
$adPaidAmount = 0;
$refundValue = 0;
- $wayOfPayment = 'fullPayment';
- if ($objOrder->is_advance_payment) {
- $wayOfPayment = 'advancePayment';
- }
+ $totalDemandsPrice = $objHotelBookingDemands->getRoomTypeBookingExtraDemands(
+ $objHtlBooking->id_order,
+ $objHtlBooking->id_product,
+ $objHtlBooking->id_room,
+ $objHtlBooking->date_from,
+ $objHtlBooking->date_to,
+ 1,
+ 1
+ );
- $objHtlRefundRules = new HotelBranchRefundRules();
if ($refundRules = $objHtlRefundRules->getHotelRefundRules($objHtlBooking->id_hotel, 0, 1)) {
$orderCurrency = $objOrder->id_currency;
$defaultCurrency = Configuration::get('PS_CURRENCY_DEFAULT');
@@ -156,9 +166,10 @@ class HotelOrderRefundRules extends ObjectModel
$daysDifference = date_diff($startDate, $dateRequest);
$daysBeforeCancel = (int) $daysDifference->format('%a');
+ $ruleApplied = false;
foreach ($refundRules as $refRule) {
if ($daysBeforeCancel >= $refRule['days']) {
- $paidAmount = $objHtlBooking->total_paid_amount;
+ $paidAmount = $objHtlBooking->total_paid_amount + $totalDemandsPrice;
if ($objOrder->is_advance_payment) {
$refundValue = $refRule['deduction_value_adv_pay'];
} else {
@@ -166,41 +177,49 @@ class HotelOrderRefundRules extends ObjectModel
}
if ($refRule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE) {
- $cancelationCharges = $paidAmount * ($refundValue / 100);
+ $bookingCancellationCharge = $paidAmount * ($refundValue / 100);
if ($defaultCurrency != $orderCurrency) {
- $cancelationCharges = Tools::convertPriceFull(
- $cancelationCharges,
+ $bookingCancellationCharge = Tools::convertPriceFull(
+ $bookingCancellationCharge,
$objDefaultCurrency,
$objOrderCurrency
);
}
} else {
if ($defaultCurrency != $orderCurrency) {
- $cancelationCharges = Tools::convertPriceFull(
+ $bookingCancellationCharge = Tools::convertPriceFull(
$refundValue,
$objDefaultCurrency,
$objOrderCurrency
);
} else {
- $cancelationCharges = $refundValue;
+ $bookingCancellationCharge = $refundValue;
}
- //if deduction amount is more than the order total cost
- if ($cancelationCharges > $paidAmount) {
- $cancelationCharges = $paidAmount;
+ // if deduction amount is more than the order total cost
+ if ($bookingCancellationCharge > $paidAmount) {
+ $bookingCancellationCharge = $paidAmount;
}
}
+
+ $ruleApplied = true;
break;
}
}
+
+ if (!$ruleApplied) {
+ $bookingCancellationCharge = ($objHtlBooking->total_price_tax_incl + $totalDemandsPrice);
+ }
} else {
- $cancelationCharges += $objHtlBooking->total_price_tax_incl;
+ $bookingCancellationCharge = ($objHtlBooking->total_price_tax_incl + $totalDemandsPrice);
}
}
+
+ $totalCancelationCharges += $bookingCancellationCharge;
}
}
- return $cancelationCharges;
+ return $totalCancelationCharges;
}
}
diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
index 910675c1d..e5d235806 100644
--- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
+++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
@@ -39,6 +39,16 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
public $groupBox;
+ const DATE_SELECTION_TYPE_RANGE = 1;
+ const DATE_SELECTION_TYPE_SPECIFIC = 2;
+
+ const IMPACT_WAY_DECREASE = 1;
+ const IMPACT_WAY_INCREASE = 2;
+ const IMPACT_WAY_FIX_PRICE = 3;
+
+ const IMPACT_TYPE_PERCENTAGE = 1;
+ const IMPACT_TYPE_FIXED_PRICE = 2;
+
public static $definition = array(
'table' => 'htl_room_type_feature_pricing',
'primary' => 'id_feature_price',
@@ -180,7 +190,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
return Db::getInstance()->getRow(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing`
WHERE `id_product`='.(int) $id_product.'
- AND `date_selection_type`=2
+ AND `date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_SPECIFIC.'
AND `date_from` = \''.pSQL($date_from).'\'
AND `id_feature_price`!='.(int) $id_feature_price
);
@@ -206,7 +216,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
return Db::getInstance()->getRow(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing`
WHERE `id_product`='.(int) $id_product.'
- AND `date_selection_type`=1
+ AND `date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_RANGE.'
AND `is_special_days_exists`=0
AND `date_from` <= \''.pSQL($date_to).'\'
AND `date_to` >= \''.pSQL($date_from).'\'
@@ -363,7 +373,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$params['enableFeaturePrice'] = 1;
$nextDate = date('Y-m-d', strtotime('+1 day', strtotime($dateFrom)));
if ($nextDate == $dateTo) {
- $params['dateSelectionType'] = 2;
+ $params['dateSelectionType'] = self::DATE_SELECTION_TYPE_SPECIFIC;
$featurePriceExists = $this->checkRoomTypeFeaturePriceExistance(
$id_product,
$dateFrom,
@@ -380,7 +390,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
}
}
} else {
- $params['dateSelectionType'] = 1;
+ $params['dateSelectionType'] = self::DATE_SELECTION_TYPE_RANGE;
$featurePriceExists = $this->checkRoomTypeFeaturePriceExistance(
$id_product,
$dateFrom,
@@ -404,7 +414,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$nextDayDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
$params['dateFrom'] = $currentDate;
$params['dateTo'] = $nextDayDate;
- $params['dateSelectionType'] = 2;
+ $params['dateSelectionType'] = self::DATE_SELECTION_TYPE_SPECIFIC;
$featurePriceExists = $this->checkRoomTypeFeaturePriceExistance(
$id_product,
$currentDate,
@@ -604,7 +614,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$roomTypeFeaturePricing->feature_price_name[$language['id_lang']] = $params['featurePriceName'];
}
$roomTypeFeaturePricing->date_selection_type = $params['dateSelectionType'];
- if ($dateSelectionType == 1) {
+ if ($dateSelectionType == self::DATE_SELECTION_TYPE_RANGE) {
$roomTypeFeaturePricing->date_from = $params['dateFrom'];
$roomTypeFeaturePricing->date_to = $params['dateTo'];
} else {
@@ -676,7 +686,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$id_guest,
$id_room
)) {
- if ($featurePrice['impact_type'] == 1) {
+ if ($featurePrice['impact_type'] == self::IMPACT_TYPE_PERCENTAGE) {
//percentage
$featureImpactPriceTE = $productPriceTE * ($featurePrice['impact_value'] / 100);
$featureImpactPriceTI = $productPriceTI * ($featurePrice['impact_value'] / 100);
@@ -686,11 +696,11 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$featureImpactPriceTE = Tools::convertPrice($featurePrice['impact_value'], $id_currency);
$featureImpactPriceTI = Tools::convertPrice($featurePrice['impact_value']+$taxPrice, $id_currency);
}
- if ($featurePrice['impact_way'] == 1) {
+ if ($featurePrice['impact_way'] == self::IMPACT_WAY_DECREASE) {
// Decrease
$priceWithFeatureTE = ($productPriceTE - $featureImpactPriceTE);
$priceWithFeatureTI = ($productPriceTI - $featureImpactPriceTI);
- } elseif ($featurePrice['impact_way'] == 2) {
+ } elseif ($featurePrice['impact_way'] == self::IMPACT_WAY_INCREASE) {
// Increase
$priceWithFeatureTE = ($productPriceTE + $featureImpactPriceTE);
$priceWithFeatureTI = ($productPriceTI + $featureImpactPriceTI);
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php
index 881949f22..46668b770 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php
@@ -42,13 +42,13 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = a.`id_product`)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hbl.`id` = hrt.`id_hotel` AND hbl.`id_lang`='.(int) $this->context->language->id.')';
- $this->_select .= ' fpl.`feature_price_name` as ftr_price_name, CONCAT(pl.`name`, " (#", a.`id_product`, ")") as product_name, hbl.`hotel_name`, IF(a.impact_type=1 , CONCAT(round(a.impact_value, 2), " ", "%"), a.impact_value) AS impact_value';
- $this->_select .= ' ,IF(a.impact_type=1 , \''.$this->l('Percentage').'\', \''.$this->l('Fixed Amount').'\')
+ $this->_select .= ' fpl.`feature_price_name` as ftr_price_name, CONCAT(pl.`name`, " (#", a.`id_product`, ")") as product_name, hbl.`hotel_name`, IF(a.impact_type='.(int) HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE.', CONCAT(round(a.impact_value, 2), " ", "%"), a.impact_value) AS impact_value';
+ $this->_select .= ' ,IF(a.impact_type='.(int) HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE.', \''.$this->l('Percentage').'\', \''.$this->l('Fixed Amount').'\')
AS impact_type';
$this->_select .= ', CASE
- WHEN a.`impact_way` = 1 THEN \''.$this->l('Decrease').'\'
- WHEN a.`impact_way` = 2 THEN \''.$this->l('Increase').'\'
- WHEN a.`impact_way` = 3 THEN \''.$this->l('Fix').'\'
+ WHEN a.`impact_way` = '.(int) HotelRoomTypeFeaturePricing::IMPACT_WAY_DECREASE.' THEN \''.$this->l('Decrease').'\'
+ WHEN a.`impact_way` = '.(int) HotelRoomTypeFeaturePricing::IMPACT_WAY_INCREASE.' THEN \''.$this->l('Increase').'\'
+ WHEN a.`impact_way` = '.(int) HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE.' THEN \''.$this->l('Fix').'\'
END AS `impact_way`';
$this->_where = ' AND a.`id_cart` = 0 AND a.`id_guest` = 0 AND a.`id_room` = 0';
@@ -131,7 +131,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
public function getDateToValue($dateTo, $row)
{
- if ($row['date_selection_type'] == 1) {
+ if ($row['date_selection_type'] == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
return date($this->context->language->date_format_lite, strtotime($dateTo));
} else {
return ''.$this->l('Specific date').'';
@@ -260,7 +260,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
$languages = Language::getLanguages(false);
$objDefaultLang = new language($defaultLangId);
$isPlanTypeExists = 0;
- if ($dateSelectionType == 2) {
+ if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC) {
$isPlanTypeExists = $objFeaturePricing->checkRoomTypeFeaturePriceExistance(
$roomTypeId,
$specificDate,
@@ -321,7 +321,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
}
}
- if ($dateSelectionType == 1) {
+ if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
if ($dateFrom == '') {
$this->errors[] = $this->l('Please choose Date from for the feature price.');
}
@@ -384,7 +384,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
}
$objFeaturePricing->date_selection_type = $dateSelectionType;
- if ($dateSelectionType == 1) {
+ if ($dateSelectionType == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE) {
$objFeaturePricing->date_from = $dateFrom;
$objFeaturePricing->date_to = $dateTo;
} else {
@@ -463,6 +463,23 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController
public function setMedia()
{
parent::setMedia();
+
+ Media::addJsDef(array(
+ 'date_selection_types' => array(
+ 'range' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE,
+ 'specific' => HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC,
+ ),
+ 'impact_ways' => array(
+ 'decrease' => HotelRoomTypeFeaturePricing::IMPACT_WAY_DECREASE,
+ 'increase' => HotelRoomTypeFeaturePricing::IMPACT_WAY_INCREASE,
+ 'fix' => HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE,
+ ),
+ 'impact_types' => array(
+ 'percentage' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_PERCENTAGE,
+ 'fixed' => HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE,
+ ),
+ ));
+
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
}
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
index 4d32141db..8b0477159 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php
@@ -448,7 +448,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
// Generate voucher
if (Tools::isSubmit('generateDiscount') && !count($this->errors)) {
$cartrule = new CartRule();
- $language_ids = Language::getIDs((bool)$order);
+ $language_ids = Language::getIDs();
$cartrule->description = sprintf($this->l('Credit card slip for order #%d'), $objOrder->id);
foreach ($language_ids as $id_lang) {
// Define a temporary name
diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
index 2197b263c..e791a8b18 100644
--- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
+++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js
@@ -905,11 +905,11 @@ $(document).ready(function() {
/* ---- AdminHotelFeaturePricesSettingsController Admin ---- */
$('#date_selection_type').on('change', function() {
- if ($('#date_selection_type').val() == 2) {
+ if ($('#date_selection_type').val() == date_selection_types.specific) {
$(".specific_date_type").show(200);
$(".date_range_type").hide(200);
$(".special_days_content").hide(200);
- } else if ($('#date_selection_type').val() == 1) {
+ } else if ($('#date_selection_type').val() == date_selection_types.range) {
$(".specific_date_type").hide(200);
$(".date_range_type").show(200);
$(".special_days_content").show(200);
@@ -930,9 +930,9 @@ $(document).ready(function() {
});
$('#price_impact_way').on('change', function() {
- if ($('#price_impact_way').val() == 3) {
- $('#price_impact_type option[value="2"]').attr('selected', 'selected');
- $('#price_impact_type_input').removeAttr('disabled').val(2);
+ if ($('#price_impact_way').val() == impact_ways.fix) {
+ $('#price_impact_type option[value="' + impact_ways.increase + '"]').attr('selected', 'selected');
+ $('#price_impact_type_input').removeAttr('disabled').val(impact_ways.increase);
$('#price_impact_type').trigger('change').attr('disabled', 'disabled');
} else {
$('#price_impact_type_input').attr('disabled', 'disabled');
@@ -941,9 +941,9 @@ $(document).ready(function() {
});
$('#price_impact_type').on('change', function() {
- if ($('#price_impact_type').val() == 2) {
+ if ($('#price_impact_type').val() == impact_types.fixed) {
$(".payment_type_icon").text(defaultcurrency_sign);
- } else if ($('#price_impact_type').val() == 1) {
+ } else if ($('#price_impact_type').val() == impact_types.percentage) {
$(".payment_type_icon").text('%');
} else {
$(".payment_type_icon").text(defaultcurrency_sign);
diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl
index 2fa68ae8c..4ecb8af89 100644
--- a/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl
+++ b/modules/hotelreservationsystem/views/templates/admin/hotel_feature_prices_settings/helpers/form/form.tpl
@@ -78,17 +78,17 @@
-
-
-
- date_selection_type) && $objFeaturePrice->date_selection_type == 2}style="display:none;"{/if}>
+ date_selection_type) && $objFeaturePrice->date_selection_type == HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC}style="display:none;"{/if}>
@@ -218,11 +218,11 @@
{l s='Impact Type :' mod='hotelreservationsystem'}
- |
- {displayPrice currency=$order->id_currency price=$rm_v['paid_unit_price_tax_incl']}
+ {displayPrice currency=$order->id_currency price=$rm_v['avg_paid_unit_price_tax_excl']}
|
diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl
index f125fafc8..bcfc6d8cd 100644
--- a/themes/hotel-reservation-theme/order-detail.tpl
+++ b/themes/hotel-reservation-theme/order-detail.tpl
@@ -359,20 +359,20 @@
{if $group_use_tax}
-
+
{displayWtPriceWithCurrency price=$rm_v['product_price_without_reduction_tax_incl'] currency=$currency}
-
- {displayWtPriceWithCurrency price=$rm_v['paid_unit_price_tax_incl'] currency=$currency}
+
+ {displayWtPriceWithCurrency price=$rm_v['avg_paid_unit_price_tax_incl'] currency=$currency}
{else}
-
+
{displayWtPriceWithCurrency price=$rm_v['product_price_without_reduction_tax_excl'] currency=$currency}
-
- {displayWtPriceWithCurrency price=$rm_v['paid_unit_price_tax_excl'] currency=$currency}
+
+ {displayWtPriceWithCurrency price=$rm_v['avg_paid_unit_price_tax_excl'] currency=$currency}
{/if}
|