mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms-api-rest: add free rooms by type @ calendar pricelist and rules service
This commit is contained in:
committed by
Darío Lodeiros
parent
5f30373953
commit
f5316c3fba
@@ -419,7 +419,22 @@ class PmsCalendarService(Component):
|
||||
AND ipp.record = pp.product_tmpl_id
|
||||
AND ipp.pms_property_id = %s
|
||||
)
|
||||
) price
|
||||
) price,
|
||||
(SELECT COUNT (1)
|
||||
FROM pms_room r
|
||||
WHERE r.room_type_id = dr.room_type_id AND r.active = true AND r.pms_property_id = 1
|
||||
AND NOT EXISTS (SELECT 1
|
||||
FROM pms_reservation_line
|
||||
WHERE date = dr.date
|
||||
AND occupies_availability = true
|
||||
AND room_id = r.id
|
||||
AND r.is_shared_room = false)
|
||||
AND EXISTS (SELECT 1
|
||||
FROM pms_room
|
||||
WHERE active = true
|
||||
AND room_type_id = dr.room_type_id
|
||||
AND pms_property_id = %s)
|
||||
) free_rooms
|
||||
FROM
|
||||
(
|
||||
SELECT dates.date, rt_r.room_type_id, rt_r.product_id, rt_r.default_max_avail, rt_r.default_quota
|
||||
@@ -436,7 +451,9 @@ class PmsCalendarService(Component):
|
||||
FROM pms_room_type rt
|
||||
WHERE EXISTS ( SELECT 1
|
||||
FROM pms_room
|
||||
WHERE pms_property_id = %s AND room_type_id = rt.id)
|
||||
WHERE pms_property_id = %s
|
||||
AND room_type_id = rt.id
|
||||
AND active = true)
|
||||
) rt_r
|
||||
) dr
|
||||
INNER JOIN product_product pp ON pp.id = dr.product_id
|
||||
@@ -452,6 +469,7 @@ class PmsCalendarService(Component):
|
||||
ORDER BY dr.room_type_id, dr.date;
|
||||
""",
|
||||
(
|
||||
calendar_search_param.pmsPropertyId,
|
||||
calendar_search_param.pmsPropertyId,
|
||||
date_from,
|
||||
date_to,
|
||||
@@ -468,6 +486,7 @@ class PmsCalendarService(Component):
|
||||
for index, item in enumerate(result):
|
||||
date = {
|
||||
"date": datetime.combine(item['date'], datetime.min.time()).isoformat(),
|
||||
"freeRooms": item['free_rooms'],
|
||||
"pricelistItemId": item['pricelist_item_id'],
|
||||
"price": item['price'],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user