Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def get_recipients(option: str, filing_json: dict, token: str | None = None, fil
):
recipients = f"{recipients}, {', '.join(party_emails)}"

elif not is_coop:
# only add business email recipient for non-coop
else:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only case this was effecting for coops was annualReport which is now skipped earlier

recipients = get_recipient_from_auth(identifier, token)

return recipients
Expand All @@ -99,7 +98,7 @@ def get_recipient_from_auth(identifier: str, token: str) -> str:
f'{current_app.config.get("AUTH_URL")}/entities/{identifier}',
headers=headers
)
contacts = contact_info.json()["contacts"]
contacts = (contact_info.json()).get("contacts")

if not contacts:
current_app.logger.error("Queue Error: No email in business (%s) profile to send output to.", identifier, exc_info=True)
Expand All @@ -111,7 +110,7 @@ def get_recipient_from_auth(identifier: str, token: str) -> str:
def get_user_email_from_auth(user_name: str, token: str) -> str:
"""Get user email from auth."""
user_info = get_user_from_auth(user_name, token)
contacts = user_info.json()["contacts"]
contacts = (user_info.json()).get("contacts")

if not contacts:
return user_info.json().get("email") # idir user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"""Email processing rules and actions corp filing notifications."""
from __future__ import annotations

import copy
from contextlib import suppress

from flask import current_app
from jinja2 import Template

Expand Down Expand Up @@ -42,36 +45,46 @@ def _get_additional_info(filing: Filing) -> dict:
if filing.filing_type == "alteration":
meta_data_alteration = filing.meta_data.get("alteration", {}) if filing.meta_data else {}
additional_info["nameChange"] = "toLegalName" in meta_data_alteration
elif filing.filing_type == "specialResolution":
additional_info["nameChange"] = filing.filing_json["filing"].get("changeOfName")
additional_info["rulesChange"] = bool(filing.filing_json["filing"].get("alteration", {}).get("rulesFileKey"))

return additional_info


def _get_additional_recipients(filing: Filing, token: str) -> str:
def _get_additional_recipients(filing: Filing, token: str) -> str | None:
"""Get additional recipients for a filing type."""
submitter_recipient_filings = ["alteration", "changeOfRegistration", "dissolution", "specialResolution"]
if filing.filing_type in submitter_recipient_filings:
optional_email = filing.filing_json["filing"]["header"].get("documentOptionalEmail")
if filing.submitter_roles and UserRoles.staff in filing.submitter_roles and optional_email:
if filing.submitter_roles and UserRoles.staff in filing.submitter_roles:

@kialj876 kialj876 Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is true and theres no optional email we don't actually want it to add the staff user email (reason for the change)

# when staff do filing documentOptionalEmail may contain completing party email
return optional_email
return filing.filing_json["filing"]["header"].get("documentOptionalEmail")
else:
return get_user_email_from_auth(filing.filing_submitter.username, token)


def _get_attachments_and_extra_pdf_types(status: str, filing_type: str, filing: Filing, legal_type_key: str) -> tuple[list[str], list[str]]:
"""Get attachments for a filing type."""
attachments = FILING_ATTACHMENTS.get(legal_type_key, {}).get(filing_type, {}).get("attachments", [])
extra_pdf_types = FILING_ATTACHMENTS.get(legal_type_key, {}).get(filing_type, {}).get("extraPdfTypes", [])
attachments = copy.deepcopy(FILING_ATTACHMENTS.get(legal_type_key, {}).get(filing_type, {}).get("attachments", []))
extra_pdf_types = copy.deepcopy(FILING_ATTACHMENTS.get(legal_type_key, {}).get(filing_type, {}).get("extraPdfTypes", []))

# filing sub type overrides attachments and extraPdfTypes if present
if filing.filing_sub_type and (attachments_sub := FILING_ATTACHMENTS.get(legal_type_key, {}).get(f"{filing_type}-{filing.filing_sub_type}", {})):
if filing.filing_sub_type and (attachments_sub := copy.deepcopy(FILING_ATTACHMENTS.get(legal_type_key, {}).get(f"{filing_type}-{filing.filing_sub_type}", {}))):
attachments = attachments_sub.get("attachments", [])
extra_pdf_types = attachments_sub.get("extraPdfTypes", [])
# filing attachments with change of name cert can override attachments and extraPdfTypes if present
if (_get_additional_info(filing).get("nameChange", False)
and (attachments_con := FILING_ATTACHMENTS.get(legal_type_key, {}).get(f"{filing_type}-con", {}))
):
attachments = attachments_con.get("attachments", [])
extra_pdf_types = attachments_con.get("extraPdfTypes", [])

