Skip to content
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

20359 Initial business summary updates #2575

Closed
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
21 changes: 17 additions & 4 deletions legal-api/src/legal_api/reports/business_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Copy link
Contributor Author

@PaulGarewal PaulGarewal Apr 9, 2024

Choose a reason for hiding this comment

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

handles an odd case when the partner of a firm is an organization, partyType will not be populated. Does not handle when there are 2 partner organizations yet.

Example in FM1000051

My initial changes were getting out of hand to handle this fully, so looking for cleaner suggestions.


def _set_name_translations(self, legal_entity: dict):
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -518,7 +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"])
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 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
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kept getting an error here when the conditional was met, handles that case but needs improvement.

@staticmethod
def _get_environment():
Expand Down
Loading