From 712c5661ec44e83ec045f9ac493ffd3eb51d40c0 Mon Sep 17 00:00:00 2001 From: JustinMacaulay Date: Tue, 19 Dec 2023 13:00:54 -0800 Subject: [PATCH] icbc plate jurisdiction fix (#256) --- python/form_handler/actions.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/python/form_handler/actions.py b/python/form_handler/actions.py index a1ed44188..6ff848c99 100644 --- a/python/form_handler/actions.py +++ b/python/form_handler/actions.py @@ -361,8 +361,18 @@ def prep_icbc_payload(**args)->tuple: birthdate= birthdate.strftime('%Y%m%d') tmp_payload["birthdate"]=birthdate - if "vehicle_jurisdiction" in event_data : - tmp_payload["plateJurisdiction"]=event_data["vehicle_jurisdiction"] + if event_data["vehicle_jurisdiction"]: + tmp_jurisdictionvalue=event_data["vehicle_jurisdiction"] + with application.app_context(): + # get jurisdiction data + juris_data = db.session.query(JurisdictionCrossRef) \ + .filter(JurisdictionCrossRef.jurisdiction_code == tmp_jurisdictionvalue) \ + .all() + if len(juris_data) == 0: + logging.error("jurisdiction not found") + tmp_payload["plateJurisdiction"]= '' + else: + tmp_payload["plateJurisdiction"]= juris_data[0].icbc_jurisdiction_code if "vehicle_plate_no" in event_data: tmp_plate_no=event_data["vehicle_plate_no"].upper()