# adjust attachments for some filings that have dynamic attachments based on the filing data
additional_info = _get_additional_info(filing)
with suppress(ValueError):
if not additional_info.get("nameChange"):
# remove con if in the attachments list
attachments.remove("Certificate of Name Change")
extra_pdf_types.remove("certificateOfNameChange")

if not additional_info.get("rulesChange"):
# remove cr if in the attachments list
attachments.remove("Certified Rules")
extra_pdf_types.remove("certifiedRules")

if status != Filing.Status.COMPLETED.value:
extra_pdf_types = []
Expand All @@ -84,7 +97,7 @@ def _skip_email_check(status: str, filing: Filing, legal_type: str, filing_name:
invalid_status = (status not in [Filing.Status.COMPLETED.value, Filing.Status.PAID.value]
or (status == Filing.Status.PAID.value and not filing.is_future_effective))
invalid_data = not legal_type or not filing_name or not business_identifier
skipped_coop_filing_types = ["changeOfDirectors", "changeOfAddress"]
skipped_coop_filing_types = ["annualReport", "changeOfDirectors", "changeOfAddress"]
invalid_coop_filing = legal_type == Business.LegalTypes.COOP.value and filing.filing_type in skipped_coop_filing_types

return invalid_status or invalid_data or invalid_coop_filing
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"continuationIn": "Continuation Application",
"incorporationApplication": "Incorporation Application",
"registration": "Registration",
"specialResolution": "Special Resolution"
}

FILING_TITLE_SHORT = {
Expand All @@ -62,14 +63,14 @@
"incorporationApplication": {
"attachments": ["Incorporation Application","Certificate of Incorporation","Certified Rules","Memorandum","Receipt"],
"extraPdfTypes": ["certificateOfIncorporation","certifiedRules","certifiedMemorandum"],
}
},
"specialResolution": {
"attachments": ["Special Resolution","Special Resolution Application","Certificate of Name Change","Certified Rules","Receipt"],
"extraPdfTypes": ["specialResolutionApplication","certificateOfNameChange","certifiedRules"],
},
},
"CORP": {
"alteration": {
"attachments": ["Alteration","Notice of Articles","Receipt"],
"extraPdfTypes": ["noticeOfArticles"],
},
"alteration-con": {
"attachments": ["Alteration","Notice of Articles","Certificate of Name Change","Receipt"],
"extraPdfTypes": ["noticeOfArticles","certificateOfNameChange"],
},
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Your have successfully filed your special resolution with the BC Business Registry

---

[[business-tombstone.md]]

---

[[attachments.md]]

---

[[business-registry-footer.md]]
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
notice_of_withdrawal_notification,
nr_notification,
restoration_notification,
special_resolution_notification,
)
from business_emailer.email_processors.util import FILING_TITLE
from business_emailer.exceptions import EmailException, QueueException
Expand Down Expand Up @@ -166,6 +165,7 @@ def send_email(email: dict, token: str):
)
current_app.logger.debug("NOTIFY API response: %s", resp.status_code)
if resp.status_code != HTTPStatus.OK:
current_app.logger.debug("NOTIFY API error: %s", resp.json())
raise EmailException
except Exception:
# this should log the error and put the email msg back on the queue
Expand Down Expand Up @@ -256,9 +256,6 @@ def process_email(ce: SimpleCloudEvent): # pylint: disable=too-many-branches, t
elif etype == "continuationOut" and option == Filing.Status.COMPLETED.value:
email = continuation_out_notification.process(email_msg["email"], token)
send_email(email, token)
elif etype == "specialResolution":
email = special_resolution_notification.process(email_msg["email"], token)
send_email(email, token)
elif etype == "continuationIn" and option in ReviewStatus._member_names_:
# Special case for review step of continuation in filing. Regular filing notifications are handled by the filing_notification processor.
email = continuation_in_notification.process(email_msg["email"], token)
Expand All @@ -279,7 +276,7 @@ def process_email(ce: SimpleCloudEvent): # pylint: disable=too-many-branches, t
if email := filing_notification.process(email_msg["email"], token):
send_email(email, token)
else:
# should only be if this was for a coops filing
# should only be if this was for a coops filing or an invalid publish option
current_app.logger.debug("No email to send for: %s", email_msg)
else:
current_app.logger.debug("No email to send for: %s", email_msg)
Loading
Loading