diff --git a/classes/order/Order.php b/classes/order/Order.php index c59836651..cca685821 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -3377,7 +3377,8 @@ class OrderCore extends ObjectModel FROM `'._DB_PREFIX_.'orders` o INNER JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`) INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd - ON (hbd.`id_order` = o.`id_order` AND hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0) + ON (hbd.`id_order` = o.`id_order` AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.') LEFT JOIN `'._DB_PREFIX_.'address` a ON (a.`id_customer` = c.`id_customer` AND a.`deleted` = 0 AND a.`id_address` = (SELECT MAX(`id_address`) FROM `'._DB_PREFIX_.'address` diff --git a/classes/order/OrderPayment.php b/classes/order/OrderPayment.php index 8310ad68e..dca742481 100644 --- a/classes/order/OrderPayment.php +++ b/classes/order/OrderPayment.php @@ -188,7 +188,7 @@ class OrderPaymentCore extends ObjectModel INNER JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'currency` cur ON (cur.`id_currency` = op.`id_currency`) INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd - ON (hbd.`id_order` = o.`id_order` AND hbd.`is_cancelled` = 0) + ON (hbd.`id_order` = o.`id_order` AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.') WHERE op.`date_add` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idOrder ? ' AND o.`id_order` = '.$idOrder : '') .($idCustomer ? ' AND o.`id_customer` = '.$idCustomer : '') @@ -213,7 +213,7 @@ class OrderPaymentCore extends ObjectModel INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.`reference` = op.`order_reference` AND o.`valid` = 1) INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd - ON (hbd.`id_order` = o.`id_order` AND hbd.`is_cancelled` = 0) + ON (hbd.`id_order` = o.`id_order` AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.') WHERE op.`payment_method` IS NOT NULL AND op.`payment_method` != ""' .HotelBranchInformation::addHotelRestriction($idHotel, 'hbd').' ORDER BY op.`payment_method`' diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 86284feb3..fa032d053 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -3964,8 +3964,8 @@ class HotelBookingDetail extends ObjectModel 'SELECT DATE(o.`date_add`) AS grp_date, IFNULL(SUM(hbd.`total_price_tax_excl` / o.`conversion_rate`), 0) AS total_price_tax_excl, IFNULL(SUM((hbd.`total_price_tax_incl` - hbd.`total_price_tax_excl`) / o.`conversion_rate`), 0) AS total_tax, - SUM(CASE WHEN hbd.`is_refunded` = 0 AND hbd.`is_cancelled` = 0 THEN 1 ELSE 0 END) AS rooms_booked, - SUM(CASE WHEN hbd.`is_refunded` = 0 AND hbd.`is_cancelled` = 0 + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN 1 ELSE 0 END) AS rooms_booked, + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN DATEDIFF(hbd.`date_to`, hbd.`date_from`) ELSE 0 END) AS room_nights FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) @@ -4028,8 +4028,9 @@ class HotelBookingDetail extends ObjectModel FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`) LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) - WHERE p.`active` = 1 AND o.`valid` = 1 AND hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 + WHERE p.`active` = 1 AND o.`valid` = 1 + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND hbd.`date_from` < "'.pSQL($nextDay).' 00:00:00" AND hbd.`date_to` > "'.pSQL($current).' 00:00:00"' .$whereFilters @@ -4066,8 +4067,8 @@ class HotelBookingDetail extends ObjectModel $result[strtotime($current)] = (int) Db::getInstance()->getValue( 'SELECT COUNT(hbd.`id_room`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND hbd.`is_back_order` = 0 AND hbd.`date_from` BETWEEN "'.pSQL($current).' 00:00:00" AND "'.pSQL($current).' 23:59:59"' .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -4103,8 +4104,8 @@ class HotelBookingDetail extends ObjectModel $result[strtotime($current)] = (int) Db::getInstance()->getValue( 'SELECT COUNT(hbd.`id_room`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND hbd.`date_to` BETWEEN "'.pSQL($current).' 00:00:00" AND "'.pSQL($current).' 23:59:59" AND (hbd.`id_status` = '.(int) self::STATUS_CHECKED_IN .' OR (hbd.`check_in` != "0000-00-00 00:00:00" AND hbd.`check_out` != "0000-00-00 00:00:00"))' @@ -4153,7 +4154,7 @@ class HotelBookingDetail extends ObjectModel FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) - WHERE hbd.`is_refunded` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`is_back_order` = 0 AND hbd.`date_from` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .$statusFilter @@ -4191,7 +4192,7 @@ class HotelBookingDetail extends ObjectModel FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) - WHERE hbd.`is_refunded` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`date_to` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($allStatuses ? '' : ' AND hbd.`id_status` = '.$idStatus) .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -4227,7 +4228,7 @@ class HotelBookingDetail extends ObjectModel FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) - WHERE hbd.`is_refunded` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` IN ('.(int) self::STATUS_CHECKED_IN.', '.(int) self::STATUS_CHECKED_OUT.') AND hbd.`date_from` < "'.$dateTo.' 23:59:59" AND hbd.`date_to` > "'.$dateFrom.' 00:00:00"' @@ -4341,17 +4342,17 @@ class HotelBookingDetail extends ObjectModel SELECT hbd.`id_order`, IFNULL(NULLIF(o.`source`, \'\'), \'(direct)\') AS order_source, - SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 THEN 1 ELSE 0 END) AS rooms_booked, - SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN 1 ELSE 0 END) AS rooms_booked, + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN DATEDIFF(hbd.`date_to`, hbd.`date_from`) ELSE 0 END) AS room_nights, - SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN hbd.`total_price_tax_excl` / o.`conversion_rate` ELSE 0 END) AS revenue_excl, - SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 + SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.self::STATUS_CANCELLED.' THEN hbd.`total_price_tax_incl` / o.`conversion_rate` ELSE 0 END) AS revenue_incl, MAX(o.`total_discounts_tax_excl` / o.`conversion_rate`) AS discount_amount, IFNULL(MAX(ord_ref.`refunded_total`), 0) AS refund_amount, COUNT(*) AS total_rooms, - SUM(CASE WHEN hbd.`is_refunded` = 1 THEN 1 ELSE 0 END) AS cancelled_rooms + SUM(CASE WHEN hbd.`id_status` = '.(int) self::STATUS_CANCELLED.' THEN 1 ELSE 0 END) AS cancelled_rooms FROM `'._DB_PREFIX_.'htl_booking_detail` hbd INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order` AND o.`valid` = 1) LEFT JOIN ( @@ -4407,8 +4408,8 @@ class HotelBookingDetail extends ObjectModel IFNULL(SUM(hbd.`total_price_tax_incl` / o.`conversion_rate`), 0) AS revenue_incl FROM `'._DB_PREFIX_.'htl_booking_detail` hbd INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order` AND o.`valid` = 1) - WHERE hbd.`is_cancelled` = 0 - AND hbd.`is_refunded` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND hbd.`date_add` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idCustomer ? ' AND hbd.`id_customer` = '.$idCustomer : '') .($bookingType ? ' AND hbd.`booking_type` = '.$bookingType : '') @@ -4450,7 +4451,7 @@ class HotelBookingDetail extends ObjectModel INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order` AND o.`valid` = 1) INNER JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) INNER JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = hbd.`id_order_detail`) - INNER JOIN `'._DB_PREFIX_.'order_detail_tax` odt ON (odt.`id_order_detail` = od.`id_order_detail`) + INNER JOIN `'._DB_PREFIX_.'order_tax_detail` odt ON (odt.`id_order_detail` = od.`id_order_detail`) INNER JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = odt.`id_tax`) LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (tl.`id_tax` = t.`id_tax` AND tl.`id_lang` = '.(int) $idLang.') WHERE hbd.`date_add` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' @@ -4478,7 +4479,7 @@ class HotelBookingDetail extends ObjectModel /** * Refunded booking rows in a date range, one row per booking (requires ORDER RETURN record). - * QloApps sets is_refunded=1 on all freed/refunded rooms; is_cancelled is not reliably set. + * A booking counts as refunded when it has a completed return (OrderReturn::getRefundedBookingIdsSubquery()). * Refund report filters this further to refunded_amount > 0 in the caller; Cancellation report shows all rows. * * @param array $params date_from, date_to, id_hotel, id_customer, id_product, detailed_info @@ -4528,7 +4529,7 @@ class HotelBookingDetail extends ObjectModel ON (orsl.`id_order_return_state` = orr.`state` AND orsl.`id_lang` = '.(int) $idLang.') LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON (os.`id_order` = orr.`id_order`) - WHERE hbd.`is_refunded` = 1 + WHERE hbd.`id` IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND orr.`date_add` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' . ($idCustomer ? ' AND hbd.`id_customer` = '.$idCustomer : '') . ($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -4615,8 +4616,8 @@ class HotelBookingDetail extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) WHERE p.`active` = 1 AND o.`valid` = 1 - AND hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND o.`invoice_date` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') .($idRoom ? ' AND hbd.`id_room` = '.$idRoom : '') @@ -4683,7 +4684,7 @@ class HotelBookingDetail extends ObjectModel INNER JOIN `'._DB_PREFIX_.'htl_room_information` hri ON (hri.`id` = hbd.`id_room`) INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hri.`id_product`) WHERE p.`active` = 1 - AND hbd.`is_cancelled` = 0 + AND hbd.`id_status` != '.self::STATUS_CANCELLED.' AND hbd.`date_from` < "'.pSQL($dateNext).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateTemp).' 00:00:00"' .$statusFilter diff --git a/modules/hotelreservationsystem/classes/HotelRoomInformation.php b/modules/hotelreservationsystem/classes/HotelRoomInformation.php index 08708b8b1..6866f9581 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomInformation.php +++ b/modules/hotelreservationsystem/classes/HotelRoomInformation.php @@ -373,7 +373,8 @@ class HotelRoomInformation extends ObjectModel 'SELECT hbd.`id_product`, hbd.`id_room`, hbd.`date_from`, hbd.`date_to` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order` AND o.`valid` = 1) - WHERE hbd.`is_refunded` = 0 AND hbd.`is_cancelled` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') + AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.' AND hbd.`date_from` < "'.$dateToNext.'" AND hbd.`date_to` > "'.$dateFrom.'"' .HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd') .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -472,7 +473,7 @@ class HotelRoomInformation extends ObjectModel MIN(hbd.`id_status`) AS `id_status`, MIN(hbd.`id_customer`) AS `id_customer` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`is_refunded` = 0 + WHERE hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`date_from` < "'.$dateToNext.'" AND hbd.`date_to` > "'.$dateFrom.'" GROUP BY hbd.`id_room` ) bkgs ON (bkgs.`id_room` = hri.`id`) diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 0d2e101c8..79518b0c9 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -558,11 +558,11 @@ class HotelRoomType extends ObjectModel FROM `'._DB_PREFIX_.'htl_room_information` r WHERE r.`id_product` = hrt.`id_product` AND r.`id_hotel` = hrt.`id_hotel` ) AS total_rooms, - COUNT(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 THEN hbd.`id` END) AS bookings, - IFNULL(SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 THEN DATEDIFF(hbd.`date_to`, hbd.`date_from`) ELSE 0 END), 0) AS room_nights, - IFNULL(SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 THEN hbd.`total_price_tax_excl` / o.`conversion_rate` ELSE 0 END), 0) AS room_revenue, - IFNULL(SUM(CASE WHEN hbd.`is_cancelled` = 0 AND hbd.`is_refunded` = 0 THEN (hbd.`total_price_tax_incl` - hbd.`total_price_tax_excl`) / o.`conversion_rate` ELSE 0 END), 0) AS tax_amount, - COUNT(CASE WHEN hbd.`is_refunded` = 1 THEN hbd.`id` END) AS cancel_count + COUNT(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.' THEN hbd.`id` END) AS bookings, + IFNULL(SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.' THEN DATEDIFF(hbd.`date_to`, hbd.`date_from`) ELSE 0 END), 0) AS room_nights, + IFNULL(SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.' THEN hbd.`total_price_tax_excl` / o.`conversion_rate` ELSE 0 END), 0) AS room_revenue, + IFNULL(SUM(CASE WHEN hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND hbd.`id_status` != '.HotelBookingDetail::STATUS_CANCELLED.' THEN (hbd.`total_price_tax_incl` - hbd.`total_price_tax_excl`) / o.`conversion_rate` ELSE 0 END), 0) AS tax_amount, + COUNT(CASE WHEN hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CANCELLED.' THEN hbd.`id` END) AS cancel_count FROM `'._DB_PREFIX_.'htl_room_type` hrt INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hrt.`id_product`) INNER JOIN `'._DB_PREFIX_.'product_lang` pl diff --git a/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php index 713045f68..5688202d3 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php @@ -661,7 +661,7 @@ class ServiceProductOrderDetail extends ObjectModel $baseWhere = 'WHERE p.`active` = 1 AND o.`valid` = 1 - AND hbd.`is_refunded` = 0 + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND spod.`is_cancelled` = 0 AND o.`invoice_date` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -714,7 +714,7 @@ class ServiceProductOrderDetail extends ObjectModel $baseWhere = 'WHERE p.`active` = 1 AND o.`valid` = 1 - AND hbd.`is_refunded` = 0 + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND spod.`is_cancelled` = 0 AND o.`invoice_date` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idProduct ? ' AND hbd.`id_product` = '.$idProduct : '') @@ -883,7 +883,7 @@ class ServiceProductOrderDetail extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (tl.`id_tax` = t.`id_tax` AND tl.`id_lang` = '.(int) $idLang.') WHERE spod.`is_cancelled` = 0 - AND hbd.`is_refunded` = 0 + AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().') AND (spod.`total_price_tax_incl` - spod.`total_price_tax_excl`) > 0 AND spod.`date_add` BETWEEN "'.$dateFrom.' 00:00:00" AND "'.$dateTo.' 23:59:59"' .($idTax ? ' AND t.`id_tax` = '.$idTax : '') diff --git a/modules/qlohotelreports/qlohotelreports.php b/modules/qlohotelreports/qlohotelreports.php index 4ed7522ab..3ab175ea6 100644 --- a/modules/qlohotelreports/qlohotelreports.php +++ b/modules/qlohotelreports/qlohotelreports.php @@ -182,7 +182,7 @@ class QloHotelReports extends Module 'filter_booking_type' => $bookingType, 'filter_id_order_state' => $idOrderState, 'booking_statuses' => array( - HotelBookingDetail::STATUS_ALLOTED => $this->l('Allotted'), + HotelBookingDetail::STATUS_ASSIGNED => $this->l('Allotted'), HotelBookingDetail::STATUS_CHECKED_IN => $this->l('Checked In'), HotelBookingDetail::STATUS_CHECKED_OUT => $this->l('Checked Out'), ), @@ -358,7 +358,7 @@ class QloHotelReports extends Module OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT => $this->l('Remote Payment'), ), 'booking_statuses' => array( - HotelBookingDetail::STATUS_ALLOTED => $this->l('Allotted'), + HotelBookingDetail::STATUS_ASSIGNED => $this->l('Allotted'), HotelBookingDetail::STATUS_CHECKED_IN => $this->l('Checked In'), HotelBookingDetail::STATUS_CHECKED_OUT => $this->l('Checked Out'), ), @@ -573,7 +573,7 @@ class QloHotelReports extends Module if ($report === 'occupancy') { $dailyOccupied = HotelBookingDetail::getDatewiseOccupiedRooms($baseParams); $dailyBooked = HotelBookingDetail::getDatewiseOccupiedRooms( - array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_ALLOTED)) + array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_ASSIGNED)) ); $dailyCheckedIn = HotelBookingDetail::getDatewiseOccupiedRooms( array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_CHECKED_IN)) @@ -918,7 +918,7 @@ class QloHotelReports extends Module 'bookings' => $bookings, 'cancellations' => $cancels, 'cancel_rate_pct' => $bookings > 0 ? round($cancels / $bookings * 100, 1) : 0.0, - 'avg_los' => ($bookings > 0 && $roomNights > 0) ? round($roomNights / $bookings, 1) : 0.0, + 'avg_los' => ($bookings > 0 && $roomNights > 0) ? max(1, round($roomNights / $bookings, 1)) : 0.0, 'outstanding_balance' => $obRows ? array_sum(array_column($obRows, 'balance_due')) : 0.0, ); } @@ -1100,7 +1100,7 @@ class QloHotelReports extends Module $this->attachCurrencyToRows($rows, $csvCurrencyMap, $defaultCurrency->iso_code); $statusLabels = array( - HotelBookingDetail::STATUS_ALLOTED => $this->l('Allotted'), + HotelBookingDetail::STATUS_ASSIGNED => $this->l('Allotted'), HotelBookingDetail::STATUS_CHECKED_IN => $this->l('Checked In'), HotelBookingDetail::STATUS_CHECKED_OUT => $this->l('Checked Out'), ); @@ -1478,7 +1478,7 @@ class QloHotelReports extends Module $totalRoomsOcc = (int) AdminStatsController::getTotalRooms($idHotel ?: null, 1, $idProduct ?: null); $dailyAllOcc = HotelBookingDetail::getDatewiseOccupiedRooms($baseParams); $dailyBooked = HotelBookingDetail::getDatewiseOccupiedRooms( - array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_ALLOTED)) + array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_ASSIGNED)) ); $dailyCheckedIn = HotelBookingDetail::getDatewiseOccupiedRooms( array_merge($baseParams, array('id_status' => HotelBookingDetail::STATUS_CHECKED_IN)) @@ -1818,7 +1818,7 @@ class QloHotelReports extends Module $extraRev = (float) ServiceProductOrderDetail::getTotalRevenue($hotelParams); $grossRevenue = $roomRevenue + $extraRev; $occupancy = round(AdminStatsController::getAverageOccupancyRate($dateFrom, $dateTo, (int) $hotel['id']), 1); - $avgLos = ($bookings > 0 && $roomNights > 0) ? round($roomNights / $bookings, 1) : 0.0; + $avgLos = ($bookings > 0 && $roomNights > 0) ? max(1, round($roomNights / $bookings, 1)) : 0.0; $obRows = Order::getOutstandingBalance($hotelParams); $outstanding = is_array($obRows) ? array_sum(array_column($obRows, 'balance_due')) : 0.0; diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index d844af779..688444a51 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -343,10 +343,8 @@ class StatsCheckUp extends Module $totals['total_rooms'] += (int)$scores['total_rooms']; $descriptions = $this->getDescriptions($this->id_hotel ? 'room_type' : 'hotel', $row['id_object']); foreach ($descriptions as $description) { - if (isset($description['iso_code']) && isset($description['description'])) { - $row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description'])); - } if (isset($description['iso_code'])) { + $row['desclength_'.$description['iso_code']] = isset($description['description']) ? Tools::strlen(strip_tags($description['description'])) : 0; $scores['description_'.$description['iso_code']] = ($row['desclength_'.$description['iso_code']] < $confCheckup['DESCRIPTIONS_LT'] ? 0 : ($row['desclength_'.$description['iso_code']] > $confCheckup['DESCRIPTIONS_GT'] ? 2 : 1)); $totals['description_'.$description['iso_code']] += $scores['description_'.$description['iso_code']]; } @@ -584,10 +582,8 @@ class StatsCheckUp extends Module $totals['orders'] += (int)$scores['orders']; $descriptions = $this->getDescriptions('service', $row['id_object']); foreach ($descriptions as $description) { - if (isset($description['iso_code']) && isset($description['description_short'])) { - $row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description_short'])); - } if (isset($description['iso_code'])) { + $row['desclength_'.$description['iso_code']] = isset($description['description_short']) ? Tools::strlen(strip_tags($description['description_short'])) : 0; $scores['description_'.$description['iso_code']] = ($row['desclength_'.$description['iso_code']] < $confCheckup['DESCRIPTIONS_SHORT_LT'] ? 0 : ($row['desclength_'.$description['iso_code']] > $confCheckup['DESCRIPTIONS_SHORT_GT'] ? 2 : 1)); $totals['description_'.$description['iso_code']] += $scores['description_'.$description['iso_code']]; }