Skip to content

Commit

Permalink
Tombstone - Updates to support legacy ledger display name
Browse files Browse the repository at this point in the history
Signed-off-by: Hongjing Chen <[email protected]>
  • Loading branch information
chenhongjing committed Jan 9, 2025
1 parent 580b8fd commit 81779c4
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 9 deletions.
111 changes: 107 additions & 4 deletions data-tool/flows/tombstone/tombstone_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def has_value(cls, value):

EventFilings.FILE_ADVD2: ['dissolution', 'voluntary'],
EventFilings.FILE_ADVDS: ['dissolution', 'voluntary'],
EventFilings.DISLV_NULL: ['dissolution', 'voluntary'],
EventFilings.DISLC_NULL: ['dissolution', 'administrative'],
EventFilings.DISLV_NULL: ['dissolution', 'voluntary'], # TODO: re-map
EventFilings.DISLC_NULL: ['dissolution', 'administrative'], # TODO: re-map
EventFilings.SYSDA_NULL: ['dissolution', 'administrative'],
EventFilings.SYSDS_NULL: ['dissolution', 'administrative'],
EventFilings.SYSDF_NULL: ['dissolution', 'involuntary'],
Expand All @@ -220,7 +220,7 @@ def has_value(cls, value):
EventFilings.FILE_ICORP: 'incorporationApplication',
EventFilings.FILE_ICORU: 'incorporationApplication',
EventFilings.FILE_ICORC: 'incorporationApplication',
EventFilings.CONVICORP_NULL: 'incorporationApplication',
EventFilings.CONVICORP_NULL: 'incorporationApplication', # TODO: re-map

# TODO: Ledger - unsupported
# TODO: Legacy Other - unsupported
Expand Down Expand Up @@ -249,6 +249,110 @@ def has_value(cls, value):
}


