Exemplo n.º 1
0
def invoice_bug400(def_tva, tva20):
    prod = MagicMock(name="product 2", compte_cg="P0002", tva=tva20)
    lines = []

    for cost, qtity in ((22112500, 1), ):
        lines.append(
            DummyLine(cost=cost,
                      quantity=qtity,
                      tva=tva20.value,
                      product=prod,
                      tva_object=tva20))

    group = DummyGroup(lines=lines)
    company = Dummy(name="company", code_compta='COMP_CG', contribution=None)
    customer = Dummy(name="customer",
                     compte_tiers="CUSTOMER",
                     compte_cg='CG_CUSTOMER')
    invoice = TaskCompute()
    invoice.default_tva = def_tva.value
    invoice.expenses_tva = def_tva.value
    invoice.date = datetime.date(2013, 02, 02)
    invoice.customer = customer
    invoice.company = company
    invoice.official_number = "INV_001"
    invoice.line_groups = [group]
    invoice.all_lines = group.lines
    invoice.expenses_ht = 0
    invoice.expenses = 0
    return invoice
Exemplo n.º 2
0
def test_edit_user_submit_success(
    user, config, get_csrf_request_with_db, dbsession
):
    from autonomie.models.user.user import User
    from autonomie.views.user.user import UserEditView

    config.add_route('/users', '/users')
    config.add_route('/users/{id}', '/users/{id}')

    appstruct = {
        "lastname": user.lastname,
        "firstname": u"new firstname",
        "email": u"*****@*****.**",
        "civilite": u"Monsieur",
    }
    req = get_csrf_request_with_db()
    req.context = user
    req.matched_route = Dummy(name="/users/{id}", id=user.id)
    req.matchdict = {'id': user.id}
    view = UserEditView(req)
    view.submit_success(appstruct)

    user = dbsession.query(User).filter_by(id=user.id).first()
    assert user.firstname == u"new firstname"
    assert user.lastname == user.lastname
    assert user.email == u"*****@*****.**"
Exemplo n.º 3
0
def test_add_invoice(config, get_csrf_request_with_db, project, phase, company,
                     user, customer, ):
    from autonomie.models.task.invoice import Invoice
    from autonomie.views.invoices.invoice import InvoiceAddView
    config.add_route('/invoices/{id}', "/")
    value = {
        "name": u"Facture",
        'course': True,
        'project_id': project.id,
        'phase_id': phase.id,
        'customer_id': customer.id,
    }

    request = get_csrf_request_with_db()
    request.context = project
    request.current_company = company.id
    request.matched_route = Dummy(name="project_invoices")
    request.user = user
    view = InvoiceAddView(request)
    view.submit_success(value)

    # view.submit_success(value)
    invoice = Invoice.query().first()

    assert invoice.name == u"Facture"
    assert invoice.phase_id == phase.id
    assert invoice.customer_id == customer.id
    assert invoice.project_id == project.id
    assert invoice.course is True
Exemplo n.º 4
0
def cancelinvoice(dummy_company):
    return Dummy(
        status='draft',
        company=dummy_company,
        exported=False,
        type_='cancelinvoice',
    )
Exemplo n.º 5
0
def cancelinvoice():
    return Dummy(
        status='draft',
        company_id=1,
        exported=False,
        type_='cancelinvoice',
    )
Exemplo n.º 6
0
 def build_factory(self, config_request):
     return CustomBookEntryFactory(
         None, config_request,
         Dummy(compte_cg_debit='CG_SCOP',
               compte_cg_credit='CG_DEB',
               percentage=5,
               label_template=u"{client.name} {entreprise.name}"))
Exemplo n.º 7
0
def test_new_task_schema(project, customer, phase, company, phase2, project2,
                         default_business_type):
    import colander
    from pyramid.testing import DummyRequest
    from autonomie.tests.tools import Dummy
    from autonomie.forms.tasks.base import get_new_task_schema
    from autonomie.views.project.routes import PROJECT_ITEM_ESTIMATION_ROUTE
    schema = get_new_task_schema()
    req = DummyRequest(
        context=project,
        matched_route=Dummy(name=PROJECT_ITEM_ESTIMATION_ROUTE),
        current_company=company,
    )
    schema = schema.bind(request=req)

    result = schema.deserialize({
        'name':
        u'Facture',
        'customer_id':
        str(customer.id),
        'project_id':
        str(project.id),
        'phase_id':
        str(phase.id),
        'business_type_id':
        str(default_business_type.id),
    })

    assert result == {
        'name': u'Facture',
        'customer_id': customer.id,
        'project_id': project.id,
        'phase_id': phase.id,
        "business_type_id": default_business_type.id
    }
    with pytest.raises(colander.Invalid):
        schema.deserialize({
            'name': u'Facture',
            'customer_id': str(customer.id),
            'project_id': str(project.id),
            'phase_id': str(phase2.id),
            "business_type_id": str(default_business_type.id)
        })

    with pytest.raises(colander.Invalid):
        schema.deserialize({
            'name': u'Facture',
            'customer_id': str(customer.id),
            'project_id': str(project2.id),
            'phase_id': str(phase2.id),
            "business_type_id": str(default_business_type.id)
        })

    with pytest.raises(colander.Invalid):
        schema.deserialize({
            'name': u'Facture',
            'customer_id': str(customer.id),
            'project_id': str(project2.id),
            'phase_id': str(phase2.id),
        })
