示例#1
0
def _set_invoice_number(request, task, **kw):
    """
    Set a official number on invoices (or cancelinvoices)

    :param obj request: The current pyramid request
    :param obj task: The current context
    """
    template = Config.get_value('invoice_number_template', None)
    assert template is not None, \
        'invoice_number_template setting should be set'

    if task.official_number is None:
        InvoiceNumberService.assign_number(
            task,
            template,
        )
    return task
示例#2
0
def _set_invoice_number(request, task, **kw):
    """
    Set a official number on invoices (or cancelinvoices)

    :param obj request: The current pyramid request
    :param obj task: The current context
    """
    template = Config.get_value('invoice_number_template', None)
    assert template is not None, \
        'invoice_number_template setting should be set'

    if task.official_number is None:
        InvoiceNumberService.assign_number(
            task,
            template,
        )
    return task
def test_invoice_number_service_generation(invoice_20170707, invoice_20170808):
    tpl = 'FC-{YYYY}{MM}-{SEQGLOBAL}'

    InvoiceNumberService.assign_number(invoice_20170707, tpl)
    InvoiceNumberService.assign_number(invoice_20170808, tpl)
    assert invoice_20170707.official_number == 'FC-201707-1'
    assert invoice_20170808.official_number == 'FC-201707-2'

    # Will not re-assign
    with pytest.raises(ValueError):
        InvoiceNumberService.assign_number(invoice_20170707, tpl)
示例#4
0
def test_invoice_number_service_generation(invoice_20170707, invoice_20170808):
    tpl = 'FC-{YYYY}{MM}-{SEQGLOBAL}'

    InvoiceNumberService.assign_number(invoice_20170707, tpl)
    InvoiceNumberService.assign_number(invoice_20170808, tpl)
    assert invoice_20170707.official_number == 'FC-201707-1'
    assert invoice_20170808.official_number == 'FC-201707-2'

    # Will not re-assign
    with pytest.raises(ValueError):
        InvoiceNumberService.assign_number(invoice_20170707, tpl)
def test_invoice_number_collision_avoidance(
        invoice_20170707,
        invoice_2018,
        dbsession,
):
    # goes back to zero and conflicts with other years invoices
    # but that was how autonomie was configured by default before 4.2
    tpl = '{SEQYEAR}'

    # They will get the same official_number
    InvoiceNumberService.assign_number(invoice_20170707, tpl)

    with pytest.raises(ValueError):
        InvoiceNumberService.assign_number(invoice_2018, tpl)

    # With legacy tag, we want to allow that historic conflicts.
    invoice_20170707.legacy_number = True
    dbsession.merge(invoice_20170707)

    # Just check it raises nothing
    InvoiceNumberService.assign_number(invoice_2018, tpl)
示例#6
0
def test_invoice_number_collision_avoidance(
    invoice_20170707,
    invoice_2018,
    dbsession,
):
    # goes back to zero and conflicts with other years invoices
    # but that was how autonomie was configured by default before 4.2
    tpl = '{SEQYEAR}'

    # They will get the same official_number
    InvoiceNumberService.assign_number(invoice_20170707, tpl)

    with pytest.raises(ValueError):
        InvoiceNumberService.assign_number(invoice_2018, tpl)

    # With legacy tag, we want to allow that historic conflicts.
    invoice_20170707.legacy_number = True
    dbsession.merge(invoice_20170707)

    # Just check it raises nothing
    InvoiceNumberService.assign_number(invoice_2018, tpl)