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

Account reg summary add legacy registration indicator. #1803

Merged
merged 2 commits into from
Mar 28, 2024
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
2 changes: 2 additions & 0 deletions mhr_api/src/mhr_api/models/db2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]),
Expand Down
5 changes: 4 additions & 1 deletion mhr_api/src/mhr_api/models/registration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion mhr_api/src/mhr_api/utils/admin_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mhr_api/src/mhr_api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.8.4' # pylint: disable=invalid-name
__version__ = '1.8.5' # pylint: disable=invalid-name
9 changes: 7 additions & 2 deletions mhr_api/tests/unit/models/test_mhr_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mhr_api/tests/unit/utils/test_admin_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions ppr-api/src/ppr_api/models/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ppr-api/src/ppr_api/models/registration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion ppr-api/src/ppr_api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Development release segment: .devN
"""

__version__ = '1.2.3' # pylint: disable=invalid-name
__version__ = '1.2.4' # pylint: disable=invalid-name
2 changes: 2 additions & 0 deletions ppr-api/tests/unit/models/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] == ''
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions ppr-api/tests/unit/models/test_registration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down Expand Up @@ -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'] == ''
Expand Down Expand Up @@ -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':
Expand Down
Loading