Fix #1080 -- Deal with gaps in the invoice database (#1086)

This commit is contained in:
Raphael Michel
2018-11-20 10:36:13 +01:00
committed by GitHub
parent 1cba4b1d45
commit c93f804992
2 changed files with 18 additions and 5 deletions

View File

@@ -294,20 +294,27 @@ def test_invoice_numbers(env):
event.settings.set('invoice_numbers_consecutive', True)
inv5 = generate_invoice(order)
inv6 = generate_invoice(order)
inv7 = generate_invoice(order)
Invoice.objects.filter(pk=inv6.pk).delete() # This should never ever happen, but what if it happens anyway?
inv8 = generate_invoice(order)
inv23 = generate_invoice(order2)
# expected behaviour for switching between numbering formats
# expected behaviour for switching between numbering formats or dealing with gaps
assert inv1.invoice_no == '00001'
assert inv2.invoice_no == '00002'
assert inv3.invoice_no == '{}-3'.format(order.code)
assert inv4.invoice_no == '{}-4'.format(order.code)
assert inv5.invoice_no == '00003'
assert inv6.invoice_no == '00004'
assert inv7.invoice_no == '00005'
assert inv8.invoice_no == '00006'
# test that separate orders are counted separately in this mode
assert inv21.invoice_no == '{}-1'.format(order2.code)
assert inv22.invoice_no == '{}-2'.format(order2.code)
# but consecutively in this mode
assert inv23.invoice_no == '00004'
assert inv23.invoice_no == '00007'
# test Invoice.number, too
assert inv1.number == '{}-00001'.format(event.slug.upper())