fixed multiple order and refund related bugs

This commit is contained in:
azhar bhat
2026-10-26 13:17:15 +05:30
parent 10251e3591
commit ce7960ab60
7 changed files with 49 additions and 20 deletions

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -46,7 +46,7 @@
{assign var=countRoom value=1}
{foreach from=$occupancies key=key item=$occupancy name=occupancyInfo}
<div class="occupancy_info_block selected" occ_block_index="{$key|escape:'htmlall':'UTF-8'}">
<div class="occupancy_info_head"><span class="room_num_wrapper">{$room_type_info['selling_object_name']|escape:'htmlall':'UTF-8'} - {$countRoom|escape:'htmlall':'UTF-8'} </span>{if !$smarty.foreach.occupancyInfo.first}<a class="remove-stay-link pull-right" href="#">{l s='Remove'}</a>{/if}</div>
<div class="occupancy_info_head"><span class="room_num_wrapper">{$room_type_info['selling_object_name']|escape:'htmlall':'UTF-8'} - {$countRoom|escape:'htmlall':'UTF-8'} </span>{if !$smarty.foreach.occupancyInfo.first}<a class="remove-room-link pull-right" href="#">{l s='Remove'}</a>{/if}</div>
<div class="row">
<div class="form-group col-sm-5 col-xs-6 occupancy_count_block">
<div class="row">