Skip to content

Commit

Permalink
Merge branch 'main' into fix/update-notice-of-tax-remark-checkbox-wor…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
RuoxuanPengBC committed Oct 24, 2023
2 parents dec04ed + d09bc07 commit e746137
Show file tree
Hide file tree
Showing 26 changed files with 460 additions and 55 deletions.
4 changes: 3 additions & 1 deletion mhr_api/src/mhr_api/models/registration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,9 @@ def __collapse_results(results):
has_caution: bool = False
changes = []
for result in results:
if result['mhrNumber'] == reg['mhrNumber'] and result['registrationType'] != MhrRegistrationTypes.MHREG:
if result['mhrNumber'] == reg['mhrNumber'] and \
result['registrationType'] not in (MhrRegistrationTypes.MHREG,
MhrRegistrationTypes.MHREG_CONVERSION):
if result.get('expireDays') and result.get('expireDays') >= 0:
has_caution = True
changes.append(result)
Expand Down
7 changes: 5 additions & 2 deletions mhr_api/src/mhr_api/utils/admin_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from flask import current_app

from mhr_api.models import MhrRegistration, utils as model_utils, registration_utils as reg_utils
from mhr_api.models.type_tables import MhrDocumentTypes, MhrNoteStatusTypes
from mhr_api.models.type_tables import MhrDocumentTypes, MhrNoteStatusTypes, MhrRegistrationTypes
from mhr_api.models.db2.mhomnote import FROM_LEGACY_STATUS
from mhr_api.models.db2.utils import FROM_LEGACY_DOC_TYPE
from mhr_api.utils import validator_utils
Expand Down Expand Up @@ -55,7 +55,10 @@ def validate_admin_reg(registration: MhrRegistration, json_data) -> str:
doc_type: str = json_data.get('documentType', '')
if not doc_type and json_data.get('note') and json_data['note'].get('documentType'):
doc_type = json_data['note'].get('documentType')
error_msg += validator_utils.validate_registration_state(registration, True, doc_type)
error_msg += validator_utils.validate_registration_state(registration,
True,
MhrRegistrationTypes.REG_STAFF_ADMIN,
doc_type)
error_msg += validate_giving_notice(json_data, doc_type)
if doc_type and doc_type == MhrDocumentTypes.NRED:
error_msg += validate_nred(registration, json_data)
Expand Down
2 changes: 1 addition & 1 deletion mhr_api/src/mhr_api/utils/registration_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def validate_owner_groups(groups,
error_msg += validate_owner(owner)
if so_count > 1 or (so_count == 1 and len(groups) > 1):
error_msg += ADD_SOLE_OWNER_INVALID
if not new and active_count == 1 and tenancy_type in (MhrTenancyTypes.COMMON, MhrTenancyTypes.NA):
if not new and active_count == 1 and tenancy_type == MhrTenancyTypes.COMMON:
error_msg += GROUP_COMMON_INVALID
return error_msg

Expand Down
5 changes: 3 additions & 2 deletions mhr_api/src/mhr_api/utils/validator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ def validate_registration_state(registration: MhrRegistration, staff: bool, reg_
return error_msg
if is_legacy():
return validator_utils_legacy.validate_registration_state(registration, staff, reg_type, doc_type)
if reg_type and reg_type == MhrDocumentTypes.EXRE:
if doc_type and doc_type == MhrDocumentTypes.EXRE:
return validate_registration_state_exre(registration)
if reg_type and reg_type in (MhrRegistrationTypes.EXEMPTION_NON_RES, MhrRegistrationTypes.EXEMPTION_RES):
return validate_registration_state_exemption(registration, reg_type, staff)
if registration.status_type:
if registration.status_type != MhrRegistrationStatusTypes.ACTIVE:
if registration.status_type == MhrRegistrationStatusTypes.CANCELLED or \
doc_type is None or \
doc_type != MhrDocumentTypes.NPUB:
doc_type not in (MhrDocumentTypes.NPUB, MhrDocumentTypes.NCON,
MhrDocumentTypes.NCAN, MhrDocumentTypes.NRED):
error_msg += STATE_NOT_ALLOWED
elif registration.change_registrations:
last_reg: MhrRegistration = registration.change_registrations[-1]
Expand Down
5 changes: 3 additions & 2 deletions mhr_api/src/mhr_api/utils/validator_utils_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ def validate_registration_state(registration, staff: bool, reg_type: str, doc_ty
if not registration or not registration.manuhome:
return error_msg
manuhome: Db2Manuhome = registration.manuhome
if reg_type and reg_type == MhrDocumentTypes.EXRE:
if doc_type and doc_type == MhrDocumentTypes.EXRE:
return validate_registration_state_exre(manuhome)
if reg_type and reg_type in (MhrRegistrationTypes.EXEMPTION_NON_RES, MhrRegistrationTypes.EXEMPTION_RES):
return validate_registration_state_exemption(manuhome, reg_type, staff)
if manuhome.mh_status != manuhome.StatusTypes.REGISTERED:
if manuhome.mh_status == manuhome.StatusTypes.CANCELLED or \
doc_type is None or \
doc_type != MhrDocumentTypes.NPUB:
doc_type not in (MhrDocumentTypes.NPUB, MhrDocumentTypes.NCON,
MhrDocumentTypes.NCAN, MhrDocumentTypes.NRED):
error_msg += STATE_NOT_ALLOWED
elif manuhome.reg_documents:
last_doc: Db2Document = manuhome.reg_documents[-1]
Expand Down
71 changes: 71 additions & 0 deletions mhr_api/test_data/db2_data_files/test0006.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
-- UT-0033 000932 MHREG EXEMPT with NCON, TAXN notes.
INSERT INTO amhrtdb.manuhome(MANHOMID, MHREGNUM, MHSTATUS, REGDOCID, UPDATECT, UPDATEID, UPDATEDA, UPDATETI)
VALUES (200000047, '000932', 'E', 'UT000047', 1, 'PS12345 ', current date, current time)
;
INSERT INTO amhrtdb.document(DOCUMTID, MHREGNUM, DRAFDATE, REGIDATE, DOCUTYPE, DOCUREGI, OWNLAND, UPDATEID, PHONE, NAME, ADDRESS, AFFIRMBY, OLBCFOLI)
VALUES ('UT000047', '000932', current timestamp, current timestamp, '101 ', '90499047', 'N', 'PS12345 ', '6041234567',
'SUBMITTING',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'TEST USER', 'UT-0033')
;
INSERT INTO amhrtdb.descript(MANHOMID, DESCRNID, STATUS, REGDOCID, CSANUMBR, CSASTAND, NUMBSECT, YEARMADE,
SERNUMB1, LENGTH1, LENGIN1, WIDTH1, WIDIN1,
MANUNAME, MAKEMODL, REBUILTR, OTHERREM, ENGIDATE)
VALUES (200000047, 1, 'A', 'UT000047', '77777', '1234', 1, '2000', '888888', 60, 10, 14, 11,
'MANUFACTURER', 'make model', 'rebuilt', 'other', TO_DATE('0001-01-01', 'YYYY-MM-DD'))
;
INSERT INTO amhrtdb.location(MANHOMID, LOCATNID, STATUS, REGDOCID, STNUMBER, STNAME, TOWNCITY, PROVINCE, MAHPNAME,
MAHPPAD, PIDNUMB, TAXCERT, TAXDATE, MHDEALER, ADDDESC)
VALUES (200000047, 1, 'A', 'UT000047', '1234', 'TEST-0033', 'CITY', 'BC', '', '', '005509807', 'N',
TO_DATE('0001-01-01', 'YYYY-MM-DD'), '', 'additional')
;
INSERT INTO amhrtdb.owngroup(MANHOMID, OWNGRPID, COPGRPID, GRPSEQNO, STATUS, REGDOCID, TENYTYPE, INTEREST, INTNUMER, TENYSPEC)
VALUES (200000047, 1, 0, 1, '3', 'UT000047', 'SO', '', 0, 'Y')
;
INSERT INTO amhrtdb.owner(MANHOMID, OWNGRPID, OWNERID, OWNSEQNO, VERIFIED, OWNRTYPE, COMPNAME, OWNRFONE, OWNRPOCO, OWNRNAME, OWNRSUFF, OWNRADDR)
VALUES (200000047, 1, 1, 1, ' ', 'B', 'TESTEXRSACTIVE', '6041234567', 'V8R 3A5', 'TTEST EXRS ACTIVE', '',
'1234 TEST-0033 CITY BC CA')
;
INSERT INTO amhrtdb.cmpserno(MANHOMID, CMPSERID, SERIALNO)
VALUES (200000047, 1, (SELECT serialno FROM amhrtdb.cmpserno WHERE manhomid = 40865 AND CMPSERID = 1))
;
-- UT-0033 000932 NCON note registration
INSERT INTO amhrtdb.document(DOCUMTID, MHREGNUM, DRAFDATE, REGIDATE, DOCUTYPE, DOCUREGI, OWNLAND, UPDATEID, PHONE, NAME, ADDRESS, AFFIRMBY, OLBCFOLI)
VALUES ('UT000048', '000932', current timestamp, current timestamp, 'NCON', '90499048', 'N', 'PS12345 ', '6041234567',
'SUBMITTING',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'TEST USER', 'UT-0033')
;
INSERT INTO amhrtdb.mhomnote(MANHOMID, MHNOTEID, MHNOTENO, REGDOCID, CANDOCID, DOCUTYPE, STATUS, DESTROYD, EXPIRYDA, PHONE, NAME, ADDRESS, REMARKS)
VALUES (200000047, 1, 1, 'UT000048', '', 'NCON', 'A', '', TO_DATE('0001-01-01', 'YYYY-MM-DD'), '6041234567',
'PERSON GIVING NOTICE',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'NCON NOTE REMARKS')
;
-- UT-0033 000932 TAXN note registration
INSERT INTO amhrtdb.document(DOCUMTID, MHREGNUM, DRAFDATE, REGIDATE, DOCUTYPE, DOCUREGI, OWNLAND, UPDATEID, PHONE, NAME, ADDRESS, AFFIRMBY, OLBCFOLI)
VALUES ('UT000049', '000932', current timestamp, current timestamp, 'TAXN', '90499049', 'N', 'PS12345 ', '6041234567',
'SUBMITTING',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'TEST USER', 'UT-0033')
;
INSERT INTO amhrtdb.mhomnote(MANHOMID, MHNOTEID, MHNOTENO, REGDOCID, CANDOCID, DOCUTYPE, STATUS, DESTROYD, EXPIRYDA, PHONE, NAME, ADDRESS, REMARKS)
VALUES (200000047, 2, 2, 'UT000049', '', 'TAXN', 'A', '', TO_DATE('0001-01-01', 'YYYY-MM-DD'), '6041234567',
'PERSON GIVING NOTICE',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'TAXN NOTE REMARKS')
;
-- UT-0033 000932 EXRS registration
INSERT INTO amhrtdb.document(DOCUMTID, MHREGNUM, DRAFDATE, REGIDATE, DOCUTYPE, DOCUREGI, OWNLAND, UPDATEID, PHONE, NAME, ADDRESS, AFFIRMBY, OLBCFOLI)
VALUES ('UT000050', '000932', current timestamp, current timestamp, 'EXRS', '90499050', 'N', 'PS12345 ', '6041234567',
'SUBMITTING',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'TEST USER', 'UT-0033')
;
INSERT INTO amhrtdb.mhomnote(MANHOMID, MHNOTEID, MHNOTENO, REGDOCID, CANDOCID, DOCUTYPE, STATUS, DESTROYD, EXPIRYDA, PHONE, NAME, ADDRESS, REMARKS)
VALUES (200000047, 3, 3, 'UT000050', '', 'EXRS', 'A', '', TO_DATE('0001-01-01', 'YYYY-MM-DD'), '6041234567',
'PERSON GIVING NOTICE',
'1234 TEST-0033 CITY BC CA V8R 3A5',
'RESIDENTIAL REMARKS')
;

Loading

0 comments on commit e746137

Please sign in to comment.