Beispiel #1
0
def create_office(business, addresses, office_type):
    office = Office()
    office.office_type = office_type
    office.addresses = addresses

    if business.offices is None:
        business.offices = []

    business.offices.append(office)
Beispiel #2
0
def create_office(business: Business, addresses: list, office_type: str):
    """Create office and link it to business."""
    office = Office()
    office.office_type = office_type
    office.addresses = addresses

    if business.offices is None:
        business.offices = []

    business.offices.append(office)
Beispiel #3
0
def create_office(business, office_type, addresses) -> Office:
    """Create a new office for incorporation."""
    office = Office()
    office.office_type = office_type
    office.addresses = []
    # Iterate addresses and add to this office
    for k, v in addresses.items():
        address = create_address(v, k)
        address.business_id = business.id
        if address:
            office.addresses.append(address)
    return office
Beispiel #4
0
def test_business_relationships_json(session):
    """Assert that the business model is saved correctly."""
    from legal_api.models import Address, Office

    business = Business(legal_name='legal_name',
                        founding_date=EPOCH_DATETIME,
                        last_ledger_timestamp=EPOCH_DATETIME,
                        identifier='CP1234567',
                        last_modified=EPOCH_DATETIME)

    office = Office(office_type='registeredOffice')
    mailing_address = Address(city='Test City',
                              address_type=Address.MAILING,
                              business_id=business.id)
    office.addresses.append(mailing_address)
    business.offices.append(office)
    business.save()

    assert business.mailing_address.one_or_none()

    delivery_address = Address(city='Test City',
                               address_type=Address.DELIVERY,
                               business_id=business.id)
    office.addresses.append(delivery_address)
    business.save()

    assert business.delivery_address.one_or_none()
Beispiel #5
0
def create_office(business, office_type=None):
    from legal_api.models import Office
    if office_type == None:
        office_type = 'registeredOffice'

    office = list(
        filter(lambda x: x.office_type == office_type, business.offices))

    if len(office) == 0:
        office = Office(office_type='registeredOffice')

        if office_type:
            office = Office(office_type=office_type)

        business.offices.append(office)
        business.save()
    return business
Beispiel #6
0
def factory_business_mailing_address(business):
    """Create a business entity."""
    address = Address(city='Test City',
                      street=f'{business.identifier}-Test Street',
                      postal_code='T3S3T3',
                      country='TA',
                      region='BC',
                      address_type=Address.MAILING)

    office = Office(office_type='registeredOffice')

    office.addresses.append(address)
    business.offices.append(office)
    business.save()
    return business
Beispiel #7
0
def test_mailing_address_save_to_business(session):
    """Assert that the address saves correctly."""
    identifier = 'CP1234567'
    business = factory_business(identifier)

    address = Address(city='Test City',
                      street=f'{identifier}-Test Street',
                      postal_code='T3S3T3',
                      country='TA',
                      region='BC',
                      address_type=Address.MAILING)
    office = Office(office_type='registeredOffice')
    office.addresses.append(address)
    business.offices.append(office)
    business.save()

    mailing = business.mailing_address.one_or_none()
    assert mailing.id
Beispiel #8
0
def create_business_address(business, type):
    """Create an address."""
    from legal_api.models import Address, Office
    address = Address(
        city='Test City',
        street=f'{business.identifier}-Test Street',
        postal_code='T3S3T3',
        country='TA',
        region='BC',
    )
    if type == 'mailing':
        address.address_type = Address.MAILING
    else:
        address.address_type = Address.DELIVERY

    office = Office(office_type='registeredOffice')
    office.addresses.append(address)
    business.offices.append(office)
    business.save()
    return business