From 599a8d51975ff84331370a222f8ad82b9d2c89c4 Mon Sep 17 00:00:00 2001 From: PaulGarewal Date: Tue, 9 Apr 2024 14:44:30 -0700 Subject: [PATCH 1/2] 20359 initial business summary updates --- .../src/legal_api/reports/business_document.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/legal-api/src/legal_api/reports/business_document.py b/legal-api/src/legal_api/reports/business_document.py index 58f17fa02e..9950e8bf42 100644 --- a/legal-api/src/legal_api/reports/business_document.py +++ b/legal-api/src/legal_api/reports/business_document.py @@ -121,7 +121,11 @@ def _get_template_data(self, get_json=False): # get document data business_json["reportType"] = self._document_key business_json["business"] = self._legal_entity.json() - business_json["business"]["businessName"] = self._legal_entity.business_name + if self._legal_entity.alternate_names: + business_json["business"]["businessName"] = self._legal_entity.alternate_names[0].name + else: + business_json["business"]["businessName"] = self._legal_entity.business_name + business_json["registrarInfo"] = {**RegistrarInfo.get_registrar_info(self._report_date_time)} self._set_description(business_json) self._set_epoch_date(business_json) @@ -303,6 +307,8 @@ def _set_parties(self, legal_entity: dict): party["mailingAddress"] = BusinessDocument._format_address(party["mailingAddress"]) if party.get("deliveryAddress"): party["deliveryAddress"] = BusinessDocument._format_address(party["deliveryAddress"]) + if not party.get("officer", {}).get("partyType") and not party.get("officer", {}).get("lastName"): + party["officer"]["partyType"] = "organization" legal_entity["parties"] = party_json def _set_name_translations(self, legal_entity: dict): @@ -343,7 +349,7 @@ def _set_record_keepers(self, legal_entity: dict): custodian_json = [ party_role.json for party_role in self._legal_entity.entity_roles.all() - if party_role.role.lower() == "custodian" + if party_role.role_type.lower() == "custodian" ] for custodian in custodian_json: custodian["mailingAddress"] = BusinessDocument._format_address(custodian["mailingAddress"]) @@ -456,7 +462,7 @@ def _format_state_filing(self, filing: Filing) -> dict: def _set_amalgamation_details(self, legal_entity: dict): """Set amalgamation filing data.""" amalgamated_businesses = [] - filings = Filing.get_filings_by_types(self._legal_entity.id, ["amalgamationApplication"]) + filings = Filing.get_filings_by_types(self._legal_entity, ["amalgamationApplication"]) if filings: amalgamation_application = filings[0] legal_entity["business"]["amalgamatedEntity"] = True @@ -518,7 +524,10 @@ def _format_address(address): def _set_meta_info(self, legal_entity: dict): legal_entity["environment"] = f"{self._get_environment()} BUSINESS #{self._legal_entity.identifier}".lstrip() legal_entity["meta_title"] = "Business Summary on {}".format(legal_entity["report_date_time"]) - legal_entity["meta_subject"] = "{} ({})".format(self._legal_entity.legal_name, self._legal_entity.identifier) + if self._legal_entity.alternate_names and self._legal_entity.legal_name == None: + legal_entity["meta_subject"] = "{} ({})".format(self._legal_entity.alternate_names[0].name, self._legal_entity.identifier) + else: + legal_entity["meta_subject"] = "{} ({})".format(self._legal_entity.legal_name, self._legal_entity.identifier) @staticmethod def _get_environment(): From 1c1f56addb3d721ea5189f36d9fd348127903f11 Mon Sep 17 00:00:00 2001 From: PaulGarewal Date: Thu, 11 Apr 2024 18:10:29 -0700 Subject: [PATCH 2/2] fixed linting --- legal-api/src/legal_api/reports/business_document.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/legal-api/src/legal_api/reports/business_document.py b/legal-api/src/legal_api/reports/business_document.py index 9950e8bf42..192ea5ecaf 100644 --- a/legal-api/src/legal_api/reports/business_document.py +++ b/legal-api/src/legal_api/reports/business_document.py @@ -125,7 +125,7 @@ def _get_template_data(self, get_json=False): business_json["business"]["businessName"] = self._legal_entity.alternate_names[0].name else: business_json["business"]["businessName"] = self._legal_entity.business_name - + business_json["registrarInfo"] = {**RegistrarInfo.get_registrar_info(self._report_date_time)} self._set_description(business_json) self._set_epoch_date(business_json) @@ -524,10 +524,14 @@ def _format_address(address): def _set_meta_info(self, legal_entity: dict): legal_entity["environment"] = f"{self._get_environment()} BUSINESS #{self._legal_entity.identifier}".lstrip() legal_entity["meta_title"] = "Business Summary on {}".format(legal_entity["report_date_time"]) - if self._legal_entity.alternate_names and self._legal_entity.legal_name == None: - legal_entity["meta_subject"] = "{} ({})".format(self._legal_entity.alternate_names[0].name, self._legal_entity.identifier) + if self._legal_entity.alternate_names and self._legal_entity.legal_name is None: + legal_entity["meta_subject"] = "{} ({})".format( + self._legal_entity.alternate_names[0].name, self._legal_entity.identifier + ) else: - legal_entity["meta_subject"] = "{} ({})".format(self._legal_entity.legal_name, self._legal_entity.identifier) + legal_entity["meta_subject"] = "{} ({})".format( + self._legal_entity.legal_name, self._legal_entity.identifier + ) @staticmethod def _get_environment():