diff --git a/mhr_api/src/mhr_api/models/db2/utils.py b/mhr_api/src/mhr_api/models/db2/utils.py index c22b0f955..5b4ed1290 100755 --- a/mhr_api/src/mhr_api/models/db2/utils.py +++ b/mhr_api/src/mhr_api/models/db2/utils.py @@ -609,6 +609,7 @@ def __update_summary_info(result, results, reg_summary_list, staff, account_id): else: result['registrationDescription'] = summary_result.get('reg_description') # result['username'] = summary_result.get('username') # Sorting by username does not work with this. + result['legacy'] = False if staff or account_id == summary_result.get('account_id'): if summary_result.get('report_url') or model_utils.report_retry_elapsed(summary_result.get('report_ts')): if summary_result.get('registration_type') == MhrRegistrationTypes.MHREG: @@ -648,6 +649,7 @@ def __build_summary(row, add_in_user_list: bool = True, mhr_list=None): 'clientReferenceId': str(row[4]), 'ownerNames': owner_names, 'path': '', + 'legacy': True, 'documentId': str(row[8]), 'documentRegistrationNumber': str(row[9]), 'documentType': str(row[5]), diff --git a/mhr_api/src/mhr_api/models/registration_utils.py b/mhr_api/src/mhr_api/models/registration_utils.py index f43aa4277..b9b3e04de 100644 --- a/mhr_api/src/mhr_api/models/registration_utils.py +++ b/mhr_api/src/mhr_api/models/registration_utils.py @@ -783,7 +783,10 @@ def __get_report_path(account_id: str, staff: bool, summary: dict, row, timestam reg_account_id: str = str(row[15]) doc_storage_url: str = str(row[19]) if row[19] else '' rep_count: int = int(row[24]) - if rep_count > 0 and (staff or account_id == reg_account_id) and \ + summary['legacy'] = rep_count <= 0 + # To be consistent with PPR, allow registries staff to generate reports for legacy registrations + # if rep_count > 0 and (staff or account_id == reg_account_id) and \ + if (staff or (rep_count > 0 and account_id == reg_account_id)) and \ (doc_storage_url or model_utils.report_retry_elapsed(timestamp)): if summary['registrationType'] in (MhrRegistrationTypes.MHREG, MhrRegistrationTypes.MHREG_CONVERSION): summary['path'] = REGISTRATION_PATH + summary.get('mhrNumber') diff --git a/mhr_api/src/mhr_api/utils/admin_validator.py b/mhr_api/src/mhr_api/utils/admin_validator.py index 2436b1e52..db9aead3c 100644 --- a/mhr_api/src/mhr_api/utils/admin_validator.py +++ b/mhr_api/src/mhr_api/utils/admin_validator.py @@ -199,7 +199,8 @@ def validate_location(registration: MhrRegistration, json_data, required: bool) location = json_data.get('location') error_msg += validator_utils.validate_location(location) error_msg += validator_utils.validate_location_different(current_location, location) - error_msg += validator_utils.validate_tax_certificate(location, current_location, True) + if json_data.get('documentType', '') == MhrDocumentTypes.STAT: + error_msg += validator_utils.validate_tax_certificate(location, current_location, True) if location.get('pidNumber'): error_msg += validator_utils.validate_pid(location.get('pidNumber')) return error_msg diff --git a/mhr_api/src/mhr_api/version.py b/mhr_api/src/mhr_api/version.py index dc6767782..94ba49a15 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.4' # pylint: disable=invalid-name +__version__ = '1.8.5' # pylint: disable=invalid-name diff --git a/mhr_api/tests/unit/models/test_mhr_registration.py b/mhr_api/tests/unit/models/test_mhr_registration.py index 5d0133523..71e4e7c8b 100755 --- a/mhr_api/tests/unit/models/test_mhr_registration.py +++ b/mhr_api/tests/unit/models/test_mhr_registration.py @@ -456,6 +456,7 @@ def test_find_summary_by_mhr_number(session, account_id, mhr_num, exists, reg_de assert registration['documentId'] is not None assert registration['inUserList'] == in_list assert registration.get('locationType') + assert 'legacy' in registration else: assert not registration @@ -480,12 +481,14 @@ def test_find_summary_by_doc_reg_number(session, account_id, doc_reg_num, mhr_nu assert registration['documentId'] is not None assert registration['inUserList'] == in_list assert registration.get('locationType') + assert 'legacy' in registration if result_count == 1: assert not registration.get('changes') else: assert registration.get('changes') assert len(registration['changes']) >= (result_count - 1) for reg in registration.get('changes'): + assert 'legacy' in reg desc: str = reg['registrationDescription'] if reg.get('registrationType') == MhrRegistrationTypes.REG_NOTE and desc.find('CAUTION') > 0: assert reg.get('expireDays') @@ -515,12 +518,14 @@ def test_find_account_registrations(session, account_id, has_results): assert registration['path'] is not None assert registration['documentId'] is not None assert not registration.get('inUserList') + assert 'legacy' in registration if registration['registrationDescription'] == REG_DESCRIPTION: assert 'lienRegistrationType' in registration assert registration.get('locationType') if registration.get('changes'): for reg in registration.get('changes'): desc: str = reg['registrationDescription'] + assert 'legacy' in reg if reg.get('registrationType') == MhrRegistrationTypes.REG_NOTE and desc.find('CAUTION') > 0: assert reg.get('expireDays') elif reg.get('registrationType') == MhrRegistrationTypes.PERMIT: @@ -1234,6 +1239,8 @@ def test_save_permit(session, mhr_num, user_group, account_id): del json_data['note'] json_data['mhrNumber'] = mhr_num base_reg: MhrRegistration = MhrRegistration.find_by_mhr_number(mhr_num, account_id) + base_reg.current_view = True + current_json = base_reg.new_registration_json assert base_reg if model_utils.is_legacy(): assert base_reg.manuhome @@ -1253,8 +1260,6 @@ def test_save_permit(session, mhr_num, user_group, account_id): draft_new = MhrDraft.find_by_draft_number(registration.draft.draft_number, True) assert draft_new reg_json = registration.new_registration_json - base_reg.current_view = True - current_json = base_reg.new_registration_json batch_json = batch_utils.get_batch_registration_json(registration, reg_json, current_json) assert batch_json assert batch_json.get('documentType') == MhrDocumentTypes.REG_103.value diff --git a/mhr_api/tests/unit/utils/test_admin_validator.py b/mhr_api/tests/unit/utils/test_admin_validator.py index 015faeebc..9c19c09d0 100644 --- a/mhr_api/tests/unit/utils/test_admin_validator.py +++ b/mhr_api/tests/unit/utils/test_admin_validator.py @@ -243,8 +243,7 @@ 'leaveProvince': False, 'parkName': 'GLENDALE TRAILER PARK', 'pad': '2', - 'taxCertificate': True, - 'taxExpiryDate': '2035-01-31T08:00:00+00:00' + 'taxCertificate': False } NOTE_INVALID = { 'documentType': 'PUBA', @@ -404,6 +403,7 @@ # test data pattern is ({valid}, {mhr_num}, {doc_type}, {location}, {desc}, {add_o}, {delete_o}, {message_content}) TEST_AMEND_CORRECT_DATA = [ (True, '000931', 'PUBA', LOCATION_VALID, None, None, None, None), + (True, '000931', 'PUBA', LOCATION_VALID_MINIMAL, None, None, None, None), (True, '000931', 'REGC_STAFF', LOCATION_VALID_MINIMAL, None, None, None, None), (False, '000931', 'REGC_STAFF', LOCATION_000931, None, None, None, validator_utils.LOCATION_INVALID_IDENTICAL), (True, '000931', 'PUBA', None, DESCRIPTION, None, None, None), diff --git a/ppr-api/src/ppr_api/models/registration.py b/ppr-api/src/ppr_api/models/registration.py index dc659f506..1dcae433c 100644 --- a/ppr-api/src/ppr_api/models/registration.py +++ b/ppr-api/src/ppr_api/models/registration.py @@ -475,6 +475,7 @@ def find_all_by_account_id(cls, params: AccountRegistrationParams, new_feature_e 'clientReferenceId': str(row[12]), 'registeringName': registering_name } + result['legacy'] = result.get('accountId') == '0' result = registration_utils.set_path(params, result, reg_num, base_reg_num) if result['statusType'] == model_utils.STATE_ACTIVE and result['expireDays'] < 0 \ @@ -572,6 +573,7 @@ def find_summary_by_reg_num(cls, account_id: str, registration_num: str, account 'accountId': str(row[14]), 'vehicleCount': int(row[16]) } + result['legacy'] = result.get('accountId') == '0' if model_utils.is_financing(reg_class): result['baseRegistrationNumber'] = reg_num result['path'] = FINANCING_PATH + reg_num diff --git a/ppr-api/src/ppr_api/models/registration_utils.py b/ppr-api/src/ppr_api/models/registration_utils.py index d3b3bfa9b..318f74d2f 100644 --- a/ppr-api/src/ppr_api/models/registration_utils.py +++ b/ppr-api/src/ppr_api/models/registration_utils.py @@ -398,6 +398,7 @@ def __build_account_reg_result(params, row, reg_class, api_filter: bool = False) } if not api_filter: result['vehicleCount'] = int(row[16]) + result['legacy'] = result.get('accountId') == '0' if model_utils.is_financing(reg_class) and not api_filter: result['expand'] = False result = set_path(params, result, reg_num, base_reg_num, int(row[15])) diff --git a/ppr-api/src/ppr_api/version.py b/ppr-api/src/ppr_api/version.py index 4efb53dde..c3b30d405 100644 --- a/ppr-api/src/ppr_api/version.py +++ b/ppr-api/src/ppr_api/version.py @@ -22,4 +22,4 @@ Development release segment: .devN """ -__version__ = '1.2.3' # pylint: disable=invalid-name +__version__ = '1.2.4' # pylint: disable=invalid-name diff --git a/ppr-api/tests/unit/models/test_registration.py b/ppr-api/tests/unit/models/test_registration.py index 4758cb47b..12a4bfb2f 100644 --- a/ppr-api/tests/unit/models/test_registration.py +++ b/ppr-api/tests/unit/models/test_registration.py @@ -353,6 +353,7 @@ def test_find_all_by_account_id(session, desc, account_id, collapse, user_added_ assert statement['statusType'] assert statement['createDateTime'] assert statement['lastUpdateDateTime'] + assert 'legacy' in statement if statement['registrationNumber'] == ('TEST0016'): assert statement['registeringName'] == '' assert statement['clientReferenceId'] == '' @@ -405,6 +406,7 @@ def test_find_summary_by_reg_num(session, reg_num, account_id, result_count, exi assert registration['baseRegistrationNumber'] == reg_num assert registration['existsCount'] == exist_count assert registration['inUserList'] == in_user_list + assert 'legacy' in registration assert 'vehicleCount' in registration assert registration['vehicleCount'] >= 0 if change_count == 0: diff --git a/ppr-api/tests/unit/models/test_registration_utils.py b/ppr-api/tests/unit/models/test_registration_utils.py index 97c22a6c3..f186f46d2 100644 --- a/ppr-api/tests/unit/models/test_registration_utils.py +++ b/ppr-api/tests/unit/models/test_registration_utils.py @@ -330,6 +330,7 @@ def test_find_all_by_account_id_filter(session, reg_num, reg_type, client_ref, r assert change['registeringName'] assert change['clientReferenceId'] assert 'path' in change + assert 'legacy' in change #if change['baseRegistrationNumber'] in ('TEST0019', 'TEST0021'): # assert not change['path'] #elif change.get('registrationNumber', '') in ('TEST00D4', 'TEST00R5', 'TEST0007'): @@ -365,6 +366,7 @@ def test_find_all_by_account_id_api_filter(session, reg_num, client_ref, start_t assert statement['expireDays'] assert statement['registeringParty'] assert statement['securedParties'] + assert 'legacy' in statement assert 'vehicleCount' not in statement if statement['registrationNumber'] == ('TEST0016'): assert statement['registeringName'] == '' @@ -393,6 +395,7 @@ def test_find_all_by_account_id_api_filter(session, reg_num, client_ref, start_t assert change['registeringName'] assert change['clientReferenceId'] assert 'path' in change + assert 'legacy' in change # if change['baseRegistrationNumber'] in ('TEST0019', 'TEST0021'): # assert not change['path'] # elif change.get('registrationNumber', '') == 'TEST00D4':