Skip to content

Commit

Permalink
Merge branch 'main' into api-spec-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AimeeGao authored Aug 20, 2024
2 parents 2e2216c + ff2d445 commit 938d17b
Show file tree
Hide file tree
Showing 166 changed files with 5,899 additions and 1,126 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/entity-filer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install docker-compose
run: |
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
- name: Install dependencies
run: |
make setup
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/legal-api-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install docker-compose
run: |
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
- name: Install dependencies
run: |
make setup
Expand Down
7 changes: 1 addition & 6 deletions colin-api/devops/vaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
"application": [
"colin-api",
"test-oracle",
"sentry",
"jwt",
"launchdarkly"
]
},
{
"vault": "sentry",
"application": [
"entity"
]
}
]
3 changes: 2 additions & 1 deletion colin-api/src/colin_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class _Config: # pylint: disable=too-few-public-methods

SQLALCHEMY_TRACK_MODIFICATIONS = False

SENTRY_DSN = os.getenv('SENTRY_DSN', '')
SENTRY_DSN = os.getenv('SENTRY_DSN') or ''
SENTRY_DSN = '' if SENTRY_DSN.lower() == 'null' else SENTRY_DSN

LD_SDK_KEY = os.getenv('LD_SDK_KEY', None)

Expand Down
2 changes: 2 additions & 0 deletions colin-api/src/colin_api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Model imports."""
from .address import Address
from .business import Business
from .corp_involved import CorpInvolved
from .corp_name import CorpName
from .corp_party import Party
from .filing_type import FilingType
from .jurisdiction import Jurisdiction
from .office import Office
from .program_account import ProgramAccount
from .shares import ShareObject
26 changes: 8 additions & 18 deletions colin-api/src/colin_api/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class CorpStateTypes(Enum):

VOLUNTARY_DISSOLUTION = 'HDV'
ADMINISTRATIVE_DISSOLUTION = 'HDA'
AMALGAMATED = 'HAM'
INVOLUNTARY_DISSOLUTION_NO_AR = 'HDF'
INVOLUNTARY_DISSOLUTION_NO_TR = 'HDT'
CONTINUE_IN = 'HCI'

NUMBERED_CORP_NAME_SUFFIX = {
TypeCodes.BCOMP.value: 'B.C. LTD.',
Expand Down Expand Up @@ -173,7 +177,10 @@ def _get_bn_15s(cls, cursor, identifiers: List) -> Dict:
for row in cursor.fetchall():
row = dict(zip([x[0].lower() for x in cursor.description], row))
if row['bn_15']:
bn_15s[f'BC{row["corp_num"]}'] = row['bn_15']
if row['corp_num'].isdecimal(): # valid only for BC
bn_15s[f'BC{row["corp_num"]}'] = row['bn_15']
else:
bn_15s[row['corp_num']] = row['bn_15']
return bn_15s

except Exception as err:
Expand Down Expand Up @@ -361,23 +368,6 @@ def create_corporation(cls, con, filing_info: Dict):
current_app.logger.error('Error inserting business.')
raise err

@classmethod
def create_corp_jurisdiction(cls, cursor, corp_num: str, event_id: str):
"""Add record to the JURISDICTION table on incorporation."""
try:
cursor.execute(
"""
insert into JURISDICTION (CORP_NUM, START_EVENT_ID, STATE_TYP_CD)
values (:corp_num, :event_id, 'ACT')
""",
corp_num=corp_num,
event_id=event_id
)

except Exception as err:
current_app.logger.error('Error inserting jurisdiction.')
raise err

@classmethod
def create_corp_restriction(cls, cursor, event_id: str, corp_num: str, provisions: bool):
"""Create corp restriction entry for business."""
Expand Down
121 changes: 121 additions & 0 deletions colin-api/src/colin_api/models/corp_involved.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Copyright © 2024 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Meta information about the service.
Currently this only provides API versioning information
"""
from __future__ import annotations

from typing import List

