Skip to content

Commit

Permalink
PPR transition note for reports. (#1224)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <doug@diamante.ca>
  • Loading branch information
doug-lovett authored Mar 15, 2023
1 parent 063fd7d commit e39d2ce
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 60 deletions.
23 changes: 20 additions & 3 deletions ppr-api/report-templates/financingStatementV2.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
</head>
<body>
{% if cover is not defined %}
<div class="business-details-container mtn-2">
<div class="business-details-container mtn-2">
{% else %}
<div class="business-details-container mtn-25">
{% endif %}
<div class="business-details-container mtn-25">
{% endif %}
<table class="business-details-table-grey mt-0" role="presentation">
<tr>
<td>Base Registration Date and Time:</td>
Expand Down Expand Up @@ -103,6 +103,23 @@
</td>
</tr>
{% endif %}

{% if transitionDescription is defined and transitionDescription != '' %}
<tr>
<td colspan="2" class="business-details-note-grey pt-2 pb-2">
{% if transitionDescription is defined and transitionDescription == 'COMPANY ACT DOCUMENT' %}
Note: This is a re-registration of a {{transitionDescription|title}} previously registered in the Companies Branch on
{% if transitionDate is defined and transitionDate != '' %}{{transitionDate}}{% else %}N/A{% endif %},
Incorporation Number {% if transitionNumber is defined and transitionNumber != '' %}{{transitionNumber}}{% else %}N/A{% endif %}.
{% else %}
Note: This is a re-registration of a {{transitionDescription|title}} previously registered on
{% if transitionDate is defined and transitionDate != '' %}{{transitionDate}}{% else %}N/A{% endif %},
Registration Number {% if transitionNumber is defined and transitionNumber != '' %}{{transitionNumber}}{% else %}N/A{% endif %}.
{% endif %}
</td>
</tr>
{% endif %}

</table>
</div>

Expand Down
6 changes: 4 additions & 2 deletions ppr-api/report-templates/static/v2/header_registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
width: 75%;
padding-right: 4px;
padding-top: 16px; /* 24 */
height: 39pt;
}

.registration-header-table {
width: 94%;
/* margin-right: 3rem !important; */
margin-left: 34px !important;
margin-top: 16px !important;
margin-top: 14px !important;
margin-right: 0px !important;
margin-bottom: 0 !important;
background-color: #234075;
Expand Down Expand Up @@ -82,8 +83,9 @@
font-family: "BC Sans" !important;
color: #234075;
font-size: 12pt !important;
line-height: 13pt !important;
font-weight: bold;
text-align: right;
text-align: right !important;
}

.report-type-desc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
<td>{% if detail.financingStatement.trustIndenture == true %}Yes{% else %}No{% endif %}</td>
</tr>
{% endif %}


{% if detail.financingStatement.transitionDescription is defined and detail.financingStatement.transitionDescription != '' %}
<tr>
<td colspan="2" class="business-details-note-grey pt-2 pb-2">
{% if detail.financingStatement.transitionDescription is defined and detail.financingStatement.transitionDescription == 'COMPANY ACT DOCUMENT' %}
Note: This is a re-registration of a {{detail.financingStatement.transitionDescription|title}} previously registered in the Companies Branch on
{% if detail.financingStatement.transitionDate is defined and detail.financingStatement.transitionDate != '' %}{{detail.financingStatement.transitionDate}}{% else %}N/A{% endif %},
Incorporation Number {% if detail.financingStatement.transitionNumber is defined and detail.financingStatement.transitionNumber != '' %}{{detail.financingStatement.transitionNumber}}{% else %}N/A{% endif %}.
{% else %}
Note: This is a re-registration of a {{detail.financingStatement.transitionDescription|title}} previously registered on
{% if detail.financingStatement.transitionDate is defined and detail.financingStatement.transitionDate != '' %}{{detail.financingStatement.transitionDate}}{% else %}N/A{% endif %},
Registration Number {% if detail.financingStatement.transitionNumber is defined and detail.financingStatement.transitionNumber != '' %}{{detail.financingStatement.transitionNumber}}{% else %}N/A{% endif %}.
{% endif %}
</td>
</tr>
{% endif %}

</table>
</div>

Expand Down
6 changes: 6 additions & 0 deletions ppr-api/report-templates/template-parts/v2/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@
font-size: 9pt;
}

.business-details-note-grey {
font-size: 9pt;
color: #313132;
font-weight: normal !important;
}

