Skip to content

Commit

Permalink
Merge pull request #352 from ianco/master
Browse files Browse the repository at this point in the history
Fix the company query when the company is in the other database (COLIN vs LEAR)
  • Loading branch information
WadeBarnes authored May 16, 2024
2 parents 25640a6 + 3ac28b8 commit 7ae8956
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion data-pipeline/bcreg/bcreg_lear.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ def get_basic_corp_info_from_colin(self, corp_num):
corp['state_typ_cd'] = row[8]
cur.close()
cur = None
#LOGGER.error("Returning corp from COLIN: {corp}")
return corp
except (Exception, psycopg2.DatabaseError) as error:
LOGGER.error(error)
Expand Down Expand Up @@ -813,7 +814,13 @@ def get_bc_reg_corp_info(self, corp_num):
try:
corp = self.get_basic_corp_info(corp_num, versions=False)
corp_type = corp['corp_typ_cd']
if corp_type in LEAR_CORP_TYPES_IN_SCOPE:
if (not corp_type or corp_type == ''):
# corp not found in LEAR, return basic data from COLIN
corp = self.get_basic_corp_info_from_colin(corp_num)
corp['versions'] = {}
corp['parties'] = []
return corp
elif corp_type in LEAR_CORP_TYPES_IN_SCOPE:
corp['versions'] = self.get_basic_corp_info(corp_num, versions=True)
else:
corp['versions'] = {}
Expand Down
12 changes: 7 additions & 5 deletions data-pipeline/bcreg/eventprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ def is_owner_of_sole_prop(self, party, corp_num, corp_info):

# check if we should build a relationship credential for the given party record
def should_generate_relationship_credential(self, party, prev_event, last_event, corp_num, corp_info):
#LOGGER.info("should_generate_relationship_credential", party['corp_num'], party['bus_company_num'], party['party_typ_cd'])
#LOGGER.info(f"??? should_generate_relationship_credential: {party}")
if not 'corp_info' in party:
#LOGGER.info(" --> no corp_info, return False")
return False;
Expand All @@ -1182,10 +1182,10 @@ def should_generate_relationship_credential(self, party, prev_event, last_event,

# check if either company is "withdrawn"
if 'corp_typ_cd' in corp_info and corp_info['corp_typ_cd'] == CORP_WITHDRAWN_STATE:
LOGGER.info(" --> corp_info['corp_typ_cd'] is 'withdrawn', return False")
#LOGGER.info(" --> corp_info['corp_typ_cd'] is 'withdrawn', return False")
return False
if 'corp_typ_cd' in party['corp_info'] and party['corp_info']['corp_typ_cd'] == CORP_WITHDRAWN_STATE:
LOGGER.info(" --> party['corp_info']['corp_typ_cd'] is 'withdrawn', return False")
#LOGGER.info(" --> party['corp_info']['corp_typ_cd'] is 'withdrawn', return False")
return False

# special case where the corp_num and bus_company_num are the same
Expand All @@ -1211,7 +1211,7 @@ def should_generate_relationship_credential(self, party, prev_event, last_event,

# ... AND it belongs to the correct company type/party type logic
if self.is_owned_sole_prop(party, corp_num, corp_info) or self.is_owner_of_sole_prop(party, corp_num, corp_info):
#LOGGER.info(" --->", self.is_owned_sole_prop(party, corp_num, corp_info), self.is_owner_of_sole_prop(party, corp_num, corp_info))
#LOGGER.info(" ---> owned/owner: " + str(self.is_owned_sole_prop(party, corp_num, corp_info)) + ", " + str(self.is_owner_of_sole_prop(party, corp_num, corp_info)))
return True

#LOGGER.info(" ---> fall-through, return False")
Expand Down Expand Up @@ -1980,7 +1980,9 @@ def process_corp_event_queue_internal(self, system_type_cd, load_regs=True, gene
corp_info_json = bc_registries.to_json(corp_info)
prev_event_json = corp['PREV_EVENT']
last_event_json = corp['LAST_EVENT']
if corp_info['corp_typ_cd'] in corp_types:
if corp_info['corp_typ_cd'] is null or corp_info['corp_typ_cd'] == '':
LOGGER.error(f"Error no corp_type: {corp_info_json}")
elif corp_info['corp_typ_cd'] in corp_types:
corp_in_scope = True
elif corp_info['corp_typ_cd'] in other_in_scope_corps:
corp_in_scope_other = True
Expand Down

0 comments on commit 7ae8956

Please sign in to comment.