From 426036b8b0a7c6115c71f660a2e880b29a260876 Mon Sep 17 00:00:00 2001 From: Shaoyun Tong <144159934+tshyun24@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:47:50 -0800 Subject: [PATCH] 11550 - AmalgamaTING and TED Business Summary PDF (#2398) * AmalTED pdf * Amalgamating pdf * remove Dissolution/Restoration Information section * fix lint error * lint with flake8 * lint --- .../report-templates/businessSummary.html | 1 + .../business-summary/amalgamating.html | 24 ++++++++++++++ .../business-summary/amalgamations.html | 6 ++-- .../business-summary/stateTransition.html | 2 +- .../legal_api/reports/business_document.py | 32 ++++++++++++++++++- 5 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 legal-api/report-templates/template-parts/business-summary/amalgamating.html diff --git a/legal-api/report-templates/businessSummary.html b/legal-api/report-templates/businessSummary.html index 0ffab74604..23b91fcdd5 100644 --- a/legal-api/report-templates/businessSummary.html +++ b/legal-api/report-templates/businessSummary.html @@ -35,6 +35,7 @@ [[business-summary/stateTransition.html]] [[business-summary/recordKeeper.html]] [[business-summary/amalgamations.html]] + [[business-summary/amalgamating.html]] [[common/addresses.html]] {% if business.legalType in ['GP', 'SP'] %} [[business-summary/parties.html]] diff --git a/legal-api/report-templates/template-parts/business-summary/amalgamating.html b/legal-api/report-templates/template-parts/business-summary/amalgamating.html new file mode 100644 index 0000000000..fd4a948ab4 --- /dev/null +++ b/legal-api/report-templates/template-parts/business-summary/amalgamating.html @@ -0,0 +1,24 @@ +{% if business.isAmalgamating %} +
+
+
Amalgamated Into
+
+ +
+ Name of Amalgamated Company: + {% if business.amalgamatedInto is defined %} + {{business.amalgamatedInto.legalName}} + {% else %} + Not Available + {% endif %} +
+ +
+ Incorporation Number: + {% if business.amalgamatedInto is defined %} + {{business.amalgamatedInto.identifier}} + {% else %} + Not Available + {% endif %} +
+{% endif %} \ No newline at end of file diff --git a/legal-api/report-templates/template-parts/business-summary/amalgamations.html b/legal-api/report-templates/template-parts/business-summary/amalgamations.html index 461475f50e..a9dda9be2c 100644 --- a/legal-api/report-templates/template-parts/business-summary/amalgamations.html +++ b/legal-api/report-templates/template-parts/business-summary/amalgamations.html @@ -1,15 +1,15 @@ {% if business.amalgamatedEntity %}
-
Amalgamating {{ entityShortDescription }}s Information
+
Amalgamating Corporation(s) Information
{% for entity in amalgamatedEntities %} diff --git a/legal-api/report-templates/template-parts/business-summary/stateTransition.html b/legal-api/report-templates/template-parts/business-summary/stateTransition.html index 2b0405368d..818141f0c7 100644 --- a/legal-api/report-templates/template-parts/business-summary/stateTransition.html +++ b/legal-api/report-templates/template-parts/business-summary/stateTransition.html @@ -1,4 +1,4 @@ -{% if stateFilings|length > 0 %} +{% if stateFilings|length > 0 and not business.isAmalgamating %}
diff --git a/legal-api/src/legal_api/reports/business_document.py b/legal-api/src/legal_api/reports/business_document.py index 0f605eddfb..e1cd40709d 100644 --- a/legal-api/src/legal_api/reports/business_document.py +++ b/legal-api/src/legal_api/reports/business_document.py @@ -22,6 +22,7 @@ from flask import current_app, jsonify from legal_api.models import AlternateName, CorpType, Filing, LegalEntity +from legal_api.models.amalgamation import Amalgamation from legal_api.reports.registrar_meta import RegistrarInfo from legal_api.resources.v2.business import get_addresses, get_directors from legal_api.resources.v2.business.business_parties import get_parties @@ -83,6 +84,7 @@ def _substitute_template_parts(template_code): template_parts = [ "business-summary/alterations", "business-summary/amalgamations", + "business-summary/amalgamating", "business-summary/businessDetails", "business-summary/liquidation", "business-summary/nameChanges", @@ -133,6 +135,7 @@ def _get_template_data(self, get_json=False): self._set_name_translations(business_json) self._set_business_changes(business_json) self._set_amalgamation_details(business_json) + self._set_amalgamating_details(business_json) self._set_liquidation_details(business_json) if self._legal_entity.entity_type in ["SP", "GP"]: @@ -326,6 +329,14 @@ def _set_business_state_changes(self, legal_entity: dict): ], ): state_filings.append(self._format_state_filing(filing)) + # If it is amalgamating business + if ((legal_entity.get("business").get("state") == "HISTORICAL") + and (legal_entity.get("business").get("amalgamatedInto"))): + amalgamating_business_temp = LegalEntity.find_by_identifier(legal_entity.get("business").get("identifier")) + amalgamating_business = amalgamating_business_temp.amalgamating_businesses.one_or_none() + amalgamation = Amalgamation.find_by_id(amalgamating_business.amalgamation_id) + filing = Filing.find_by_id(amalgamation.filing_id) + state_filings.append(self._format_state_filing(filing)) legal_entity["stateFilings"] = state_filings def _set_record_keepers(self, legal_entity: dict): @@ -440,6 +451,8 @@ def _format_state_filing(self, filing: Filing) -> dict: filing_meta["continuationOut"]["continuationOutDate"] ) filing_info["continuationOutDate"] = continuation_out_date.strftime(OUTPUT_DATE_FORMAT) + elif filing.filing_type == "amalgamationApplication": + filing_info["filingName"] = "Amalgamation" else: filing_info["filingName"] = BusinessDocument._get_summary_display_name(filing.filing_type, None, None) return filing_info @@ -450,10 +463,27 @@ def _set_amalgamation_details(self, legal_entity: dict): amalgamation_application = Filing.get_filings_by_types(self._legal_entity, ["amalgamationApplication"]) if amalgamation_application: legal_entity["business"]["amalgamatedEntity"] = True - # else condition will have to be added when we do amalgamation in the new system + amalgamation_json = amalgamation_application[0].filing_json.get("filing", {})\ + .get("amalgamationApplication", {}) + # if it's future effective if self._epoch_filing_date and amalgamation_application[0].effective_date < self._epoch_filing_date: amalgamated_businesses_info = {"legalName": NOT_AVAILABLE, "identifier": NOT_AVAILABLE} amalgamated_businesses.append(amalgamated_businesses_info) + else: + amalgamating_businesses = amalgamation_json.get("amalgamatingBusinesses", {}) + while amalgamating_businesses: + if len(amalgamating_businesses[0].get("foreignJurisdiction", {})) == 0: + identifier = amalgamating_businesses[0].get("identifier", {}) + else: + identifier = amalgamating_businesses[0].get("corpNumber", {}) + amalgamating_business = legal_entity.find_by_identifier(identifier) + business_legal_name = amalgamating_business.legal_name + amalgamated_businesses_info = { + "legalName": business_legal_name, + "identifier": identifier + } + amalgamated_businesses.append(amalgamated_businesses_info) + amalgamating_businesses.remove(amalgamating_businesses[0]) legal_entity["amalgamatedEntities"] = amalgamated_businesses def _set_liquidation_details(self, legal_entity: dict):