Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed ilo mapping with cross ref #230

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions python/form_handler/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import datetime
from minio import Minio
from minio.error import S3Error
from python.form_handler.models import Event,FormStorageRefs,VIForm,TwentyFourHourForm,TwelveHourForm,IRPForm,User,AgencyCrossref,CityCrossRef,JurisdictionCrossRef,ImpoundReasonCodes
from python.form_handler.models import Event,FormStorageRefs,VIForm,TwentyFourHourForm,TwelveHourForm,IRPForm,User,AgencyCrossref,CityCrossRef,JurisdictionCrossRef,ImpoundReasonCodes,IloIdCrossRef,ImpoundLotOperator
from python.form_handler.icbc_service import submit_to_icbc
from python.form_handler.vips_service import create_vips_doc,create_vips_imp
from python.form_handler.payloads import vips_payload,vips_document_payload
Expand Down Expand Up @@ -607,7 +607,35 @@ def prep_vips_payload(**args)->tuple:
if "driver_jurisdiction" in event_data: tmp_payload["vipsImpoundCreate"]["dlJurisdictionCd"]=event_data["driver_jurisdiction"]
if "driver_licence_no" in event_data: tmp_payload["vipsImpoundCreate"]["driverLicenceNo"]=event_data["driver_licence_no"]

tmp_payload["vipsImpoundCreate"]["impoundLotOperatorId"]=None

# get ilo id from db
tmp_ilo_id=None
ilo_id_from_db=event_data.get("impound_lot_operator",None)
if ilo_id_from_db:
with application.app_context():
ilo_data_db = db.session.query(ImpoundLotOperator) \
.filter(ImpoundLotOperator.id == ilo_id_from_db) \
.all()
if len(ilo_data_db) == 0:
logging.error("ilo db data not found")
else:
for i in ilo_data_db:
ilo_dict = i.__dict__
ilo_dict.pop('_sa_instance_state', None)
tmp_ilo_name=ilo_dict["name"]
ilo_cross_ref = db.session.query(IloIdCrossRef) \
.filter(IloIdCrossRef.ilo_name == tmp_ilo_name) \
.all()
if len(ilo_cross_ref) == 0:
logging.error("ilo cross ref data not found")
else:
for c in ilo_cross_ref:
ilo_cross_ref_dict = c.__dict__
ilo_cross_ref_dict.pop('_sa_instance_state', None)
tmp_ilo_id=ilo_cross_ref_dict["vips_impound_lot_operator_id"]
break
break
tmp_payload["vipsImpoundCreate"]["impoundLotOperatorId"]=tmp_ilo_id

# convert impoundment_dt to string
impoundment_dt=form_data.get("date_of_impound")
Expand All @@ -626,7 +654,7 @@ def prep_vips_payload(**args)->tuple:
tmp_payload["vipsImpoundCreate"]["noticeSubjectCd"]="VEHI"

# get reason codes from DB
# TODO: Check the reason list
# DONE: Check the reason list
reason_list=[]
payload_reason_list=[]
excessive_speeding=form_data.get("excessive_speed",False)
Expand Down Expand Up @@ -657,8 +685,6 @@ def prep_vips_payload(**args)->tuple:
reason_list.append("BACWARN3")
with application.app_context():
# get reason data
policeDetatchmentId=''
agency_name=''
for v in reason_list:
reason_data = db.session.query(ImpoundReasonCodes) \
.filter(ImpoundReasonCodes.df_unique_code == v) \
Expand Down
10 changes: 10 additions & 0 deletions python/form_handler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,15 @@ class ImpoundReasonCodes(db.Model):
vips_value_cd = db.Column(db.String)
vips_value_dsc = db.Column(db.String)
vips_value_abbreviated_dsc = db.Column(db.String)

@dataclass
class IloIdCrossRef(db.Model):
__tablename__ = 'ilo_cross_ref'

ilo_name: str
vips_impound_lot_operator_id: int

ilo_name = db.Column(db.String, primary_key=True)
vips_impound_lot_operator_id = db.Column(db.Integer)


32 changes: 32 additions & 0 deletions python/prohibition_web_svc/migrations/versions/237614f969cf_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""empty message

Revision ID: 237614f969cf
Revises: b4b054d65515
Create Date: 2023-12-02 14:47:40.537260

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '237614f969cf'
down_revision = 'b4b054d65515'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('ilo_cross_ref',
sa.Column('ilo_name', sa.String(), nullable=False),
sa.Column('vips_impound_lot_operator_id', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('ilo_name')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('ilo_cross_ref')
# ### end Alembic commands ###
10 changes: 10 additions & 0 deletions python/prohibition_web_svc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,15 @@ class ImpoundReasonCodes(db.Model):
vips_value_cd = db.Column(db.String)
vips_value_dsc = db.Column(db.String)
vips_value_abbreviated_dsc = db.Column(db.String)

@dataclass
class IloIdCrossRef(db.Model):
__tablename__ = 'ilo_cross_ref'

ilo_name: str
vips_impound_lot_operator_id: int

ilo_name = db.Column(db.String, primary_key=True)
vips_impound_lot_operator_id = db.Column(db.Integer)


10 changes: 10 additions & 0 deletions python/task_scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,15 @@ class ImpoundReasonCodes(db.Model):
vips_value_cd = db.Column(db.String)
vips_value_dsc = db.Column(db.String)
vips_value_abbreviated_dsc = db.Column(db.String)

@dataclass
class IloIdCrossRef(db.Model):
__tablename__ = 'ilo_cross_ref'

ilo_name: str
vips_impound_lot_operator_id: int

ilo_name = db.Column(db.String, primary_key=True)
vips_impound_lot_operator_id = db.Column(db.Integer)


Loading