Skip to content

Commit

Permalink
22235 Legal API - Create endpoint for retrieving stage 1 AR letter (b…
Browse files Browse the repository at this point in the history
…cgov#2849)

* 22235-legal-api-create endpoint for retrieving stage 1 AR (major updates)

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* misc related updates

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* update furnishing job stage one to populate address for both email & mail scenarios

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* fix linting

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* handle bad data

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* fix typo

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* specify user roles for endpoint

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* fix typo

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* 1password & related updates

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* update address position

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* update address type for furnishing address

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* remove handling for bad data

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* remove FURNISHING type in address model & fix broken tests in furnishings job

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* rename 'output_type' to 'variant'

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

---------

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>
  • Loading branch information
chenhongjing authored Jul 24, 2024
1 parent 075a7a7 commit e36f105
Show file tree
Hide file tree
Showing 23 changed files with 2,229 additions and 23 deletions.
25 changes: 9 additions & 16 deletions jobs/furnishings/src/furnishings/stage_processors/stage_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,24 @@ async def _send_first_round_notification(self, batch_processing: BatchProcessing
# send email/letter notification for the first time
email = self._get_email_address_from_auth(batch_processing.business_identifier)
business = Business.find_by_identifier(batch_processing.business_identifier)
if email:
# send email letter
new_furnishing = self._create_new_furnishing(
new_furnishing = self._create_new_furnishing(
batch_processing,
eligible_details,
Furnishing.FurnishingType.EMAIL,
business.last_ar_date if business.last_ar_date else business.founding_date,
business.legal_name,
email
)
# notify emailer
mailing_address = business.mailing_address.one_or_none()
if mailing_address:
self._create_furnishing_address(mailing_address, new_furnishing.id)
if email:
# send email letter
await self._send_email(new_furnishing)
else:
# send paper letter if business doesn't have email address
new_furnishing = self._create_new_furnishing(
batch_processing,
eligible_details,
Furnishing.FurnishingType.MAIL,
business.last_ar_date if business.last_ar_date else business.founding_date,
business.legal_name
)

mailing_address = business.mailing_address.one_or_none()
if mailing_address:
self._create_furnishing_address(mailing_address, new_furnishing.id)
new_furnishing.furnishing_type = Furnishing.FurnishingType.MAIL
new_furnishing.save()

# TODO: create and add letter to either AR or transition pdf
# TODO: send AR and transition pdf to BCMail+
Expand Down Expand Up @@ -192,7 +185,7 @@ def _create_new_furnishing( # pylint: disable=too-many-arguments
def _create_furnishing_address(self, mailing_address: Address, furnishings_id: int) -> Address:
"""Clone business mailing address to be used by mail furnishings."""
furnishing_address = Address(
address_type=Address.FURNISHING,
address_type=mailing_address.address_type,
street=mailing_address.street,
street_additional=mailing_address.street_additional,
city=mailing_address.city,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_get_email_address_from_auth(session, test_name, mock_return):
async def test_process_first_notification(app, session, test_name, entity_type, email, expected_furnishing_name):
"""Assert that the first notification furnishing entry is created correctly."""
business = factory_business(identifier='BC1234567', entity_type=entity_type)
factory_address(address_type=Address.MAILING, business_id=business.id)
mailing_address = factory_address(address_type=Address.MAILING, business_id=business.id)
batch = factory_batch()
factory_batch_processing(
batch_id=batch.id,
Expand Down Expand Up @@ -129,7 +129,7 @@ async def test_process_first_notification(app, session, test_name, entity_type,
assert len(furnishing_addresses) == 1
furnishing_address = furnishing_addresses[0]
assert furnishing_address
assert furnishing_address.address_type == Address.FURNISHING
assert furnishing_address.address_type == mailing_address.address_type
assert furnishing_address.furnishings_id == furnishing.id
assert furnishing_address.business_id == None
assert furnishing_address.office_id == None
Expand Down Expand Up @@ -160,7 +160,7 @@ async def test_process_first_notification(app, session, test_name, entity_type,
async def test_process_second_notification(app, session, test_name, has_email_furnishing, has_mail_furnishing, is_email_elapsed):
"""Assert that the second notification furnishing entry is created correctly."""
business = factory_business(identifier='BC1234567')
factory_address(address_type=Address.MAILING, business_id=business.id)
mailing_address = factory_address(address_type=Address.MAILING, business_id=business.id)
batch = factory_batch()
factory_batch_processing(
batch_id=batch.id,
Expand Down Expand Up @@ -210,7 +210,7 @@ async def test_process_second_notification(app, session, test_name, has_email_fu
assert len(furnishing_addresses) == 1
furnishing_address = furnishing_addresses[0]
assert furnishing_address
assert furnishing_address.address_type == Address.FURNISHING
assert furnishing_address.address_type == mailing_address.address_type
assert furnishing_address.furnishings_id == mail_furnishing.id
assert furnishing_address.business_id == None
assert furnishing_address.office_id == None
Expand Down
3 changes: 2 additions & 1 deletion legal-api/devops/vaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
{
"vault": "api",
"application": [
"mras-api"
"mras-api",
"report-api-gotenberg"
]
}
]
81 changes: 81 additions & 0 deletions legal-api/report-templates/noticeOfDissolutionCommencement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Notice of Commencement of Dissolution</title>
<meta charset="UTF-8">
<meta name="author" content="BC Registries and Online Services">
{% if variant == 'default' %}
[[common/v2/style.html]]
{% else %}
[[common/v2/styleMail.html]]
{% endif %}
</head>
<body>
<div class="letter-copy">
{% if furnishing.mailingAddress %}
<div class="container address-container ml-3">
{% if furnishing.mailingAddress.streetAddressAdditional %}
<div class="address-container-additional-info">
{% else %}
<div class="address-container-no-additional-info">
{% endif %}
<div>{{ furnishing.businessName }}</div>
<div>{{ furnishing.mailingAddress.streetAddress }}</div>
<div>{{ furnishing.mailingAddress.streetAddressAdditional }}</div>
<div>
{{ furnishing.mailingAddress.addressCity }}
{{ furnishing.mailingAddress.addressRegion }}
&nbsp;{{ furnishing.mailingAddress.postalCode }}
</div>
</div>
</div>
{% endif %}
<div class="container letter-container ml-3">
<div class="mt-5"><span class="bold">No Annual Reports Filed Since {{ furnishing.lastARDate }} for {{ furnishing.businessIdentifier }}</span></div>
<div class="mt-5">To file an annual report online, log in to your Business Page at <a href="https://www.business.bcregistry.gov.bc.ca/{{ furnishing.businessIdentifier }}" class="break-url">business.bcregistry.gov.bc.ca/<wbr>{{ furnishing.businessIdentifier }}</a> to file any outstanding annual reports listed.</div>
<div class="mt-5">Under section 422 of the Business Corporation Act (the Act), this letter is to notify you that your company has for two years failed to file the annual reports required under section 51 of the Act. A company must annually, within two months after each anniversary of the date on which the company was recognized, file an annual report with the Registrar.</div>
<div class="mt-5">If within one month after the date of this letter, the company fails to file the outstanding annual reports, a notice may be published on the BC Laws website www.bclaws.ca. This notice will state that, at any time after the expiration of one month after the date of publication of the notice, the company will be dissolved, unless cause is shown to the contrary; I am satisfied the failure has been or is being remedied; or a copy of the entered court order to the contrary has been filed.</div>

{% if furnishing.foreignRegistrations %}
<div class="mt-5">
Our records indicate your company is registered in
{% if furnishing.foreignRegistrations|length == 1 %}
{{ furnishing.foreignRegistrations[0] }}
{% elif furnishing.foreignRegistrations|length == 2 %}
{{ furnishing.foreignRegistrations[0] }} and {{ furnishing.foreignRegistrations[1] }}
{% else %}
{{ furnishing.foreignRegistrations[0] }}, {{ furnishing.foreignRegistrations[1] }}, and {{ furnishing.foreignRegistrations[2] }}
{% endif %}
as an extraprovincial company. Therefore, if your company is dissolved, its registration as an extraprovincial company in
{% if furnishing.foreignRegistrations|length == 1 %}
{{ furnishing.foreignRegistrations[0] }}
{% elif furnishing.foreignRegistrations|length == 2 %}
{{ furnishing.foreignRegistrations[0] }} and {{ furnishing.foreignRegistrations[1] }}
{% else %}
{{ furnishing.foreignRegistrations[0] }}, {{ furnishing.foreignRegistrations[1] }}, and {{ furnishing.foreignRegistrations[2] }}
{% endif %}
will automatically be cancelled as well.
</div>
{% endif %}

<div class="mt-5">To request a delay of the dissolution, go to <a href="https://www.business.bcregistry.gov.bc.ca/{{ furnishing.businessIdentifier }}" class="break-url">business.bcregistry.gov.bc.ca/{{ furnishing.businessIdentifier }}</a> and request for a Delay of Dissolution or Cancellation under the To Do section. This must be completed prior to the dissolution of the company.</div>
<div class="mt-5">If your company is dissolved under section 422(1)(a) of the Act, section 347 of the Act states the liability of each director, officer, shareholder and liquidator of a company that is dissolved continues and may be enforced as if the company had not been dissolved.</div>
<div class="mt-5">If you have filed the outstanding annual reports, no further action is required.</div>
<div class="mt-5">If you need help with setting up an account or managing a business, please visit our Resources and Help page at <a href="https://bcreg.ca/resources" class="break-url">bcreg.ca/resources</a></div>

<p class="mt-5"><i><span class="bold">Issued</span> on my behalf on {{ furnishing.processedDate }}</i></p>
<div class="registrar-info">
<div>[[common/certificateRegistrarSignature.html]]</div>
<div>
<div class="registrar-name"><span class="bold">{{ registrarInfo.name }}</span></div>
<div class="registrar-title">{{ registrarInfo.title }}</div>
</div>
<div class="mt-2">
<div class="registry-info"><span class="bold">BC Registries and Online Services</span></div>
<div class="registry-contact"><span class="bold">Toll-Free Phone:</span> 1-877-526-1526</div>
</div>
</div>
</div>
</div>
</body>
</html>
68 changes: 68 additions & 0 deletions legal-api/report-templates/template-parts/common/v2/footer.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions legal-api/report-templates/template-parts/common/v2/header.html

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions legal-api/report-templates/template-parts/common/v2/headerMail.html

Large diffs are not rendered by default.

603 changes: 603 additions & 0 deletions legal-api/report-templates/template-parts/common/v2/style.html

Large diffs are not rendered by default.

635 changes: 635 additions & 0 deletions legal-api/report-templates/template-parts/common/v2/styleMail.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions legal-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ecdsa==0.14.1
expiringdict==1.1.4
flask-jwt-oidc==0.3.0
flask-restx==0.3.0
google-auth==2.16.2
gunicorn==20.1.0
idna==2.10
itsdangerous==1.1.0
Expand Down
4 changes: 4 additions & 0 deletions legal-api/src/legal_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ class _Config(): # pylint: disable=too-few-public-methods
MRAS_SVC_URL = os.getenv('MRAS_SVC_URL')
MRAS_SVC_API_KEY = os.getenv('MRAS_SVC_API_KEY')

# GCP Gotenberg report service
REPORT_API_GOTENBERG_AUDIENCE = os.getenv('REPORT_API_GOTENBERG_AUDIENCE', '')
REPORT_API_GOTENBERG_URL = os.getenv('REPORT_API_GOTENBERG_URL', 'https://')

TESTING = False
DEBUG = False

Expand Down
1 change: 1 addition & 0 deletions legal-api/src/legal_api/exceptions/error_messages/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ class ErrorCode(AutoName):
FILING_NOT_FOUND = auto()
MISSING_BUSINESS = auto()
NOT_AUTHORIZED = auto()
FURNISHING_NOT_FOUND = auto()
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
ErrorCode.MISSING_BUSINESS: 'Business not found for identifier: {identifier}',
ErrorCode.FILING_NOT_FOUND: 'Filing: {filing_id} not found for: {identifier}',
ErrorCode.NOT_AUTHORIZED: 'Not authorized to access business: {identifier}',
ErrorCode.FURNISHING_NOT_FOUND: 'Furnishing: {furnishing_id} not found for identifier: {identifier}'
}
3 changes: 1 addition & 2 deletions legal-api/src/legal_api/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class Address(db.Model): # pylint: disable=too-many-instance-attributes

MAILING = 'mailing'
DELIVERY = 'delivery'
FURNISHING = 'furnishing'
ADDRESS_TYPES = [MAILING, DELIVERY, FURNISHING]
ADDRESS_TYPES = [MAILING, DELIVERY]
JSON_MAILING = 'mailingAddress'
JSON_DELIVERY = 'deliveryAddress'
JSON_ADDRESS_TYPES = [JSON_MAILING, JSON_DELIVERY]
Expand Down
Loading

0 comments on commit e36f105

Please sign in to comment.