from flask import current_app

from colin_api.resources.db import DB


class CorpInvolved:
"""Corp Involved object."""

event_id = None
corp_involve_id = None
corp_num = None
can_jur_typ_cd = None
adopted_corp_ind = None
home_juri_num = None
othr_juri_desc = None
foreign_nme = None

def __init__(self):
"""Initialize with all values None."""

def as_dict(self):
"""Return dict camel case version of self."""
return {
'eventId': self.event_id,
'corpInvolveId': self.corp_involve_id,
'corpNum': self.corp_num,
'canJurTypCd': self.can_jur_typ_cd,
'adoptedCorpInd': self.adopted_corp_ind,
'homeJuriNum': self.home_juri_num,
'othrJuriDesc': self.othr_juri_desc,
'foreignName': self.foreign_nme,
}

@classmethod
def _create_corp_involved_objs(cls, cursor) -> List:
"""Return a CorpInvolved obj by parsing cursor."""
corps_involved = cursor.fetchall()

corp_involved_objs = []
for corp_involved in corps_involved:
corp_involved = dict(zip([x[0].lower() for x in cursor.description], corp_involved))
corp_involved_obj = CorpInvolved()
corp_involved_obj.event_id = corp_involved['event_id']
corp_involved_obj.corp_involve_id = corp_involved['corp_involve_id']
corp_involved_obj.corp_num = corp_involved['corp_num']
corp_involved_obj.can_jur_typ_cd = corp_involved['can_jur_typ_cd']
corp_involved_obj.adopted_corp_ind = corp_involved['adopted_corp_ind']
corp_involved_obj.home_juri_num = corp_involved['home_juri_num']
corp_involved_obj.othr_juri_desc = corp_involved['othr_juri_desc']
corp_involved_obj.foreign_nme = corp_involved['foreign_nme']
corp_involved_objs.append(corp_involved_obj)

return corp_involved_objs

@classmethod
def create_corp_involved(cls, cursor, corp_involved_obj) -> CorpInvolved:
"""Add record to the CORP INVOLVED table."""
try:
cursor.execute(
"""
insert into CORP_INVOLVED (EVENT_ID, CORP_INVOLVE_ID, CORP_NUM, CAN_JUR_TYP_CD, ADOPTED_CORP_IND,
HOME_JURI_NUM, OTHR_JURI_DESC, FOREIGN_NME)
values (:event_id, :corp_involve_id, :corp_num, :can_jur_typ_cd, :adopted_corp_ind,
:home_juri_num, :othr_juri_desc, :foreign_nme)
""",
event_id=corp_involved_obj.event_id,
corp_involve_id=corp_involved_obj.corp_involve_id,
corp_num=corp_involved_obj.corp_num,
can_jur_typ_cd=corp_involved_obj.can_jur_typ_cd,
adopted_corp_ind=corp_involved_obj.adopted_corp_ind,
home_juri_num=corp_involved_obj.home_juri_num,
othr_juri_desc=corp_involved_obj.othr_juri_desc,
foreign_nme=corp_involved_obj.foreign_nme,
)

except Exception as err:
current_app.logger.error(f'Error inserting corp involved for event {corp_involved_obj.event_id}.')
raise err

@classmethod
def get_by_event(cls, cursor, event_id: str) -> List[CorpInvolved]:
"""Get the corps involved with the given event id."""
querystring = (
"""
select event_id, corp_involve_id, corp_num, can_jur_typ_cd, adopted_corp_ind, home_juri_num,
othr_juri_desc, foreign_nme, dd_event_id
from corp_involved
where event_id=:event_id
"""
)

try:
if not cursor:
cursor = DB.connection.cursor()
cursor.execute(querystring, event_id=event_id)
return cls._create_corp_involved_objs(cursor=cursor)

except Exception as err:
current_app.logger.error(f'error getting corp involved for event {event_id}')
raise err
Loading

0 comments on commit 938d17b

Please sign in to comment.