Skip to content

Commit

Permalink
23350 - notice of withdrawal outputs - focus on NoW for existing busi…
Browse files Browse the repository at this point in the history
…nesses (#3148)

* create template for NoW and format it
* update business details for NoW
* update receipt data for NoW
  • Loading branch information
eason-pan-bc authored Dec 24, 2024
1 parent 1a68629 commit 71abcb9
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 5 deletions.
33 changes: 33 additions & 0 deletions legal-api/report-templates/noticeOfWithdrawal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[[macros.html]]
<!DOCTYPE html>
<html lang="en">
<head>
<title>Notice of Withdrawal</title>
<meta charset="UTF-8">
<meta name="author" content="BC Registries and Online Services">
[[common/style.html]]
</head>
<body>
<div class="header">
<table class="header-table" role="presentation">
<tr class="no-page-break">
<td>
[[logo.html]]
</td>
<td>
<div class="report-type">NOTICE OF WITHDRAWAL</div>
<div class="report-type-desc">{{entityDescription}} - {{ entityAct }}</div>
</td>
</tr>
</table>
<div class="business-name-header">
<label class="lbl-business-name">{{business.legalName}}</label>
</div>
</div>
[[common/businessDetails.html]]
<div class="section-header mt-5 pt-4">NOTICE OF WITHDRAWAL</div>
<div class="container pt-4">
[[notice-of-withdrawal/recordToBeWithdrawn.html]]
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,28 @@
{% endif %}
<div class="pt-2">{{report_date_time}}</div>
</td>
{% elif header.name == 'noticeOfWithdrawal' %}
<td class="col-33">
{% if not business or business.identifier.startswith('T') %}
<div class="bold">Filed Date and Time:</div>
{% else %}
<div class="bold">Incorporation Number:</div>
<div class="bold pt-2">Filed Date and Time:</div>
{% endif %}
<div class="bold pt-2">Recognition Date and Time:</div>
<div class="bold pt-2">Retrieved Date and Time:</div>
</td>
<td>
{% if not business or business.identifier.startswith('T') %}
<div>{{ filing_date_time }}</div>
<div class="pt-2">{{ effective_date_time }}</div>
{% else %}
<div>{{business.identifier}}</div>
<div class="pt-2">{{ filing_date_time }}</div>
<div class="pt-2">{{ recognition_date_time }}</div>
{% endif %}
<div class="pt-2">{{ report_date_time }}</div>
</td>
{% endif %}
{% if reportType != 'summary' %}
<td class="business-details-registar-td">
Expand Down Expand Up @@ -359,8 +381,8 @@
{% if business.legalType in ['SP', 'GP'] %}
<span> | Registration #{{business.identifier}}</span>
{% else %}
{% if header.name != 'incorporationApplication' %}
<!-- not required for incorporationApplication -->
{% if header.name not in ['incorporationApplication', 'noticeOfWithdrawal'] %}
<!-- not required for incorporationApplication and noticeOfWithdrawal -->
<span> | Incorporation #
{% if not business or business.identifier.startswith('T') %}
Pending
Expand Down
9 changes: 9 additions & 0 deletions legal-api/report-templates/template-parts/common/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@
text-align: center
}

.record-to-be-withdrawn-table {
width: 100%;
font-family: 'BCSans-Regular', sans-serif !important;
color: #313132;
font-size: 13px;
line-height: 16px;
text-align: left;
}