EVENT_FILING_DISPLAY_NAME_MAPPING = {
EventFilings.FILE_AGMDT: 'Notice of Change - AGM Date',
EventFilings.FILE_AGMLC: 'Notice of Change - AGM Location',

EventFilings.FILE_NOALA: 'Notice of Alteration',
EventFilings.FILE_NOALB: 'Notice of Alteration from a BC Unlimited Liability Company to Become a BC Company',
EventFilings.FILE_NOALU: 'Notice of Alteration from a BC Company to Become a BC Unlimited Liability Company',
EventFilings.FILE_NOALC: 'Notice of Alteration from a BC Company to Become a Community Contribution Company',
EventFilings.FILE_AM_BC: 'Amendment - Translated Name',
EventFilings.FILE_AM_LI: 'Amendment - Ledger Information',
EventFilings.FILE_AM_RM: 'Amendment - Receiver or Receiver Manager',
EventFilings.FILE_AM_SS: 'Amendment - Share Structure',

# TODO: Amalgamation Out Consent - unsupported
# TODO: Amalgamation Out - unsupported

EventFilings.FILE_AMALH: 'Amalgamation Application Short Form (Horizontal)',
EventFilings.FILE_AMALR: 'Amalgamation Application (Regular)',
EventFilings.FILE_AMALV: 'Amalgamation Application Short Form (Vertical)',
EventFilings.FILE_AMLHU: 'Amalgamation Application Short Form (Horizontal) for a BC Unlimited Liability Company',
EventFilings.FILE_AMLRU: 'Amalgamation Application (Regular) for a BC Unlimited Liability Company',
EventFilings.FILE_AMLVU: 'Amalgamation Application Short Form (Vertical) for a BC Unlimited Liability Company',
EventFilings.FILE_AMLHC: 'Amalgamation Application Short Form (Horizontal) for a Community Contribution Company',
EventFilings.FILE_AMLRC: 'Amalgamation Application (Regular) for a Community Contribution Company',
EventFilings.FILE_AMLVC: 'Amalgamation Application Short Form (Vertical) for a Community Contribution Company',

EventFilings.FILE_ANNBC: 'BC Annual Report', # has suffix of date, dynamically add it during formatting

EventFilings.FILE_APTRA: 'Application to Transfer Registered Office',
EventFilings.FILE_NOERA: 'Notice of Elimination of Registered Office',
EventFilings.FILE_NOCAD: 'Notice of Change of Address',
EventFilings.FILE_AM_DO: 'Amendment - Dissolved Office',
EventFilings.FILE_AM_RR: 'Amendment - Registered and Records Offices',

EventFilings.FILE_NOCDR: 'Notice of Change of Directors', # TODO: some has suffix - Address Change or Name Correction Only
EventFilings.FILE_AM_DI: 'Amendment - Director',

EventFilings.FILE_CONTO: '6 Months Consent to Continue Out',
EventFilings.FILE_COUTI: 'Instrument of Continuation Out',

EventFilings.FILE_CONTI: 'Continuation Application',
EventFilings.FILE_CONTU: 'Continuation Application for a BC Unlimited Liability Company',
EventFilings.FILE_CONTC: 'Continuation Application for a Community Contribution Company',

EventFilings.FILE_CO_AR: 'Correction - Annual Report',
EventFilings.FILE_CO_BC: 'Correction - BC Company Name/Translated Name',
EventFilings.FILE_CO_DI: 'Correction - Director',
EventFilings.FILE_CO_DO: 'Correction - Dissolved Office',
EventFilings.FILE_CO_LI: 'Correction - Ledger Information',
EventFilings.FILE_CO_PF: 'Correction - Put Back Off',
EventFilings.FILE_CO_PO: 'Correction - Put Back On',
EventFilings.FILE_CO_RM: 'Correction - Receiver or Receiver Manager',
EventFilings.FILE_CO_RR: 'Correction - Registered and Records Offices',
EventFilings.FILE_CO_SS: 'Correction - Share Structure',
EventFilings.FILE_CO_TR: 'Correction - Transition',
EventFilings.FILE_CORRT: 'Correction',

EventFilings.FILE_COURT: 'Court Order',

# TODO: Delay of Dissolution - unsupported (need confirmation)
EventFilings.DISD1_DISDE: "Registrar''s Notation - Dissolution or Cancellation Delay", # has prefix "Registrar's Notation - "
EventFilings.DISD2_DISDE: "Registrar''s Notation - Dissolution or Cancellation Delay",

EventFilings.FILE_ADVD2: 'Application for Dissolution (Voluntary Dissolution)',
EventFilings.FILE_ADVDS: 'Application for Dissolution (Voluntary Dissolution)',
EventFilings.DISLV_NULL: None, # TODO: re-map, voluntary - no ledger in colin + status liquidated
EventFilings.DISLC_NULL: None, # TODO: re-map, admin - no ledger in colin + status liquidated
EventFilings.SYSDA_NULL: None, # admin - status Administrative Dissolution
EventFilings.SYSDS_NULL: None, # admin - status Administrative Dissolution
EventFilings.SYSDF_NULL: None, # invol - no ledger in lear & colin
EventFilings.SYSDT_NULL: None, # invol - no ledger in lear & colin

EventFilings.FILE_ICORP: 'Incorporation Application',
EventFilings.FILE_ICORU: 'Incorporation Application for a BC Unlimited Liability Company',
EventFilings.FILE_ICORC: 'Incorporation Application for a Community Contribution Company',
EventFilings.CONVICORP_NULL: None, # TODO: re-map

# TODO: Ledger - unsupported
# TODO: Legacy Other - unsupported
EventFilings.FILE_AM_PF: 'Amendment - Put Back Off',
EventFilings.FILE_AM_PO: 'Amendment - Put Back On',
EventFilings.FILE_AM_TR: 'Amendment - Transition',

# TODO: Liquidation - unsupported

EventFilings.FILE_NWITH: 'Notice of Withdrawal',

EventFilings.FILE_REGSN: "Registrar''s Notation",
EventFilings.FILE_REGSO: "Registrar''s Order",

EventFilings.FILE_RESTL: 'Restoration Application - Limited',
EventFilings.FILE_RESTF: 'Restoration Application - Full',
EventFilings.FILE_RESXL: 'Restoration Application (Extend Time Limit)',
EventFilings.FILE_RESXF: 'Restoration Application (Convert Limited to Full)',
EventFilings.FILE_RUSTL: 'Restoration Application - Limited for a BC Unlimited Liability Company',
EventFilings.FILE_RUSTF: 'Restoration Application - Full for a BC Unlimited Liability Company',
EventFilings.FILE_RUSXL: 'Restoration Application (Extend Time Limit) for a BC Unlimited Liability Company',
EventFilings.FILE_RUSXF: 'Restoration Application (Convert Limited to Full) for a BC Unlimited Liability Company',

EventFilings.FILE_TRANS: 'Transition Application',
EventFilings.FILE_TRANP: 'Post Restoration Transition Application',
}


