diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index 08719bc4f..92ce74054 100644 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -47,6 +47,7 @@ var currency_sign = ''; var currency_blank = false; var priceDisplayPrecision = {$smarty.const._PS_PRICE_DISPLAY_PRECISION_|intval}; + var current_order_total = {$order_total|floatval}; $(document).ready(function() { $(document).on('change', '#add_new_room_services_form select[name="price_calculation_type"]', function() { @@ -718,6 +719,10 @@ updateCartLine(response.curr_booking_info, cart_row); updateCartSummaryData(response.cart_info); updateCartVouchers(response.cart_info.summary.discounts); + var $totalTaxesTrigger = $('#total_taxes').closest('.data-focus').find('.ui-tooltip-trigger'); + initUITooltip($totalTaxesTrigger, function() { + return $totalTaxesTrigger.next('.tooltip-content').html(); + }); } }); } @@ -782,9 +787,8 @@ $('#total_taxes_tourism').html(formatCurrency(totalTaxesTourismAmt, currency_format, currency_sign, currency_blank)); $('#total_with_taxes').html(formatCurrency(parseFloat(jsonSummary.summary.total_price), currency_format, currency_sign, currency_blank)); - if (parseInt($('input[name="is_full_payment"]:checked').val())) { - $('#payment_amount').val(jsonSummary.summary.total_price); - } + current_order_total = parseFloat(jsonSummary.summary.total_price); + $('#payment_amount').val(jsonSummary.summary.total_price); $('#full_payment_amount_value').html(formatCurrency(parseFloat(jsonSummary.summary.total_price), currency_format, currency_sign, currency_blank)); if (jsonSummary.summary.is_advance_payment_active) { @@ -1322,9 +1326,8 @@ } $('#order_message').val(jsonSummary.order_message); $('#payment_amount').siblings('.input-group-addon').html(currency_sign); - if (parseInt($('input[name="is_full_payment"]:checked').val())) { - $('#payment_amount').val(jsonSummary.summary.total_price); - } + current_order_total = parseFloat(jsonSummary.summary.total_price); + $('#payment_amount').val(jsonSummary.summary.total_price); $('#full_payment_amount_value').html(formatCurrency(parseFloat(jsonSummary.summary.total_price), currency_format, currency_sign, currency_blank)); if (jsonSummary.summary.is_advance_payment_active) { @@ -1671,12 +1674,12 @@ $(document).on('change', 'input[name="is_full_payment"]', function() { if (parseInt($('input[name="is_full_payment"]:checked').val())) { - $('#payment_amount').val({$order_total|floatval}).attr('disabled', true); + $('#payment_amount').val(current_order_total).attr('disabled', true); $('#payment_amount').closest('.form-group').hide(200); $('#payment_type, #payment_module_name, #payment_transaction_id').closest('.form-group').show(200); } else { - $('#payment_amount').val({$order_total|floatval}).attr('disabled', false); + $('#payment_amount').val(current_order_total).attr('disabled', false); $('#payment_amount').closest('.form-group').show(200); managePaymentOptions(); diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 7a2018188..edc82ddfc 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -233,15 +233,17 @@ abstract class PaymentModuleCore extends Module $full_cart_total = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), _PS_PRICE_COMPUTE_PRECISION_); $amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, _PS_PRICE_COMPUTE_PRECISION_) : $amount_paid; + $is_advance_payment = false; if ($amount_paid >= $full_cart_total) { - $is_advance_payment = false; $cart_total_paid = $full_cart_total; - } else { + } elseif ($this->context->cart->is_advance_payment) { $is_advance_payment = true; $cart_total_paid = (float)Tools::ps_round( (float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT), _PS_PRICE_COMPUTE_PRECISION_ ); + } else { + $cart_total_paid = $full_cart_total; } foreach ($cart_delivery_option as $id_address => $key_carriers) { diff --git a/classes/Product.php b/classes/Product.php index a6c3d67b2..956c39bdf 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -6865,6 +6865,13 @@ class ProductCore extends ObjectModel $price = $price * $quantity; + if (!$specificPrice || ($specificPrice['id_cart'] == 0 && $specificPrice['id_htl_cart_booking'] == 0)) { + if (!$idGroup || !Validate::isLoadedObject(new Group((int)$idGroup))) { + $idGroup = (int)Group::getCurrent()->id; + } + $price = Product::applyGroupDiscount($price, $idProduct, $idGroup); + } + $tourismTaxHotelId = $idHotel; if (!$tourismTaxHotelId && $idProductRoomType) { $objRoomType = new HotelRoomType(); @@ -6906,12 +6913,6 @@ class ProductCore extends ObjectModel ); } - if (!$specificPrice || ($specificPrice['id_cart'] == 0 && $specificPrice['id_htl_cart_booking'] == 0)) { - if (!$idGroup || !Validate::isLoadedObject(new Group((int)$idGroup))) { - $idGroup = (int)Group::getCurrent()->id; - } - $price = Product::applyGroupDiscount($price, $idProduct, $idGroup); - } return $price; } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b9c788ebd..66142204b 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3084,6 +3084,8 @@ class AdminOrdersControllerCore extends AdminController $initialPaymentStatus = $this->l('Full Payment'); } elseif (isset($orderHistory[0]['id_order_state']) && ($orderHistory[0]['id_order_state'] == Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED'))) { $initialPaymentStatus = $this->l('Partial Payment'); + } elseif (isset($orderHistory[0]['id_order_state']) && ($orderHistory[0]['id_order_state'] == Configuration::get('PS_OS_ERROR'))) { + $initialPaymentStatus = $this->l('Payment Error'); } else { $initialPaymentStatus = $this->l('No Payment Received'); } @@ -3091,7 +3093,7 @@ class AdminOrdersControllerCore extends AdminController $helper->icon = 'icon-home'; $helper->color = 'color3'; $helper->title = $this->l('Initial Payment Status'); - $helper->tooltip = $this->l('Initial Payment Status defines whether the order was fully paid, partially paid, or had no payment received at the time the order was placed.'); + $helper->tooltip = $this->l('Initial Payment Status defines whether the order was fully paid, partially paid, had a payment error, or had no payment received at the time the order was placed.'); $helper->value = $initialPaymentStatus; $this->kpis[] = $helper; @@ -5810,6 +5812,11 @@ class AdminOrdersControllerCore extends AdminController } } + // VAT scoping and tourism tax rows of the new room(s) exist only now, so refresh invoice totals again + if (isset($order_invoice) && Validate::isLoadedObject($order_invoice)) { + $order_invoice->recomputeTotalsFromLines(); + } + $order->total_paid = $order->getOrderTotal(); $order->total_paid_tax_incl = $order->total_paid; $order->total_paid_tax_excl = $order->getOrderTotal(false); diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index edb46552d..dad6fe65a 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -417,6 +417,10 @@ class Blockcart extends Module if ($useTax && TaxConfiguration::isGrossedUp($tourismTaxRoom)) { $totalRoomsPrice += $tourismTaxRoom; } + $tourismTaxService = (float) $tourismTaxTotals['tourism_tax_service']; + if ($useTax && TaxConfiguration::isGrossedUp($tourismTaxService)) { + $totalAdditionalServicesWithoutAutoAddPrice += $tourismTaxService; + } if ($useTax && TaxConfiguration::isGrossedUp($tourismTaxConvenienceFee)) { $totalConvenienceFee += $tourismTaxConvenienceFee; } diff --git a/modules/qlohotelreview/classes/QhrHotelReviewHelper.php b/modules/qlohotelreview/classes/QhrHotelReviewHelper.php index bced1479c..4399cab73 100644 --- a/modules/qlohotelreview/classes/QhrHotelReviewHelper.php +++ b/modules/qlohotelreview/classes/QhrHotelReviewHelper.php @@ -29,6 +29,16 @@ class QhrHotelReviewHelper return false; } + // At least one room must be actually checked out, otherwise an order with all rooms cancelled would count as checked out + if (!Db::getInstance()->getValue( + 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_OUT.' + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_order` = '.(int) $idOrder + )) { + return false; + } + return (bool) !Db::getInstance()->getValue( 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_OUT.' @@ -73,9 +83,11 @@ class QhrHotelReviewHelper $maxDate = Db::getInstance()->getValue( 'SELECT MAX(DATE(hbd.`date_to`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`id_order` = '.(int) $idOrder + WHERE hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CANCELLED.' + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_order` = '.(int) $idOrder ); - return date('Y-m-d') >= $maxDate; + return $maxDate && date('Y-m-d') >= $maxDate; } public static function sendReviewRequestMail($idOrder) diff --git a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl index e84dbb689..c187ce54a 100644 --- a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl +++ b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl @@ -46,7 +46,7 @@ {assign var=countRoom value=1} {foreach from=$occupancies key=key item=$occupancy name=occupancyInfo}
-
{$room_type_info['selling_object_name']|escape:'htmlall':'UTF-8'} - {$countRoom|escape:'htmlall':'UTF-8'} {if !$smarty.foreach.occupancyInfo.first}{l s='Remove'}{/if}
+
{$room_type_info['selling_object_name']|escape:'htmlall':'UTF-8'} - {$countRoom|escape:'htmlall':'UTF-8'} {if !$smarty.foreach.occupancyInfo.first}{l s='Remove'}{/if}