示例#1
0
    def create_corporation(cls, con, filing_info: Dict):
        """Insert a new business from an incorporation filing."""
        try:
            business = Business()
            business.corp_name = filing_info['business']['legalName']
            business.corp_num = filing_info['business']['identifier']
            business.founding_date = convert_to_pacific_time(
                filing_info['header']['learEffectiveDate'])

            if filing_info['business'][
                    'legalType'] in cls.CORP_TYPE_CONVERSION[
                        cls.LearBusinessTypes.BCOMP.value]:
                business.corp_num = business.corp_num[-7:]
                business.corp_type = Business.TypeCodes.BCOMP.value
            else:
                business.corp_type = Business.TypeCodes.COOP.value

            cursor = con.cursor()

            # Expand query as NR data/ business info becomes more aparent
            cursor.execute("""
                insert into CORPORATION (CORP_NUM, CORP_TYP_CD, RECOGNITION_DTS)
                values (:corp_num, :corp_type, TO_TIMESTAMP_TZ(:recognition_date,'YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM'))
                """,
                           corp_num=business.corp_num,
                           corp_type=business.corp_type,
                           recognition_date=business.founding_date)

            return business

        except Exception as err:
            current_app.logger.error('Error inserting business.')
            raise err
示例#2
0
 def _add_filings(con, json_data: dict, filing_list: list, identifier: str,
                  corp_types: list) -> list:
     """Process all parts of the filing."""
     filings_added = []
     for filing_type in filing_list:
         filing = Filing()
         filing.header = json_data['header']
         filing.filing_date = filing.header['date']
         filing.filing_type = filing_type
         filing.body = filing_list[filing_type]
         print('body: ', filing.body)
         # get utc lear effective date and convert to pacific time for insert into oracle
         filing.effective_date = convert_to_pacific_time(
             filing.header['learEffectiveDate'])
         if filing_type != 'incorporationApplication':
             filing.business = Business.find_by_identifier(
                 identifier, corp_types, con)
         else:
             filing.business = Business.create_corporation(con, json_data)
         # add the new filing
         event_id = Filing.add_filing(con, filing)
         filings_added.append({
             'event_id': event_id,
             'filing_type': filing_type
         })
     return filings_added