Esempio n. 1
0
def process(correction_filing: Filing, filing: Dict):
    """Render the correction filing onto the business model objects."""
    local_timezone = pytz.timezone('US/Pacific')

    # link to original filing
    original_filing = Filing.find_by_id(
        filing['correction']['correctedFilingId'])
    original_filing.parent_filing = correction_filing

    # add comment to the original filing
    original_filing.comments.append(
        Comment(
            comment=f'This filing was corrected on '
            f'{correction_filing.filing_date.astimezone(local_timezone).date().isoformat()}.',
            staff_id=correction_filing.submitter_id))

    # add comment to the correction filing
    correction_filing.comments.append(
        Comment(comment=filing['correction']['comment'],
                staff_id=correction_filing.submitter_id))
    if not any('incorporationApplication' in x
               for x in correction_filing.legal_filings()):
        # set correction filing to PENDING_CORRECTION, for manual intervention
        # - include flag so that listener in Filing model does not change state automatically to COMPLETE
        correction_filing._status = Filing.Status.PENDING_CORRECTION.value  # pylint: disable=protected-access
        setattr(correction_filing, 'skip_status_listener', True)

    original_filing.save_to_session()
    return correction_filing
def test_incorporation_filing_bc_company_from_colin(app, session, legal_type):
    """Assert that an existing bc company(LTD, ULC, CCC) incorporation is loaded corrrectly."""
    # setup
    corp_num = 'BC0000001'
    colind_id = 1
    filing = copy.deepcopy(INCORPORATION_FILING_TEMPLATE)

    # Change the template to be LTD, ULC or CCC
    filing['filing']['business']['legalType'] = legal_type
    filing['filing']['business']['identifier'] = corp_num
    filing['filing']['incorporationApplication']['nameRequest']['legalType'] = legal_type
    effective_date = datetime.utcnow()
    # Create the Filing object in the DB
    filing_rec = Filing(effective_date=effective_date,
                        filing_json=filing)
    colin_event = ColinEventId()
    colin_event.colin_event_id = colind_id
    filing_rec.colin_event_ids.append(colin_event)
    # Override the state setting mechanism
    filing_rec.skip_status_listener = True
    filing_rec._status = 'PENDING'
    filing_rec.save()
    filing_meta = FilingMeta(application_date=filing_rec.effective_date)

    # test
    business, filing_rec, filing_meta = incorporation_filing.process(None, filing, filing_rec, filing_meta=filing_meta)

    # Assertions
    assert business.identifier == corp_num
    assert business.founding_date.replace(tzinfo=None) == effective_date
    assert business.legal_type == filing['filing']['incorporationApplication']['nameRequest']['legalType']
    assert business.legal_name == business.identifier[2:] + ' B.C. LTD.'
    assert len(business.offices.all()) == 2  # One office is created in create_business method.
    assert len(business.share_classes.all()) == 2
    assert len(business.party_roles.all()) == 3
Esempio n. 3
0
def test_conversion_coop_from_colin(app, session):
    """Assert that an existing coop incorporation is loaded corrrectly."""
    # setup
    identifier = 'CP0000001'
    colind_id = 1
    filing = copy.deepcopy(CONVERSION_FILING_TEMPLATE)

    # Change the template to be a CP == Cooperative
    filing['filing']['business']['legalType'] = 'CP'
    filing['filing']['business']['identifier'] = identifier
    filing['filing']['conversion']['nameRequest']['legalType'] = 'CP'
    filing['filing']['conversion'].pop('shareStructure')
    effective_date = datetime.utcnow()
    # Create the Filing obeject in the DB
    filing_rec = Filing(effective_date=effective_date,
                        filing_json=filing)
    colin_event = ColinEventId()
    colin_event.colin_event_id=colind_id
    filing_rec.colin_event_ids.append(colin_event)
    # Override the state setting mechanism
    filing_rec.skip_status_listener = True
    filing_rec._status = 'PENDING'
    filing_rec.save()

    # test
    business, filing_rec = conversion.process(None, filing, filing_rec)

    # Assertions
    assert business.identifier == identifier
    assert business.founding_date.replace(tzinfo=None) == effective_date.replace(tzinfo=None)
    assert business.legal_type == filing['filing']['conversion']['nameRequest']['legalType']
    assert business.legal_name == business.identifier[2:] + ' B.C. LTD.'
    assert len(business.offices.all()) == 2  # One office is created in create_business method.
Esempio n. 4
0
def create_filing(filing_type, colin_filing, colin_event_id, corp_num):
    """Create legal api filing using colin filing as base"""
    effective_date = colin_filing['filing']['business']['foundingDate']
    colin_filing['filing']['business']['identifier'] = corp_num
    filing = Filing(effective_date=effective_date, filing_json=colin_filing)
    filing._filing_type = filing_type
    filing.filing_date = effective_date
    colin_event = ColinEventId()
    colin_event.colin_event_id = colin_event_id
    filing.colin_event_ids.append(colin_event)

    # Override the state setting mechanism
    filing.skip_status_listener = True
    filing._status = 'PENDING'
    filing.source = Filing.Source.COLIN.value
    return filing