Exemplo n.º 8
0
def test_add_invoice(
    config, get_csrf_request_with_db, project, phase, company,
    user, customer, default_business_type,
):
    from autonomie.models.task.invoice import Invoice
    from autonomie.views.project.routes import PROJECT_ITEM_INVOICE_ROUTE
    from autonomie.views.invoices.invoice import InvoiceAddView
    config.add_route('/invoices/{id}', "/")
    value = {
        "name": u"Facture",
        'business_type_id': default_business_type.id,
        'project_id': project.id,
        'phase_id': phase.id,
        'customer_id': customer.id,
    }

    request = get_csrf_request_with_db()
    request.context = project
    request.current_company = company.id
    request.matched_route = Dummy(name=PROJECT_ITEM_INVOICE_ROUTE)
    request.user = user
    view = InvoiceAddView(request)
    view.submit_success(value)

    # view.submit_success(value)
    invoice = Invoice.query().first()

    assert invoice.name == u"Facture"
    assert invoice.phase_id == phase.id
    assert invoice.customer_id == customer.id
    assert invoice.project_id == project.id
    assert invoice.business_type_id == default_business_type.id
Exemplo n.º 9
0
def invoice(def_tva, tva):

    p1 = MagicMock(name="product 1", compte_cg="P0001", tva=def_tva)
    p2 = MagicMock(name="product 2", compte_cg="P0002", tva=tva)
    line1 = DummyLine(cost=10000000,
                      quantity=1,
                      tva=def_tva.value,
                      product=p1,
                      tva_object=def_tva)
    line2 = DummyLine(
        cost=10000000,
        quantity=1,
        tva=def_tva.value,
        product=p1,
        tva_object=def_tva,
    )
    line3 = DummyLine(
        cost=10000000,
        quantity=1,
        tva=tva.value,
        product=p2,
        tva_object=tva,
    )

    group = DummyGroup(lines=(
        line1,
        line2,
        line3,
    ))

    company = Dummy(name="company", code_compta='COMP_CG', contribution=None)
    customer = Dummy(name="customer",
                     compte_tiers="CUSTOMER",
                     compte_cg='CG_CUSTOMER')
    invoice = TaskCompute()
    invoice.default_tva = def_tva.value
    invoice.expenses_tva = def_tva.value
    invoice.date = datetime.date(2013, 02, 02)
    invoice.customer = customer
    invoice.company = company
    invoice.official_number = "INV_001"
    invoice.line_groups = [group]
    invoice.all_lines = group.lines
    invoice.expenses_ht = 10000000
    invoice.expenses = 10000000
    return invoice
Exemplo n.º 10
0
def invoice(dummy_company):
    return Dummy(
        status='draft',
        company=dummy_company,
        paid_status='waiting',
        exported=False,
        type_='invoice',
    )
Exemplo n.º 11
0
def invoice():
    return Dummy(
        status='draft',
        company_id=1,
        paid_status='waiting',
        exported=False,
        type_='invoice',
    )
Exemplo n.º 12
0
    def build_factory(self, config_request):
        return CustomBookEntryFactory(
            None, config_request,
            Dummy(compte_cg_debit='CG_ORGA',
                  compte_cg_credit='CG_DEB_ORGA',
                  percentage=5,
                  label_template=u"Contribution Organic {client.name} \
{entreprise.name}"))
Exemplo n.º 13
0
def estimation(dummy_company):
    return Dummy(
        status='draft',
        company=dummy_company,
        signed_status='waiting',
        geninv=False,
        type_='estimation',
    )
Exemplo n.º 14
0
def expense_payment(expense, bank):
    p = Dummy(
        amount=10000000,
        mode=u"chèque",
        date=datetime.date.today(),
        expense=expense,
        bank=bank,
    )
    return p
Exemplo n.º 15
0
def estimation(dummy_project):
    return Dummy(
        status='draft',
        company_id=1,
        signed_status='waiting',
        geninv=False,
        type_='estimation',
        project=dummy_project,
    )
Exemplo n.º 16
0
def expense_sheet():
    return Dummy(
        status='draft',
        company_id=1,
        paid_status='waiting',
        expense_exported=False,
        purchase_exported=False,
        type_='expensesheet',
    )
Exemplo n.º 17
0
def payment(invoice, def_tva, bank):
    p = Dummy(
        remittance_amount=10000,
        amount=10000000,
        mode=u"chèque",
        date=datetime.date.today(),
        tva=def_tva,
        bank=bank,
        invoice=invoice,
    )
    return p
