Example #1
0
def test_get_or_create_by_document_with_existing_person(
        store, example_creator):
    person = example_creator.create_person()
    individual = example_creator.create_individual(person=person)
    individual.cpf = '437.433.508-07'

    assert Person.get_or_create_by_document(store, '437.433.508-07') is person
Example #2
0
def test_get_or_create_by_document_with_cnpj(store):
    assert store.find(Company, cnpj='71.255.183/0001-34').count() == 0

    person = Person.get_or_create_by_document(store, '71.255.183/0001-34')

    company = store.find(Company, cnpj='71.255.183/0001-34').one()
    assert company is not None
    assert person is not None
Example #3
0
def test_get_or_create_by_document_with_cpf(store):
    assert store.find(Individual, cpf='123.456.789-10').count() == 0

    person = Person.get_or_create_by_document(store, '123.456.789-10')

    individual = store.find(Individual, cpf='123.456.789-10').one()
    assert individual is not None
    assert person is not None
Example #4
0
    def find_or_create_supplier(self, nfe_supplier):
        # FIXME: Need to do the same thing to Individual suppliers
        person = Person.get_or_create_by_document(
            self.store,
            nfe_supplier.cnpj,
            name=nfe_supplier.name,
            phone_number=nfe_supplier.phone_number,
            notes=u"Automatically created by Stoq-Link")

        person.company.state_registry = nfe_supplier.state_registry
        person.company.fancy_name = nfe_supplier.fancy_name or nfe_supplier.name

        if person.supplier is None:
            supplier = Supplier(store=self.store, person=person)
            nfe_supplier.supplier = supplier

        return person.supplier