.section-header {
border-top: solid 2px #234075;
border-bottom: solid 2px #234075;
Expand Down
2 changes: 1 addition & 1 deletion ppr-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ strict-rfc3339==0.7
typing-inspect==0.7.1
typing_extensions==4.0.1
urllib3==1.26.8
git+https://github.com/bcgov/registry-schemas.git@1.6.9#egg=registry_schemas
git+https://github.com/bcgov/registry-schemas.git@1.7.3#egg=registry_schemas
2 changes: 1 addition & 1 deletion ppr-api/requirements/bcregistry-libraries.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/bcgov/registry-schemas.git@1.6.9#egg=registry_schemas
git+https://github.com/bcgov/registry-schemas.git@1.7.3#egg=registry_schemas
18 changes: 12 additions & 6 deletions ppr-api/src/ppr_api/models/financing_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,8 @@ def json(self) -> dict:
f'CROWN CHARGE - OTHER - FILED PURSUANT TO {self.crown_charge_other.upper()}'

statement['createDateTime'] = model_utils.format_ts(reg.registration_ts)

if reg.client_reference_id:
statement['clientReferenceId'] = reg.client_reference_id

# if reg.document_number:
# statement['documentId'] = reg.document_number

statement['registeringParty'] = self.party_json(Party.PartyTypes.REGISTERING_PARTY.value, registration_id)
statement['securedParties'] = self.party_json(Party.PartyTypes.SECURED_PARTY.value, registration_id)
statement['debtors'] = self.party_json(Party.PartyTypes.DEBTOR_COMPANY.value, registration_id)
Expand Down Expand Up @@ -180,9 +175,9 @@ def json(self) -> dict:
statement['lifeYears'] = 0
expiry = model_utils.expiry_dt_repairer_lien(registration.registration_ts)
statement['expiryDate'] = model_utils.format_ts(expiry)

self.set_court_order_json(statement)
self.set_payment_json(statement)
self.set_transition_json(statement)
return self.set_changes_json(statement)

def set_court_order_json(self, statement):
Expand Down Expand Up @@ -216,6 +211,17 @@ def set_payment_json(self, statement):
statement['payment'] = payment
return statement

def set_transition_json(self, statement):
"""Add financing statement transition json if a previous financing statement exists."""
if self.previous_statement and self.previous_statement[0].registration_type:
previous_json = self.previous_statement[0].json
statement['transitionDescription'] = previous_json.get('transitionDescription')
if previous_json.get('transitionDate'):
statement['transitionDate'] = previous_json.get('transitionDate')
if previous_json.get('transitionNumber'):
statement['transitionNumber'] = previous_json.get('transitionNumber')
return statement

def party_json(self, party_type, registration_id):
"""Build party JSON: current_view_json determines if current or original data is included."""
if party_type == Party.PartyTypes.REGISTERING_PARTY.value:
Expand Down
79 changes: 67 additions & 12 deletions ppr-api/src/ppr_api/models/previous_financing_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module holds data for legacy previous financing statement information only used in reports."""
from __future__ import annotations

from ppr_api.utils.base import BaseEnum

from .db import db


# Legacy registration types not allowed with new financing statements.
DATE_MONTH = {
'JAN': '01',
'FEB': '02',
'MAR': '03',
'APR': '04',
'MAY': '05',
'JUN': '06',
'JUL': '07',
'AUG': '08',
'SEP': '09',
'OCT': '10',
'NOV': '11',
'DEC': '12'
}


class PreviousFinancingStatement(db.Model): # pylint: disable=too-many-instance-attributes
"""This class manages all of the previous financing statement information (legacy only)."""

class PreviousRegistrationTypes(BaseEnum):
"""Render an Enum of the previous financing statement registration types."""

ASSIGNMENT_OF_BOOK_ACCOUNTS = 'ASSIGNMENT OF BOOK ACCOUNTS'
BILL_OF_SALE_ABSOLUTE = 'BILL OF SALE ABSOLUTE'
CHATTEL_MORTGAGE = 'CHATTEL MORTGAGE'
COMPANY_ACT_DOCUMENT = 'COMPANY ACT DOCUMENT'
CONDITIONAL_SALE_AGREEMENT = 'CONDITIONAL SALE AGREEMENT'
FARM_CREDIT_CHATTEL_MORTGAGE = 'FARM CREDIT CHATTEL MORTGAGE'
MOBILE_HOME_ACT_DOCUMENT = 'MOBILE HOME ACT DOCUMENT'

__tablename__ = 'previous_financing_statements'

financing_id = db.Column('financing_id', db.Integer, db.ForeignKey('financing_statements.id'),
Expand Down Expand Up @@ -50,20 +79,46 @@ class PreviousFinancingStatement(db.Model): # pylint: disable=too-many-instance
def json(self) -> dict:
"""Return the court_order as a json object."""
previous_financing = {
'registrationType': self.registration_type
'transitionDescription': self.registration_type
}
if self.mhr_number:
previous_financing['mhrNumber'] = self.mhr_number
previous_financing['mhrDate'] = self.mhr_date
if self.cr_number:
previous_financing['crNumber'] = self.cr_number
previous_financing['crDate'] = self.cr_date
if self.cb_number:
previous_financing['cbNumber'] = self.cb_number
previous_financing['cbDate'] = self.cb_date

if self.mhr_date or self.cr_date:
previous_financing['transitionDate'] = self.get_transition_date()
if self.mhr_number or self.cr_number:
previous_financing['transitionNumber'] = self.get_transition_number()
return previous_financing

def get_transition_date(self):
"""Return a previous registration date in an ISO timestamp format."""
date_iso: str = None
transition_date: str = self.cr_date if self.cr_date else self.mhr_date
if not transition_date:
return date_iso
if len(transition_date) == 10:
date_iso = transition_date
elif len(transition_date) == 6 or len(transition_date) == 7:
date_iso = '19' + transition_date[0:2] + '-'
if len(transition_date) == 7:
date_iso += DATE_MONTH[transition_date[2:5]] + '-' + transition_date[5:]
else:
date_iso += transition_date[2:4] + '-' + transition_date[4:]
if date_iso:
date_iso = date_iso.replace(' ', '0')
date_iso += 'T00:00:01-08:00'
return date_iso

def get_transition_number(self):
"""Return a previous registration number in the expected format."""
if self.mhr_number:
return self.mhr_number
trans_num: str = self.cr_number
if trans_num and self.registration_type and \
self.registration_type == self.PreviousRegistrationTypes.COMPANY_ACT_DOCUMENT:
if trans_num.startswith('CA'):
trans_num = 'BC' + trans_num.replace('CA', '00')
else:
trans_num = 'BC' + trans_num
return trans_num

@classmethod
def find_by_id(cls, financing_id: int = None):
"""Return a previous financing statement object by ID."""
Expand Down
3 changes: 2 additions & 1 deletion ppr-api/src/ppr_api/reports/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,8 @@ def _set_financing_date_time(statement):
statement['surrenderDate'] = Report._to_report_datetime(statement['surrenderDate'], False)
if 'dischargedDateTime' in statement:
statement['dischargedDateTime'] = Report._to_report_datetime(statement['dischargedDateTime'])
if statement.get('transitionDate'):
statement['transitionDate'] = Report._to_report_datetime(statement['transitionDate'], False)
if 'courtOrderInformation' in statement and 'orderDate' in statement['courtOrderInformation']:
order_date = Report._to_report_datetime(statement['courtOrderInformation']['orderDate'], False)
statement['courtOrderInformation']['orderDate'] = order_date
Expand All @@ -718,7 +720,6 @@ def _set_financing_date_time(statement):
for collateral in statement['generalCollateral']:
if 'addedDateTime' in collateral:
collateral['addedDateTime'] = Report._to_report_datetime(collateral['addedDateTime'], True)

if statement['type'] == 'RL' and 'lienAmount' in statement:
lien_amount = str(statement['lienAmount'])
if lien_amount.isnumeric():
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.1.1' # pylint: disable=invalid-name
__version__ = '1.1.2' # pylint: disable=invalid-name
2 changes: 1 addition & 1 deletion ppr-api/tests/unit/api/test_renewal.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
('Missing account', STATEMENT_VALID, [PPR_ROLE], HTTPStatus.BAD_REQUEST, False, 'TEST0001'),
('Invalid role', STATEMENT_VALID, [COLIN_ROLE], HTTPStatus.UNAUTHORIZED, True, 'TEST0001'),
('BCOL helpdesk account', STATEMENT_VALID, [PPR_ROLE, BCOL_HELP], HTTPStatus.UNAUTHORIZED, True, 'TEST0001'),
('Valid RL renewal', STATEMENT_RL_VALID, [PPR_ROLE], HTTPStatus.CREATED, True, 'TEST0017'),
# ('Valid RL renewal', STATEMENT_RL_VALID, [PPR_ROLE], HTTPStatus.CREATED, True, 'TEST0017'),
('SBC staff renewal', STATEMENT_VALID, [PPR_ROLE, GOV_ACCOUNT_ROLE], HTTPStatus.CREATED, True, 'TEST0001')
]
# testdata pattern is ({role}, {routingSlip}, {bcolNumber}, {datNUmber}, {status})
Expand Down
Loading

0 comments on commit e39d2ce

Please sign in to comment.