Skip to content

Commit

Permalink
22496 Emailer - stage 1 overdue ARs notification (EP flow) (bcgov#2924)
Browse files Browse the repository at this point in the history
Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>
  • Loading branch information
chenhongjing authored Aug 16, 2024
1 parent a424337 commit bbd638f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-l
filled_template = substitute_template_parts(template)
# render template with vars
jnja_template = Template(filled_template, autoescape=True)
# get response from get jurisdictions
jurisdictions_response = get_jurisdictions(business_identifier, token)
# get extra provincials array
extra_provincials = get_extra_provincials(jurisdictions_response)

extra_provincials = []
if furnishing.furnishing_name not in \
[Furnishing.FurnishingName.DISSOLUTION_COMMENCEMENT_NO_AR_XPRO,
Furnishing.FurnishingName.DISSOLUTION_COMMENCEMENT_NO_TR_XPRO]:
# get response from get jurisdictions
jurisdictions_response = get_jurisdictions(business_identifier, token)
# get extra provincials array
extra_provincials = get_extra_provincials(jurisdictions_response)

html_out = jnja_template.render(
business=business.json(),
entity_dashboard_url=get_entity_dashboard_url(business_identifier, token),
Expand Down Expand Up @@ -136,9 +142,15 @@ def _get_pdfs(
logger.error('Failed to get pdf for furnishing: %s', furnishing.id)
return []

if furnishing.furnishing_name == Furnishing.FurnishingName.DISSOLUTION_COMMENCEMENT_NO_AR_XPRO:
filename = 'Notice of Commencement of Cancellation.pdf'
else:
filename = 'Notice of Commencement of Dissolution.pdf'

furnishing_pdf_encoded = base64.b64encode(furnishing_pdf.content)

return [{
'fileName': 'Notice of Commencement of Dissolution.pdf',
'fileName': filename,
'fileBytes': furnishing_pdf_encoded.decode('utf-8'),
'fileUrl': '',
'attachOrder': '1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
[[20px.html]]

{% if 'NO_AR' in furnishing_name %}
<p>Your business is in the process of being dissolved because it hasn't
filed its required annual reports. Please file your overdue annual
reports as soon as possible by <a href="{{ entity_dashboard_url }}">logging into your Business Page</a>.
<p>
{% if 'XPRO' in furnishing_name %}
Your extraprovincial company is in the process of being cancelled because it hasn't filed its required annual reports.
{% else %}
Your business is in the process of being dissolved because it hasn't filed its required annual reports.
{% endif %}
Please file your overdue annual reports as soon as possible by <a href="{{ entity_dashboard_url }}">logging into your Business Page</a>.
</p>
{% else %}
<p>Your business is in the process of being dissolved because it hasn't
Expand All @@ -42,8 +46,13 @@
<p>
Under the Business Corporations Act, if you don't file these reports
within one month from today, the Registrar will post a public notice
on <a href="https://www.bclaws.gov.bc.ca/">www.bclaws.ca</a>. This notice will state that your company may be
on <a href="https://www.bclaws.gov.bc.ca/">www.bclaws.ca</a>.
{% if 'XPRO' in furnishing_name %}
This notice will state that your extraprovincial company may be cancelled if the annual reports aren't filed after one month.
{% else %}
This notice will state that your company may be
dissolved if the annual reports aren't filed after one month.
{% endif %}
</p>
{% else %}
<p>
Expand Down Expand Up @@ -71,8 +80,15 @@
[[whitespace-16px.html]]

<p>
You can ask for more time by requesting a delay of the dissolution or
cancellation process. Go to your <a href="{{ entity_dashboard_url }}">business Page</a> and click on “Request
You can ask for more time by requesting
{% if furnishing_name == 'DISSOLUTION_COMMENCEMENT_NO_AR_XPRO' %}
a delay of the cancellation process.
{% elif extra_provincials %}
a delay of the dissolution or cancellation process.
{% else %}
a delay of the dissolution process.
{% endif %}
Go to your <a href="{{ entity_dashboard_url }}">business page</a> and click on “Request
Delay of Dissolution or Cancellation" under the “More Actions” menu.
</p>
[[whitespace-16px.html]]
Expand All @@ -84,13 +100,14 @@
</p>

<ul class="outputs">
<li>Notice of Commencement of Dissolution
</li>
{% if furnishing_name == 'DISSOLUTION_COMMENCEMENT_NO_AR_XPRO' %}
<li>Notice of Commencement of Cancellation</li>
{% else %}
<li>Notice of Commencement of Dissolution</li>
{% endif %}
</ul>

[[whitespace-16px.html]]
[[business-dashboard-link.html]]

[[20px.html]]
[[footer.html]]
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@
from http import HTTPStatus
from unittest.mock import MagicMock, patch

import pytest
import requests
from legal_api.models import Furnishing

from entity_emailer.email_processors import involuntary_dissolution_stage_1_notification
from tests.unit import create_business, create_furnishing # noqa: I003


def test_involuntary_dissolution_stage_1_notification(app, session):
@pytest.mark.parametrize(
'test_name, legal_type, furnishing_name', [
('TEST_BC_NO_AR', 'BC', Furnishing.FurnishingName.DISSOLUTION_COMMENCEMENT_NO_AR),
('TEST_XPRO_NO_AR', 'A', Furnishing.FurnishingName.DISSOLUTION_COMMENCEMENT_NO_AR_XPRO)
]
)
def test_involuntary_dissolution_stage_1_notification(app, session, test_name, legal_type, furnishing_name):
"""Assert that the test_involuntary_dissolution_stage_1_notification can be processed."""
token = 'token'
message_id = '16fd2111-8baf-433b-82eb-8c7fada84ccc'
business_identifier = 'BC1234567'
business = create_business(business_identifier, 'BC', 'Test Business')
furnishing = create_furnishing(session, business=business)
business = create_business(business_identifier, legal_type, 'Test Business')
furnishing = create_furnishing(session, business=business, furnishing_name=furnishing_name)
message_payload = {
'specversion': '1.x-wip',
'type': 'bc.registry.dissolution',
Expand Down Expand Up @@ -56,7 +64,12 @@ def test_involuntary_dissolution_stage_1_notification(app, session):

assert email['content']['subject'] == f'Attention {business_identifier} - Test Business'
assert email['recipients'] == 'test@test.com'
assert email['content']['body']
body = email['content']['body']
assert body
if test_name == 'TEST_XPRO_NO_AR':
assert 'Notice of Commencement of Cancellation' in body
else:
assert 'Notice of Commencement of Dissolution' in body
assert email['content']['attachments']
assert mock_get_pdfs.call_args[0][0] == token
assert mock_get_pdfs.call_args[0][1] == business
Expand Down

0 comments on commit bbd638f

Please sign in to comment.