[IMP]14.0-pms_api_rest: added new folio filters in get_folios

This commit is contained in:
braisab
2024-02-05 18:59:17 +01:00
committed by Darío Lodeiros
parent fa454c234a
commit b602f1fe41
2 changed files with 58 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ class PmsDashboardServices(Component):
dateFrom = fields.Date.from_string(pms_dashboard_search_param.dateFrom)
dateTo = fields.Date.from_string(pms_dashboard_search_param.dateTo)
# If you modify this SQL you must modify the get_folios service in pms_folio_service.py
self.env.cr.execute(
"""
SELECT

View File

@@ -150,7 +150,63 @@ class PmsFolioService(Component):
]
domain_filter.append(expression.OR(subdomains))
if folio_search_param.filterByState:
if folio_search_param.filterByState == "byCheckin":
if folio_search_param.filterByState == "checkinYesterday":
subdomains = [
[("state", "in", ("confirm", "arrival_delayed"))],
[("checkin", "=", fields.Date.today() - timedelta(days=1))],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "pendingCheckinToday":
subdomains = [
[("state", "in", ("confirm", "arrival_delayed"))],
[("checkin", "=", fields.Date.today())],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "completedCheckinsToday":
subdomains = [
[("state", "=", "onboard")],
[("checkin", "=", fields.Date.today())],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "pendingCheckinsTomorrow":
subdomains = [
[("state", "=", "confirm")],
[("checkin", "=", fields.Date.today() + timedelta(days=1))],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "pendingCheckoutsToday":
subdomains = [
[("state", "in", ("onboard", "departure_delayed"))],
[("checkout", "=", fields.Date.today())],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "pendingCheckoutsTomorrow":
subdomains = [
[("state", "in", ("onboard", "departure_delayed"))],
[("checkout", "=", fields.Date.today() + timedelta(days=1))],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "completedCheckoutsToday":
subdomains = [
[("state", "=", "done")],
[("checkout", "=", fields.Date.today())],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "completedCheckoutsTomorrow":
subdomains = [
[("state", "=", "done")],
[("checkout", "=", fields.Date.today() + timedelta(days=1))],
[("reservation_type", "!=", "out")],
]
domain_filter.append(expression.AND(subdomains))
elif folio_search_param.filterByState == "byCheckin":
subdomains = [
[("state", "in", ("confirm", "arrival_delayed"))],
[("checkin", "<=", fields.Date.today())],