Exemplo n.º 18
0
def test_populate_void(mk_business_type_file_types, ftypes, btypes):
    mk_business_type_file_types(
        ftypes['ftype1'], btypes['default'], 'invoice', 'recommended'
    )
    node = Dummy(
        file_requirements=[],
        type_='estimation',
        business_type_id=btypes['default'].id,
    )
    SaleFileRequirementService.populate(node)
    assert len(node.file_requirements) == 0
Exemplo n.º 19
0
def test_password_change_schema(login, pyramid_request):
    import colander
    from autonomie.forms.user.login import get_password_schema

    schema = get_password_schema()
    pyramid_request.context = login
    pyramid_request.user = Dummy(login=None)

    schema = schema.bind(request=pyramid_request)

    result = schema.deserialize({'pwd_hash': u"New pass"})

    assert result['pwd_hash'] == u'New pass'
Exemplo n.º 20
0
def test_default_disable():
    from autonomie.forms.user.user import deferred_company_disable_default
    companies = [Dummy(employees=range(2))]
    user = Dummy(companies=companies)
    req = Dummy(context=user)
    assert not deferred_company_disable_default("", {'request': req})
    companies = [Dummy(employees=[1])]
    user = Dummy(companies=companies)
    req = Dummy(context=user)
    assert (deferred_company_disable_default("", {'request': req}))
Exemplo n.º 21
0
def test_mypassword_change_schema(login, pyramid_request):
    import colander
    from autonomie.forms.user.login import get_password_schema

    schema = get_password_schema()
    pyramid_request.context = login
    pyramid_request.user = Dummy(login=login)

    schema = schema.bind(request=pyramid_request)

    result = schema.deserialize({'password': '******', 'pwd_hash': u"New pass"})

    assert result['pwd_hash'] == u'New pass'

    with pytest.raises(colander.Invalid):
        schema.deserialize({'password': '******', 'pwd_hash': u"New pass"})
Exemplo n.º 22
0
def test_new_task_schema(project, customer, phase, company, phase2, project2):
    import colander
    from pyramid.testing import DummyRequest
    from autonomie.tests.tools import Dummy
    from autonomie.forms.tasks.base import get_new_task_schema
    schema = get_new_task_schema()
    req = DummyRequest(
        context=project,
        matched_route=Dummy(name='project_estimations'),
        current_company=company,
    )
    schema = schema.bind(request=req)

    result = schema.deserialize({
        'name': u'Facture',
        'customer_id': str(customer.id),
        'project_id': str(project.id),
        'phase_id': str(phase.id),
        'course': str(1)
    })

    assert result == {
        'name': u'Facture',
        'customer_id': customer.id,
        'project_id': project.id,
        'phase_id': phase.id,
        'course': 1,
    }
    with pytest.raises(colander.Invalid):
        schema.deserialize({
            'name': u'Facture',
            'customer_id': str(customer.id),
            'project_id': str(project.id),
            'phase_id': str(phase2.id),
            'course': str(1)
        })

    with pytest.raises(colander.Invalid):
        schema.deserialize({
            'name': u'Facture',
            'customer_id': str(customer.id),
            'project_id': str(project2.id),
            'phase_id': str(phase2.id),
            'course': str(1)
        })
Exemplo n.º 23
0
def test_add_user_submit_success_confirm(user, config,
                                         get_csrf_request_with_db):
    from autonomie.views.user.user import UserAddView

    config.add_route('/users', '/users')
    config.add_route('/users/{id}', '/users/{id}')

    appstruct = {
        "lastname": user.lastname,
        "firstname": u"Firstname 1",
        "email": u"*****@*****.**",
        "civilite": u"Monsieur",
    }
    req = get_csrf_request_with_db()
    req.matched_route = Dummy(name="/users")
    view = UserAddView(req)
    result = view.submit_success(appstruct)
    assert 'confirmation_message' in result
    assert 'form' in result
Exemplo n.º 24
0
def dummy_company():
    user1 = Dummy(login='******')
    company = Dummy(employees=[user1])
    return company
Exemplo n.º 25
0
def request(settings):
    registry = Dummy(settings=settings)
    req = Dummy(registry=registry, headers={})
    return req
Exemplo n.º 26
0
def dummy_company():
    login = Dummy(login="******")
    user1 = Dummy(login=login)
    company = Dummy(employees=[user1])
    return company
Exemplo n.º 27
0
def dummy_project():
    project_type = Dummy(default=True)
    project = Dummy(project_type=project_type)
    return project
Exemplo n.º 28
0
def bank():
    return Dummy(compte_cg=u"COMPTE_CG_BANK", code_journal="CODE_JOURNAL_BANK")
Exemplo n.º 29
0
def dummy_project():
    project_type = Dummy(default=True)
    project = Dummy(project_type=project_type, company_id=1)
    return project