Skip to content

Commit

Permalink
19433 amalgamation state filing fix (bcgov#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Jan 25, 2024
1 parent 7661f42 commit 4623a52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if business.amalgamatedEntity %}
{% if amalgamatedEntities|length > 0 %}
<div class="no-page-break">
<div class="separator mt-4"></div>
<div class="section-title mt-4">Amalgamating Businesses Information</div>
Expand Down
48 changes: 23 additions & 25 deletions legal-api/src/legal_api/reports/business_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,11 @@ def _set_business_state_changes(self, business: dict):
'continuationOut']):
state_filings.append(self._format_state_filing(filing))
# If it is amalgamating business
if ((business.get('business').get('state') == 'HISTORICAL')
and (business.get('business').get('amalgamatedInto'))):
amalgamating_business_temp = Business.find_by_identifier(business.get('business').get('identifier'))
amalgamating_business = amalgamating_business_temp.amalgamating_businesses.one_or_none()
if business.get('business').get('amalgamatedInto'):
amalgamating_business = self._business.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))
state_filings.insert(0, self._format_state_filing(filing))
business['stateFilings'] = state_filings

def _set_record_keepers(self, business: dict):
Expand Down Expand Up @@ -423,52 +421,51 @@ def _format_state_filing(self, filing: Filing) -> dict:
continuation_out_date = LegislationDatetime.as_legislation_timezone_from_date_str(
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

def _set_amalgamation_details(self, business: dict):
"""Set the list of partial amalgamation filing data."""
"""Set amalgamation filing data."""
amalgamated_businesses = []
amalgamation_application = Filing.get_filings_by_types(self._business.id, ['amalgamationApplication'])
if amalgamation_application:
filings = Filing.get_filings_by_types(self._business.id, ['amalgamationApplication'])
if filings:
amalgamation_application = filings[0]
business['business']['amalgamatedEntity'] = True
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:
if self._epoch_filing_date and amalgamation_application.effective_date < self._epoch_filing_date:
# imported from COLIN
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', {})
amalgamation = self._business.amalgamation.one_or_none()
amalgamating_businesses = amalgamation.amalgamating_businesses.all()
for amalgamating_business in amalgamating_businesses:
if ting_business := Business.find_by_internal_id(amalgamating_business.business_id):
identifier = ting_business.identifier
business_legal_name = ting_business.legal_name
else:
identifier = amalgamating_businesses[0].get('corpNumber', {})
amalgamating_business = Business.find_by_identifier(identifier)
business_legal_name = amalgamating_business.legal_name
identifier = amalgamating_business.foreign_corp_num or 'Not Available'
business_legal_name = amalgamating_business.foreign_name or 'Not Available'

amalgamated_businesses_info = {
'legalName': business_legal_name,
'identifier': identifier
}
amalgamated_businesses.append(amalgamated_businesses_info)
amalgamating_businesses.remove(amalgamating_businesses[0])
business['amalgamatedEntities'] = amalgamated_businesses

def _set_amalgamating_details(self, business: dict):
amalgamating_info = business.get('business', {}).get('amalgamatedInto')
amalgamated_entity = business.get('business', {}).get('amalgamatedEntity')
if amalgamating_info:
business['business']['isAmalgamating'] = True
if amalgamated_entity:
business['business']['amalgamatedEntity'] = False
if business.get('amalgamatedEntities'):
# Amalgamating business can contain amalgamatedEntities when it is created through an amalgamation
# (if a business was a TED and it is now a TING). No need to show amalgamating businesses information
business['amalgamatedEntities'] = []

def _set_liquidation_details(self, business: dict):
"""Set partial liquidation filing data."""
Expand Down Expand Up @@ -528,6 +525,7 @@ def _get_legal_type_description(legal_type: str) -> str:
return corp_type.full_desc if corp_type else ''

FILING_SUMMARY_DISPLAY_NAME = {
'amalgamationApplication': 'Amalgamation',
'dissolution': {
'voluntary': {
'CP': 'Voluntary Dissolution',
Expand Down

0 comments on commit 4623a52

Please sign in to comment.