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

MHR API UXA review amend permit report updates. #1673

Merged
merged 2 commits into from
Jan 3, 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
18 changes: 9 additions & 9 deletions mhr_api/report-templates/registrationCoverV2.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@
{{ documentDescription }}
{% endif %}
</div>
<div class="cover-data"><span class="cover-data-bold">
{% if registrationType is defined and registrationType == 'PERMIT' %}Transport Permit Number:{% else %}Document Registration Number:{% endif %}
</span>
{% if documentRegistrationNumber is defined and documentRegistrationNumber != '' %}
{{ documentRegistrationNumber }}
{% else %}
N/A
{% endif %}
</div>
{% if documentType is defined and documentType == 'CANCEL_PERMIT' and note is defined and note.cancelledDocumentRegistrationNumber is defined %}
<div class="cover-data"><span class="cover-data-bold">Transport Permit Number:</span>
{{ note.cancelledDocumentRegistrationNumber }}
Expand All @@ -118,6 +109,15 @@
{{ permitRegistrationNumber }}
</div>
{% endif %}
<div class="cover-data"><span class="cover-data-bold">
{% if registrationType is defined and registrationType == 'PERMIT' %}Transport Permit Number:{% else %}Document Registration Number:{% endif %}
</span>
{% if documentRegistrationNumber is defined and documentRegistrationNumber != '' %}
{{ documentRegistrationNumber }}
{% else %}
N/A
{% endif %}
</div>
<div class="cover-data"><span class="cover-data-bold">
{% if registrationType is defined and registrationType == 'PERMIT' %}Date of Issue:{% else %}Document Registration Date and Time:{% endif %}
</span> {{ createDateTime }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{% elif registrationType in ('PERMIT', 'REG_STAFF_ADMIN') and (documentType is not defined or documentType != 'CANCEL_PERMIT') %}
<div class="section-title mt-5">New Registered Location</div>
{% elif amendment is defined and amendment %}
<div class="separator mt-5"></div>
<div class="section-title mt-5">New Registered Location<span class="pl-2">&nbsp;</span><span class="label">AMENDED</span></div>
{% elif registrationType not in ('EXEMPTION_RES', 'EXEMPTION_NON_RES') %}
{% if documentType is not defined or documentType != 'CANCEL_PERMIT' %}
Expand Down
7 changes: 3 additions & 4 deletions mhr_api/report-templates/transportPermitV2.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<td>{{permitDateTime}}</td>
</tr>
<tr>
<td>Permit Expiry Date:</td>
<td>Transport Permit Expiry Date:</td>
<td> {{permitExpiryDateTime}} </td>
</tr>
{% else %}
Expand Down Expand Up @@ -89,9 +89,8 @@
<td class="pl-2">
<div>If the manufactured home is permanently placed on a location other than specifically described on the transport permit,
the owner must advise the Registrar and provide full details of the location either</div>
<div>(a) within 3 days after the manufactured home was transported to the new location</div>
<div>or</div>
<div>(b) within 3 days after the expiration of the transport permit which ever occurs first.</div>
<div class="pl-3">(a) within 3 days after the manufactured home was transported to the new location, or</div>
<div class="pl-3">(b) within 3 days after the expiration of the transport permit which ever occurs first.</div>
</td>
</tr>
<tr>
Expand Down
20 changes: 13 additions & 7 deletions mhr_api/src/mhr_api/models/batch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from flask import current_app
from sqlalchemy.sql import text

from mhr_api.models import EventTracking, utils as model_utils, MhrRegistration
from mhr_api.models import EventTracking, utils as model_utils, MhrRegistration, registration_json_utils
from mhr_api.models.db import db
from mhr_api.models.type_tables import MhrDocumentTypes, MhrRegistrationStatusTypes
from mhr_api.resources import registration_utils as reg_utils
Expand Down Expand Up @@ -317,12 +317,14 @@ def get_batch_registration_json(registration: MhrRegistration, json_data: dict,
if not doc_type:
doc_type = registration.documents[0].document_type
reg_json['documentType'] = doc_type
if not reg_json.get('declaredValue'):
reg_json = registration_json_utils.set_current_misc_json(registration, reg_json, False)
reg_json = batch_json_cleanup(reg_json)
if not current_json or doc_type == MhrDocumentTypes.REG_101:
return reg_json
reg_json = set_batch_json_description(reg_json, current_json)
reg_json = set_batch_json_location(reg_json, current_json, doc_type)
reg_json = set_batch_json_owners(reg_json, current_json, doc_type)
reg_json = set_batch_json_location(reg_json, current_json, doc_type, registration)
reg_json = set_batch_json_owners(reg_json, current_json, doc_type, registration)
if reg_json.get('status') == model_utils.STATUS_FROZEN:
reg_json['status'] = MhrRegistrationStatusTypes.ACTIVE.value
return reg_json
Expand All @@ -337,9 +339,11 @@ def set_batch_json_description(reg_json: dict, current_json: dict) -> dict:
return reg_json


def set_batch_json_location(reg_json: dict, current_json: dict, doc_type: str) -> dict:
def set_batch_json_location(reg_json: dict, current_json: dict, doc_type: str, registration: MhrRegistration) -> dict:
"""Update the batch JSON: add the current location and conditionally the previous location."""
if is_previous_location_doc_type(doc_type, reg_json) and current_json:
if doc_type in (MhrDocumentTypes.REGC, MhrDocumentTypes.PUBA) and not registration.locations:
current_app.logger.debug(f'No location change: skipping previous location for doc type={doc_type}.')
elif is_previous_location_doc_type(doc_type, reg_json) and current_json:
current_app.logger.debug(f'Setting up previous location for doc type={doc_type}.')
reg_json['previousLocation'] = current_json.get('location')
if reg_json.get('newLocation'):
Expand All @@ -350,9 +354,11 @@ def set_batch_json_location(reg_json: dict, current_json: dict, doc_type: str) -
return reg_json


def set_batch_json_owners(reg_json: dict, current_json: dict, doc_type: str) -> dict:
def set_batch_json_owners(reg_json: dict, current_json: dict, doc_type: str, registration: MhrRegistration) -> dict:
"""Update the batch JSON: add the current owner groups and conditionally the previous owner groups."""
if is_previous_owner_doc_type(doc_type, reg_json) and current_json:
if doc_type in (MhrDocumentTypes.REGC, MhrDocumentTypes.PUBA) and not registration.owner_groups:
current_app.logger.debug(f'No owner change: skipping previous owner groups for doc type={doc_type}.')
elif is_previous_owner_doc_type(doc_type, reg_json) and current_json:
current_app.logger.debug(f'Setting up previous owners for doc type={doc_type}.')
reg_json['previousOwnerGroups'] = current_json.get('ownerGroups')
if reg_json.get('deleteOwnerGroups'):
Expand Down