From 51527ce6d375104006a53ff0dffed89409bb428c Mon Sep 17 00:00:00 2001 From: Doug Lovett Date: Tue, 1 Oct 2024 08:34:56 -0700 Subject: [PATCH] MHR API bug fixes remove registration, permit move back to BC. (#2029) Signed-off-by: Doug Lovett --- mhr_api/src/mhr_api/models/mhr_registration.py | 2 +- mhr_api/src/mhr_api/models/queries.py | 8 ++++++-- mhr_api/src/mhr_api/version.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mhr_api/src/mhr_api/models/mhr_registration.py b/mhr_api/src/mhr_api/models/mhr_registration.py index 37db495e9..f803937c2 100755 --- a/mhr_api/src/mhr_api/models/mhr_registration.py +++ b/mhr_api/src/mhr_api/models/mhr_registration.py @@ -362,7 +362,7 @@ def save_permit(self, json_data, new_reg_id): json_data.get('location') and json_data['location']['address']['region'] == model_utils.PROVINCE_BC: self.status_type = MhrRegistrationStatusTypes.ACTIVE current_app.logger.info('Cancel Transport Permit new location in BC, updating EXEMPT status to ACTIVE.') - elif json_data and json_data.get('documentType') == MhrDocumentTypes.AMEND_PERMIT and \ + elif json_data and json_data.get('amendment') and \ self.status_type == MhrRegistrationStatusTypes.EXEMPT and \ json_data['newLocation']['address']['region'] == model_utils.PROVINCE_BC: self.status_type = MhrRegistrationStatusTypes.ACTIVE diff --git a/mhr_api/src/mhr_api/models/queries.py b/mhr_api/src/mhr_api/models/queries.py index 72e653411..12d3fc3f0 100644 --- a/mhr_api/src/mhr_api/models/queries.py +++ b/mhr_api/src/mhr_api/models/queries.py @@ -136,9 +136,13 @@ SELECT DISTINCT mr.mhr_number FROM mhr_registrations mr WHERE account_id = :query_value1 - AND mr.registration_type IN ('MHREG', 'MHREG_CONVERSION'))) + AND mr.registration_type IN ('MHREG', 'MHREG_CONVERSION') + AND NOT EXISTS (SELECT mer.id + FROM mhr_extra_registrations mer + WHERE mer.account_id = mr.account_id + AND mer.mhr_number = mr.mhr_number + AND mer.removed_ind = 'Y'))) """ - REG_ORDER_BY_DATE = ' ORDER BY registration_ts DESC' REG_ORDER_BY_MHR_NUMBER = ' ORDER BY mhr_number' REG_ORDER_BY_REG_TYPE = ' ORDER BY document_type' diff --git a/mhr_api/src/mhr_api/version.py b/mhr_api/src/mhr_api/version.py index 4892ddd1e..f0136d15d 100644 --- a/mhr_api/src/mhr_api/version.py +++ b/mhr_api/src/mhr_api/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.8.23' # pylint: disable=invalid-name +__version__ = '1.8.24' # pylint: disable=invalid-name