From b602f1fe411337a12734da980f27907447d10c49 Mon Sep 17 00:00:00 2001 From: braisab Date: Mon, 5 Feb 2024 18:59:17 +0100 Subject: [PATCH] [IMP]14.0-pms_api_rest: added new folio filters in get_folios --- .../services/pms_dashboard_service.py | 1 + pms_api_rest/services/pms_folio_service.py | 58 ++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/pms_api_rest/services/pms_dashboard_service.py b/pms_api_rest/services/pms_dashboard_service.py index 34966cf11..f4ea451de 100644 --- a/pms_api_rest/services/pms_dashboard_service.py +++ b/pms_api_rest/services/pms_dashboard_service.py @@ -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 diff --git a/pms_api_rest/services/pms_folio_service.py b/pms_api_rest/services/pms_folio_service.py index 3ce6a51cc..afca0ed68 100644 --- a/pms_api_rest/services/pms_folio_service.py +++ b/pms_api_rest/services/pms_folio_service.py @@ -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())],