LEAR_FILING_BUSINESS_UPDATE_MAPPING = {
'incorporationApplication': ['last_coa_date', 'last_cod_date'],
'changeOfAddress': ['last_coa_date'],
Expand All @@ -272,4 +376,3 @@ def has_value(cls, value):
# ingore the following since we won't map to them
# 'dissolved', 'restorationApplication', 'continuedOut'
]

24 changes: 19 additions & 5 deletions data-tool/flows/tombstone/tombstone_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import copy
from decimal import Decimal
import json
from datetime import datetime, timezone
from decimal import Decimal

import pandas as pd
import pytz
from sqlalchemy import Connection, text
from tombstone.tombstone_base_data import (ALIAS, AMALGAMATION, FILING, FILING_JSON, OFFICE,
PARTY, PARTY_ROLE, RESOLUTION,
from tombstone.tombstone_base_data import (ALIAS, AMALGAMATION, FILING,
FILING_JSON, OFFICE, PARTY,
PARTY_ROLE, RESOLUTION,
SHARE_CLASSES, USER)
from tombstone.tombstone_mappings import (EVENT_FILING_LEAR_TARGET_MAPPING,
from tombstone.tombstone_mappings import (EVENT_FILING_DISPLAY_NAME_MAPPING,
EVENT_FILING_LEAR_TARGET_MAPPING,
LEAR_FILING_BUSINESS_UPDATE_MAPPING,
LEAR_STATE_FILINGS)
LEAR_STATE_FILINGS, EventFilings)

unsupported_event_file_types = set()

Expand Down Expand Up @@ -443,6 +445,7 @@ def build_filing_json_meta_data(filing_type: str, filing_subtype: str, effective
'eventId': int(data['e_event_id'])
},
'isLedgerPlaceholder': True,
'colinDisplayName': get_colin_display_name(data)
}

if filing_type == 'annualReport':
Expand Down Expand Up @@ -477,6 +480,17 @@ def build_filing_json_meta_data(filing_type: str, filing_subtype: str, effective
return filing_json, meta_data


def get_colin_display_name(data: dict) -> str:
event_file_type = data['event_file_type']
name = EVENT_FILING_DISPLAY_NAME_MAPPING.get(event_file_type)
if event_file_type == EventFilings.FILE_ANNBC.value:
ar_dt_str = data['f_period_end_dt_str']
ar_dt = datetime.strptime(ar_dt_str, '%Y-%m-%d %H:%M:%S%z')
suffix = ar_dt.strftime('%b %d, %Y').upper()
name = f'{name} - {suffix}'
return name


def build_epoch_filing(business_id: int) -> dict:
now = datetime.utcnow().replace(tzinfo=pytz.UTC)
filing = copy.deepcopy(FILING['filings'])
Expand Down
4 changes: 4 additions & 0 deletions legal-api/src/legal_api/core/meta/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ class FilingMeta: # pylint: disable=too-few-public-methods
@staticmethod
def display_name(business: Business, filing: FilingStorage) -> Optional[str]:
"""Return the name of the filing to display on outputs."""
# if filing is imported from COLIN and has custom disaply name
if filing.meta_data and filing.meta_data.get('isLedgerPlaceholder'):
if displayName := filing.meta_data.get('colinDisplayName'):
return displayName
# if there is no lookup
if not (names := FILINGS.get(filing.filing_type, {}).get('displayName')):
if not (filing.filing_sub_type and
Expand Down

0 comments on commit 81779c4

Please sign in to comment.