Skip to content

Commit

Permalink
21954 - Sync involuntary dissolutions back to COLIN (bcgov#2911)
Browse files Browse the repository at this point in the history
* 21954 - Sync involuntary dissolutions back to COLIN (colin-api & legal-api updates)

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

* update to find batch_processing by filing_id

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>

---------

Signed-off-by: Hongjing Chen <Hongjing.Chen@gov.bc.ca>
  • Loading branch information
chenhongjing authored Aug 13, 2024
1 parent 8c22de3 commit ac86125
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
2 changes: 2 additions & 0 deletions colin-api/src/colin_api/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class CorpStateTypes(Enum):
VOLUNTARY_DISSOLUTION = 'HDV'
ADMINISTRATIVE_DISSOLUTION = 'HDA'
AMALGAMATED = 'HAM'
INVOLUNTARY_DISSOLUTION_NO_AR = 'HDF'
INVOLUNTARY_DISSOLUTION_NO_TR = 'HDT'

NUMBERED_CORP_NAME_SUFFIX = {
TypeCodes.BCOMP.value: 'B.C. LTD.',
Expand Down
25 changes: 24 additions & 1 deletion colin-api/src/colin_api/models/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class FilingSource(Enum):
# `voluntaryDissolution filing type in place as unsure if it is being used in other places
'dissolution': {
'sub_type_property': 'dissolutionType',
'sub_type_list': ['voluntary', 'administrative'],
'sub_type_list': ['voluntary', 'administrative', 'involuntary'],
'type_code_list': ['OTVDS', 'ADVD2'],
'voluntary': {
Business.TypeCodes.COOP.value: 'OTVDS',
Expand Down Expand Up @@ -996,6 +996,29 @@ def add_administrative_dissolution_event(cls, con, corp_num) -> int:
Business.CorpStateTypes.ADMINISTRATIVE_DISSOLUTION.value)
return event_id

@classmethod
def add_involuntary_dissolution_event(cls, con, corp_num, filing_body) -> int:
"""Add involuntary dissolution event."""
if not (filing_meta_data := filing_body.get('metaData')):
return None

event_type = None
corp_state = None
if filing_meta_data.get('overdueARs'):
event_type = 'SYSDF'
corp_state = Business.CorpStateTypes.INVOLUNTARY_DISSOLUTION_NO_AR.value
elif filing_meta_data.get('overdueTransition'):
event_type = 'SYSDT'
corp_state = Business.CorpStateTypes.INVOLUNTARY_DISSOLUTION_NO_TR.value

if event_type:
cursor = con.cursor()
event_id = cls._get_event_id(cursor=cursor, corp_num=corp_num, event_type=event_type)
Business.update_corp_state(cursor, event_id, corp_num, corp_state)
return event_id

return None

# pylint: disable=too-many-locals,too-many-statements,too-many-branches,too-many-nested-blocks;
@classmethod
def add_filing(cls, con, filing: Filing) -> int:
Expand Down
12 changes: 9 additions & 3 deletions colin-api/src/colin_api/resources/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ def post(legal_type, identifier, **kwargs):
con.begin()

# No filing will be created for administrative dissolution. Create an event and update corp state.
if ('dissolution' in filing_list and
Filing.get_filing_sub_type('dissolution', filing_list['dissolution']) == 'administrative'):
if (
'dissolution' in filing_list and
(filing_sub_type := Filing.get_filing_sub_type('dissolution', filing_list['dissolution']))
in ['administrative', 'involuntary']
):
if legal_type == Business.TypeCodes.COOP.value:
raise Exception('Not implemented!') # pylint: disable=broad-exception-raised
event_id = Filing.add_administrative_dissolution_event(con, identifier)
if filing_sub_type == 'administrative':
event_id = Filing.add_administrative_dissolution_event(con, identifier)
else:
event_id = Filing.add_involuntary_dissolution_event(con, identifier, filing_list['dissolution'])
con.commit()
return jsonify({
'filing': {
Expand Down
17 changes: 16 additions & 1 deletion legal-api/src/legal_api/resources/v2/business/colin_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
from flask_cors import cross_origin

from legal_api.exceptions import BusinessException
from legal_api.models import AmalgamatingBusiness, Amalgamation, Business, Filing, PartyRole, UserRoles, db
from legal_api.models import (
AmalgamatingBusiness,
Amalgamation,
BatchProcessing,
Business,
Filing,
PartyRole,
UserRoles,
db,
)
from legal_api.models.colin_event_id import ColinEventId
from legal_api.services.business_details_version import VersionedBusinessDetailsService
from legal_api.utils.auth import jwt
Expand Down Expand Up @@ -76,6 +85,12 @@ def get_completed_filings_for_colin():
except Exception as ex: # noqa: B902
current_app.logger.info(ex)
continue # do not break this function because of one filing
elif (filing.filing_type == 'dissolution' and
filing.filing_sub_type == 'involuntary'):
batch_processings = BatchProcessing.find_by(filing_id=filing.id)
if not batch_processings:
continue # skip filing for missing batch processing info
filing_json['filing']['dissolution']['metaData'] = batch_processings[0].meta_data

filings.append(filing_json)
return jsonify({
Expand Down

0 comments on commit ac86125

Please sign in to comment.