.share-structure-table {
width: 100%;
border-collapse: collapse;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="no-page-break">
<div class="section-title mt-4">Record to be Withdrawn</div>
<table class="record-to-be-withdrawn-table" role="presentation">
<tr>
<td class="col-33">
<div class="bold pt-4">Filing Type:</div>
<div class="bold pt-2">Filing Number:</div>
<div class="bold pt-2">Effective Date and Time:</div>
</td>
<td>
<div class="pt-4">{{ withdrawnFilingType }}</div>
<div class="pt-2">{{ noticeOfWithdrawal.filingId }}</div>
<div class="pt-2">{{ withdrawnFilingEffectiveDate }}</div>
</td>
</tr>
</table>
</div>
21 changes: 20 additions & 1 deletion legal-api/src/legal_api/reports/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from dateutil.relativedelta import relativedelta
from flask import current_app, jsonify

from legal_api.core.meta.filing import FILINGS
from legal_api.core.meta.filing import FILINGS, FilingMeta
from legal_api.models import (
AmalgamatingBusiness,
Amalgamation,
Expand Down Expand Up @@ -174,6 +174,7 @@ def _substitute_template_parts(template_code):
'change-of-registration/addresses',
'change-of-registration/proprietor',
'change-of-registration/partner',
'notice-of-withdrawal/recordToBeWithdrawn',
'incorporation-application/benefitCompanyStmt',
'incorporation-application/completingParty',
'incorporation-application/effectiveDate',
Expand Down Expand Up @@ -306,6 +307,8 @@ def _format_filing_json(self, filing): # pylint: disable=too-many-branches, too
self._format_continuation_in_data(filing)
elif self._report_key == 'certificateOfContinuation':
self._format_certificate_of_continuation_in_data(filing)
elif self._report_key == 'noticeOfWithdrawal':
self._format_notice_of_withdrawal_data(filing)
else:
# set registered office address from either the COA filing or status quo data in AR filing
with suppress(KeyError):
Expand Down Expand Up @@ -748,6 +751,18 @@ def _format_amalgamation_data(self, filing):
def _format_certificate_of_amalgamation_data(self, filing):
self._set_amalgamating_businesses(filing)

def _format_notice_of_withdrawal_data(self, filing):
withdrawn_filing_id = filing['noticeOfWithdrawal']['filingId']
withdrawn_filing = Filing.find_by_id(withdrawn_filing_id)
formatted_withdrawn_filing_type = FilingMeta.get_display_name(
withdrawn_filing.filing_json['filing']['business']['legalType'],
withdrawn_filing.filing_type,
withdrawn_filing.filing_sub_type
)
filing['withdrawnFilingType'] = formatted_withdrawn_filing_type
withdrawn_filing_date = LegislationDatetime.as_legislation_timezone(withdrawn_filing.effective_date)
filing['withdrawnFilingEffectiveDate'] = LegislationDatetime.format_as_report_string(withdrawn_filing_date)

def _set_amalgamating_businesses(self, filing):
amalgamating_businesses = []
business_legal_name = None
Expand Down Expand Up @@ -1460,6 +1475,10 @@ class ReportMeta: # pylint: disable=too-few-public-methods
'certificateOfContinuation': {
'filingDescription': 'Certificate of Continuation',
'fileName': 'certificateOfContinuation'
},
'noticeOfWithdrawal': {
'filingDescription': 'Notice of Withdrawal',
'fileName': 'noticeOfWithdrawal'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def _get_receipt(business: Business, filing: Filing, token):
return {}, HTTPStatus.BAD_REQUEST

effective_date = None
if filing.storage.effective_date.date() != filing.storage.filing_date.date():
if filing.storage.effective_date.date() != filing.storage.filing_date.date() \
or filing.filing_type == 'noticeOfWithdrawal':
effective_date = LegislationDatetime.format_as_report_string(filing.storage.effective_date)

headers = {'Authorization': 'Bearer ' + token}
Expand Down
97 changes: 96 additions & 1 deletion legal-api/tests/unit/reports/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"""Test-Suite to ensure that the Report class is working as expected."""
import copy
from contextlib import suppress
from datetime import datetime, timedelta
from pathlib import Path
from unittest.mock import patch

import pytest
from flask import current_app
from registry_schemas.example_data import (
AGM_LOCATION_CHANGE,
ALTERATION_FILING_TEMPLATE,
ANNUAL_REPORT,
CHANGE_OF_ADDRESS,
Expand All @@ -31,6 +33,8 @@
CORRECTION_COMBINED_AR,
DISSOLUTION,
FILING_HEADER,
NOTICE_OF_WITHDRAWAL,
RESTORATION,
INCORPORATION_FILING_TEMPLATE,
SPECIAL_RESOLUTION,
TRANSITION_FILING_TEMPLATE,
Expand All @@ -40,7 +44,8 @@
from legal_api.models.db import versioning_manager
from legal_api.reports.report import Report # noqa:I001
from legal_api.services import VersionedBusinessDetailsService # noqa:I001
from tests.unit.models import factory_business, factory_completed_filing # noqa:E501,I001
from legal_api.utils.legislation_datetime import LegislationDatetime
from tests.unit.models import factory_business, factory_completed_filing, factory_pending_filing # noqa:E501,I001


def create_report(identifier, entity_type, report_type, filing_type, template):
Expand Down Expand Up @@ -293,3 +298,93 @@ def create_alteration_report(filing, business, report_type):
set_registrar_info(report)
set_meta_info(report)
return report


@pytest.mark.parametrize(
'test_name, identifier, entity_type, filing_template, filing_type, formatted_filing_type',
[
('BC agmLocationChange', 'BC1234567', 'BC', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('BC alteration', 'BC1234567', 'BC', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('BC changeOfAddress', 'BC1234567', 'BC', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('BC changeOfDirectors', 'BC1234567', 'BC', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('BC dissolution', 'BC1234567', 'BC', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('BC restoration', 'BC1234567', 'BC', RESTORATION, 'restoration', 'Full Restoration Application'),
('BEN agmLocationChange', 'BC1234567', 'BEN', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('BEN alteration', 'BC1234567', 'BEN', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('BEN changeOfAddress', 'BC1234567', 'BEN', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('BEN changeOfDirectors', 'BC1234567', 'BEN', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('BEN dissolution', 'BC1234567', 'BEN', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('BEN restoration', 'BC1234567', 'BEN', RESTORATION, 'restoration', 'Full Restoration Application'),
('ULC agmLocationChange', 'BC1234567', 'ULC', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('ULC alteration', 'BC1234567', 'ULC', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('ULC changeOfAddress', 'BC1234567', 'ULC', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('ULC changeOfDirectors', 'BC1234567', 'ULC', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('ULC dissolution', 'BC1234567', 'ULC', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('ULC restoration', 'BC1234567', 'ULC', RESTORATION, 'restoration', 'Full Restoration Application'),
('CC agmLocationChange', 'BC1234567', 'CC', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('CC alteration', 'BC1234567', 'CC', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('CC changeOfAddress', 'BC1234567', 'CC', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('CC changeOfDirectors', 'BC1234567', 'CC', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('CC dissolution', 'BC1234567', 'CC', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('CC restoration', 'BC1234567', 'CC', RESTORATION, 'restoration', 'Full Restoration Application'),
('C agmLocationChange', 'C1234567', 'C', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('C alteration', 'C1234567', 'C', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('C changeOfAddress', 'C1234567', 'C', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('C changeOfDirectors', 'C1234567', 'C', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('C dissolution', 'C1234567', 'C', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('C restoration', 'C1234567', 'C', RESTORATION, 'restoration', 'Full Restoration Application'),
('CUL agmLocationChange', 'C1234567', 'CUL', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('CUL alteration', 'C1234567', 'CUL', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('CUL changeOfAddress', 'C1234567', 'CUL', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('CUL changeOfDirectors', 'C1234567', 'CUL', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('CUL dissolution', 'C1234567', 'CUL', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('CUL restoration', 'C1234567', 'CUL', RESTORATION, 'restoration', 'Full Restoration Application'),
('CBEN agmLocationChange', 'C1234567', 'CBEN', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('CBEN alteration', 'C1234567', 'CBEN', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('CBEN changeOfAddress', 'C1234567', 'CBEN', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('CBEN changeOfDirectors', 'C1234567', 'CBEN', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('CBEN dissolution', 'C1234567', 'CBEN', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('CBEN restoration', 'C1234567', 'CBEN', RESTORATION, 'restoration', 'Full Restoration Application'),
('CCC agmLocationChange', 'C1234567', 'CCC', AGM_LOCATION_CHANGE, 'agmLocationChange', 'AGM Location Change'),
('CCC alteration', 'C1234567', 'CCC', ALTERATION_FILING_TEMPLATE, 'alteration', 'Alteration'),
('CCC changeOfAddress', 'C1234567', 'CCC', CHANGE_OF_ADDRESS, 'changeOfAddress', 'Address Change'),
('CCC changeOfDirectors', 'C1234567', 'CCC', CHANGE_OF_DIRECTORS, 'changeOfDirectors', 'Director Change'),
('CCC dissolution', 'C1234567', 'CCC', DISSOLUTION, 'dissolution', 'Voluntary Dissolution'),
('CCC restoration', 'C1234567', 'CCC', RESTORATION, 'restoration', 'Full Restoration Application')
]
)
def test_notice_of_withdraw_format_data(session, test_name, identifier, entity_type, filing_template, filing_type, formatted_filing_type):
"""Test the data passed to NoW report template - existing business"""
# create a business
test_business = factory_business(identifier=identifier, entity_type=entity_type)

# file a FE filing
today = datetime.utcnow().date()
future_effective_date = today + timedelta(days=5)
future_effective_date = future_effective_date.isoformat()
withdrawn_json = copy.deepcopy(FILING_HEADER)
withdrawn_json['filing']['header']['name'] = filing_type
withdrawn_json['filing']['business']['legalType'] = entity_type
withdrawn_json['filing'][filing_type] = copy.deepcopy(filing_template)
withdrawn_filing = factory_pending_filing(test_business, withdrawn_json)
withdrawn_filing.effective_date = future_effective_date
withdrawn_filing.payment_completion_date = today.isoformat()
withdrawn_filing.save()
withdrawn_filing_id = withdrawn_filing.id

# file a NoW filing
now_json = copy.deepcopy(FILING_HEADER)
now_json['filing']['header']['name'] = 'noticeOfWithdrawal'
now_json['filing']['business']['legalType'] = 'BC'
now_json['filing']['noticeOfWithdrawal'] = copy.deepcopy(NOTICE_OF_WITHDRAWAL)
now_json['filing']['noticeOfWithdrawal']['filingId'] = withdrawn_filing_id

# verify formatted NoW data for report template
formatted_now_json = copy.deepcopy(now_json['filing'])
report_instance = Report({})
expected_withdrawn_filing_effective_date = LegislationDatetime.as_legislation_timezone(withdrawn_filing.effective_date)
expected_withdrawn_filing_effective_date = LegislationDatetime.format_as_report_string(expected_withdrawn_filing_effective_date)
report_instance._format_notice_of_withdrawal_data(formatted_now_json)
assert formatted_now_json['withdrawnFilingType'] == formatted_filing_type
assert formatted_now_json['withdrawnFilingEffectiveDate'] == expected_withdrawn_filing_effective_date
assert formatted_now_json['noticeOfWithdrawal']['filingId'] == withdrawn_filing_id

0 comments on commit 71abcb9

Please sign in to comment.