-
Notifications
You must be signed in to change notification settings - Fork 73
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
22363 Continuation in email templates #2946
Changes from 4 commits
a94c160
ff21c45
18263b7
acda58c
cad7cb5
60951c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
from entity_queue_common.service_utils import logger | ||
from flask import current_app | ||
from jinja2 import Template | ||
from legal_api.models import Business, Filing | ||
from legal_api.models import Business, Filing, ReviewResult | ||
|
||
from entity_emailer.email_processors import ( | ||
get_entity_dashboard_url, | ||
|
@@ -66,6 +66,7 @@ def _get_pdfs( | |
) | ||
attach_order += 1 | ||
|
||
# add receipt | ||
corp_name = business.get('legalName') | ||
receipt = requests.post( | ||
f'{current_app.config.get("PAY_API_URL")}/{filing.payment_token}/receipts', | ||
|
@@ -91,6 +92,22 @@ def _get_pdfs( | |
} | ||
) | ||
attach_order += 1 | ||
|
||
elif status == 'RESUBMITTED': | ||
# add filing pdf | ||
filing_pdf_type = 'continuationIn' | ||
filing_pdf_encoded = get_filing_document(business['identifier'], filing.id, filing_pdf_type, token) | ||
if filing_pdf_encoded: | ||
pdfs.append( | ||
{ | ||
'fileName': 'Continuation Application - Resubmitted.pdf', | ||
'fileBytes': filing_pdf_encoded.decode('utf-8'), | ||
'fileUrl': '', | ||
'attachOrder': str(attach_order) | ||
} | ||
) | ||
attach_order += 1 | ||
|
||
elif status == Filing.Status.COMPLETED.value: | ||
# add certificate of continuation | ||
certificate_pdf_type = 'certificateOfContinuation' | ||
|
@@ -105,6 +122,7 @@ def _get_pdfs( | |
} | ||
) | ||
attach_order += 1 | ||
|
||
# add notice of articles | ||
noa_pdf_type = 'noticeOfArticles' | ||
noa_encoded = get_filing_document(business['identifier'], filing.id, noa_pdf_type, token) | ||
|
@@ -118,28 +136,29 @@ def _get_pdfs( | |
} | ||
) | ||
attach_order += 1 | ||
|
||
return pdfs | ||
|
||
|
||
def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-locals, , too-many-branches | ||
"""Build the email for Continuation notification.""" | ||
logger.debug('filing_notification: %s', email_info) | ||
# get template and fill in parts | ||
|
||
# get template vars from email info | ||
filing_type, status = email_info['type'], email_info['option'] | ||
|
||
# get template vars from filing | ||
filing, business, leg_tmz_filing_date, leg_tmz_effective_date = get_filing_info(email_info['filingId']) | ||
filing_name = filing.filing_type[0].upper() + ' '.join(re.findall('[a-zA-Z][^A-Z]*', filing.filing_type[1:])) | ||
filing_data = (filing.json)['filing'][f'{filing_type}'] | ||
if status == Filing.Status.PAID.value: | ||
business = filing_data['nameRequest'] | ||
business['identifier'] = filing.temp_reg | ||
|
||
template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/CONT-IN-{status}.html').read_text() | ||
filled_template = substitute_template_parts(template) | ||
# render template with vars | ||
legal_type = business.get('legalType') | ||
numbered_description = Business.BUSINESSES.get(legal_type, {}).get('numberedDescription') | ||
jnja_template = Template(filled_template, autoescape=True) | ||
review_result = ReviewResult.get_last_review_result(filing.id) | ||
# encode newlines in review comment only | ||
latest_review_comment = review_result.comments.replace('\n', '\\n') if review_result else None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# compute Foreign Jurisdiction string as in report.py and business_document.py | ||
country_code = filing_data['foreignJurisdiction']['country'] | ||
|
@@ -150,6 +169,12 @@ def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-l | |
region = pycountry.subdivisions.get(code=f'{country_code}-{region_code}') | ||
foreign_jurisdiction = f'{region.name}, {country.name}' if region else country.name | ||
|
||
# get template and fill in parts | ||
template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/CONT-IN-{status}.html').read_text() | ||
filled_template = substitute_template_parts(template) | ||
jnja_template = Template(filled_template, autoescape=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I simply moved a few things around to make sense, ie:
|
||
|
||
# render template with vars | ||
html_out = jnja_template.render( | ||
business=business, | ||
filing=filing_data, | ||
|
@@ -161,9 +186,13 @@ def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-l | |
email_header=filing_name.upper(), | ||
filing_type=filing_type, | ||
numbered_description=numbered_description, | ||
foreign_jurisdiction=foreign_jurisdiction | ||
foreign_jurisdiction=foreign_jurisdiction, | ||
latest_review_comment=latest_review_comment | ||
) | ||
|
||
# decode newlines to <br> for html output | ||
html_out = html_out.replace('\\n', '<br>') | ||
|
||
# get attachments | ||
pdfs = _get_pdfs(status, | ||
token, | ||
|
@@ -179,10 +208,18 @@ def process(email_info: dict, token: str) -> dict: # pylint: disable=too-many-l | |
|
||
# assign subject | ||
legal_name = business.get('legalName', None) | ||
if status == Filing.Status.PAID.value: | ||
subject = 'Confirmation of Filing from the Business Registry' | ||
if status == Filing.Status.APPROVED.value: | ||
subject = 'Results of your Filing from the Business Registry' | ||
elif status == Filing.Status.CHANGE_REQUESTED.value: | ||
subject = 'Change Requested from the Business Registry' | ||
elif status == Filing.Status.COMPLETED.value: | ||
subject = 'Continuation Documents from the Business Registry' | ||
elif status == Filing.Status.PAID.value: | ||
subject = 'Confirmation of Filing from the Business Registry' | ||
elif status == Filing.Status.REJECTED.value: | ||
subject = 'Results of your Filing from the Business Registry' | ||
elif status == 'RESUBMITTED': | ||
subject = 'Confirmation of Filing from the Business Registry' | ||
vysakh-menon-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
subject = f'{legal_name} - {subject}' if legal_name else subject | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<base href="/"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="referrer" content="origin-when-cross-origin"/> | ||
<meta name="author" content="BC Registries and Online Services"> | ||
<title>Results of your Continuation Application</title> | ||
[[style.html]] | ||
</head> | ||
|
||
<body> | ||
<table class="body-table" role="presentation"> | ||
<tr> | ||
<td> | ||
[[header.html]] | ||
|
||
<div class="container"> | ||
<!-- first section --> | ||
<p class="title-message bold">Results of your Continuation Application</p> | ||
|
||
<p>Your Continuation Authorization is <span class="bold">approved</span>.</p> | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- second section --> | ||
<p class="title-message bold">Your Next Steps</p> | ||
|
||
<ol class="outputs"> | ||
<li>Receive confirmation that your business has been continued in.</li> | ||
<li>Visit <a href="{{ entity_dashboard_url }}">BC Business Registry account</a> to access | ||
your business.</li> | ||
</ol> | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- third section --> | ||
[[continuation-application-details.html]] | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- fourth section --> | ||
<p class="title-message bold">Attached to this Email</p> | ||
|
||
<p>The following document is attached to this email:</p> | ||
<ul class="outputs"> | ||
<li>Continuation Application</li> | ||
</ul> | ||
|
||
[[business-dashboard-link.html]] | ||
|
||
<!-- fifth section --> | ||
[[24px.html]] | ||
[[footer.html]] | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<base href="/"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="referrer" content="origin-when-cross-origin"/> | ||
<meta name="author" content="BC Registries and Online Services"> | ||
<title>Results of your Continuation Application</title> | ||
[[style.html]] | ||
</head> | ||
|
||
<body> | ||
<table class="body-table" role="presentation"> | ||
<tr> | ||
<td> | ||
[[header.html]] | ||
|
||
<div class="container"> | ||
<!-- first section --> | ||
<p class="title-message bold">Results of your Continuation Application</p> | ||
|
||
<p>Your Continuation Authorization is <span class="bold">not yet approved</span>. Follow | ||
the steps below to modify and resubmit your application.</p> | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- second section --> | ||
<p class="title-message bold">Your Next Steps</p> | ||
|
||
<p>Follow these steps to complete your application:</p> | ||
<ol class="outputs"> | ||
<li>Visit <a href="{{ entity_dashboard_url }}">BC Business Registry account</a>.</li> | ||
<li>Modify the application to satisfy the request from staff as described below:</li> | ||
</ol> | ||
|
||
<pre class="bold">{{ latest_review_comment }}</pre> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-formatted looked the best to me (see sample above). |
||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- third section --> | ||
[[continuation-application-details.html]] | ||
|
||
<!-- fourth section --> | ||
[[24px.html]] | ||
[[footer.html]] | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<base href="/"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="referrer" content="origin-when-cross-origin"/> | ||
<meta name="author" content="BC Registries and Online Services"> | ||
<title>Results of your Continuation Application</title> | ||
[[style.html]] | ||
</head> | ||
|
||
<body> | ||
<table class="body-table" role="presentation"> | ||
<tr> | ||
<td> | ||
[[header.html]] | ||
|
||
<div class="container"> | ||
<!-- first section --> | ||
<p class="title-message bold">Results of your Continuation Application</p> | ||
|
||
<p>Your Continuation Authorization is <span class="bold">rejected</span> and a refund request | ||
has been submitted. The refund will be applied to your original payment method. Refunds | ||
are usually processed within 10-14 business days.</p> | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- second section --> | ||
<p class="title-message bold">Your Next Steps</p> | ||
|
||
<ol class="outputs"> | ||
<li>Review the reasons for rejected as outlined below:</li> | ||
<pre class="bold">{{ latest_review_comment }}</pre> | ||
<li>Visit <a href="{{ entity_dashboard_url }}">BC Business Registry account</a> to submit | ||
a new Continuation Application.</li> | ||
</ol> | ||
|
||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- third section --> | ||
[[continuation-application-details.html]] | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- fourth section --> | ||
<p class="title-message bold">Attached to this Email</p> | ||
|
||
<p>The following document is attached to this email:</p> | ||
<ul class="outputs"> | ||
<li>Continuation Application - Rejected</li> | ||
</ul> | ||
|
||
[[business-dashboard-link.html]] | ||
|
||
<!-- fifth section --> | ||
[[24px.html]] | ||
[[footer.html]] | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<base href="/"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="referrer" content="origin-when-cross-origin"/> | ||
<meta name="author" content="BC Registries and Online Services"> | ||
<title>Confirmation of Filing from the Business Registry</title> | ||
[[style.html]] | ||
</head> | ||
|
||
<body> | ||
<table class="body-table" role="presentation"> | ||
<tr> | ||
<td> | ||
[[header.html]] | ||
|
||
<div class="container"> | ||
<!-- first section --> | ||
<p class="title-message bold">We have received your updated Continuation Application</p> | ||
|
||
<p>BC Registries will review your Continuation Authorization documents and contact you | ||
with the results within 2 business days.</p> | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- second section --> | ||
[[continuation-application-details.html]] | ||
|
||
[[20px.html]] | ||
[[divider.html]] | ||
[[20px.html]] | ||
|
||
<!-- third section --> | ||
<p class="title-message bold">Attached to this Email</p> | ||
|
||
<p>The following document id attached to this email:</p> | ||
<ul class="outputs"> | ||
<li>Continuation Application - Pending</li> | ||
</ul> | ||
|
||
[[business-dashboard-link.html]] | ||
[[8px.html]] | ||
|
||
<p> | ||
Once your authorization has been approved, your business will be registered and you will | ||
receive the following outputs: | ||
</p> | ||
<ul class="outputs"> | ||
<li>Notice of Articles</li> | ||
<li>Certificate of Continuation</li> | ||
</ul> | ||
|
||
<!-- fourth section --> | ||
[[24px.html]] | ||
[[footer.html]] | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resubmitted is similar to "submitted" (ie, paid) except no receipt is attached.