# Prevent using same sequence on earlier customer invoice: which date to use?

**URL:** https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840
**Category:** Developer
**Tags:** accounting
**Created:** [December 9, 2021, 4:44pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840 "2021-12-09T16:44:20Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![david\_auto](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@david\_auto](https://discuss.tryton.org/u/david_auto)
#### Post date: [January 4, 2022, 11:11am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/21 "2022-01-04T11:11:53Z")

</div>

hola:

disculpa una pregunta.

¿te refieres a la **fecha de devengo** para el iva? La cual se produce cuando se realiza la operación o bien la adquisición de la mercancía que no tiene porque coincidir cuando se factura.

hello:  
excuse a question.  
Do you mean the accrual date for the VAT? Which occurs when the operation is carried out or the acquisition of the merchandise that does not have to coincide when it is invoiced.

---

<div class="post-metadata">

### Author: ![roliver](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@roliver](https://discuss.tryton.org/u/roliver)
#### Post date: [January 4, 2022, 12:17pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/22 "2022-01-04T12:17:47Z")

</div>

Si, la fecha de registro contable debe ser la fecha del devengo del impuesto y esta no tiene porque coincidir con la fecha de emisión de factura que puede ser igual o posterior

---

<div class="post-metadata">

### Author: ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)
#### Post date: [January 11, 2022, 6:07pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/23 "2022-01-11T18:07:19Z")

</div>

> [@sergyo](#):
>
> Anyway we have just queried to “agencia tributaria” about it.

FYI my mistake I thought @roliver sent an email to “agencia tributaria” but seems there isn’t this contact mechanism. So we have to phone.

At the moment we are using a custom module that replace get\_next\_number () and set\_number () methods as cannot be adapt for this purpose.

---

<div class="post-metadata">

### Author: ![yangoon](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/y/67e7ee/32.png) [@yangoon](https://discuss.tryton.org/u/yangoon)
#### Post date: [January 12, 2022, 8:30am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/24 "2022-01-12T08:30:05Z")

</div>

I did some research on the constraints for invoice sequences for _Germany_, here are my results. I found basically two legal texts applying to the topic:

1. [Umsatzsteuergesetz (UStG) § 14 Ausstellung von Rechnungen](https://www.gesetze-im-internet.de/ustg_1980/__14.html)

The interesting part should be

> (4) Eine Rechnung muss folgende Angaben enthalten:
> 
> \<…\>
> 
> 1. eine fortlaufende Nummer mit einer oder mehreren Zahlenreihen, die zur Identifizierung der Rechnung vom Rechnungsaussteller einmalig vergeben wird (Rechnungsnummer),

1. [Umsatzsteueranwendungserlass (UStAE 2010 14.5. (Zu § 14 UStG (§§ 31 bis 34 UStDV))](https://datenbank.nwb.de/Dokument/378652_14___5/)

This decree is in principle the implementing regulation for the law in 1).

especially interesting in original language (I can provide translations by Google if it is not possible to use the discuss feature for parts of messages):

> (10) 1Durch die fortlaufende Nummer (Rechnungsnummer) soll sichergestellt werden, dass die vom Unternehmer erstellte Rechnung einmalig ist. 2Bei der Erstellung der Rechnungsnummer ist es zulässig, eine oder mehrere Zahlen- oder Buchstabenreihen zu verwenden. 3Auch eine Kombination von Ziffern mit Buchstaben ist möglich. 4Eine lückenlose Abfolge der ausgestellten Rechnungsnummern ist nicht zwingend. 5Es ist auch zulässig, im Rahmen eines weltweiten Abrechnungssystems verschiedener, in unterschiedlichen Ländern angesiedelter Konzerngesellschaften nur einen fortlaufenden Nummernkreis zu verwenden.
> 
> (11) 1Bei der Erstellung der Rechnungsnummer bleibt es dem Rechnungsaussteller überlassen, wie viele und welche separaten Nummernkreise geschaffen werden, in denen eine Rechnungsnummer jeweils einmalig vergeben wird. 2Dabei sind Nummernkreise für zeitlich, geographisch oder organisatorisch abgegrenzte Bereiche zulässig, z. B. für Zeiträume (Monate, Wochen, Tage), verschiedene Filialen, Betriebsstätten einschließlich Organgesellschaften oder Bestandsobjekte. 3Die einzelnen Nummernkreise müssen dabei nicht zwingend lückenlos sein. 4Es muss jedoch gewährleistet sein (z. B. durch Vergabe einer bestimmten Klassifizierung für einen Nummernkreis), dass die jeweilige Rechnung leicht und eindeutig dem jeweiligen Nummernkreis zugeordnet werden kann und die Rechnungsnummer einmalig ist.

In summary this says that the purpose of the invoice sequence is to provide **uniqueness**. It even says that the sequence has not obligatory to be consecutively numbered. And most notably there is **no constraint to follow invoice or accounting dates**.

We (MBSolutions) try nevertheless to have consecutively numbered invoices. If an invoice sequence was not used (e.g. given back by a rollback) we document that gap to provide complete track to be on the safe side.

The actual constraint to forbid the usage of the same invoice sequence for earlier invoice dates thus doesn’t meet IMO the requirements for Germany. Of course I would like to hear from other german colleagues their view on the topic and how they handle it.

As Tryton aims to be a generic solution I propose to remove the constraint in the base module (account\_invoice) and put it in localization modules where it applies. AFAIS this would at least serve the Spanish and German case.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 12, 2022, 8:52am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/25 "2022-01-12T08:52:40Z")

</div>

> [@yangoon](#):
>
> As Tryton aims to be a generic solution I propose to remove the constraint in the base module (account\_invoice) and put it in localization modules where it applies. AFAIS this would at least serve the Spanish and German case.

I do not agree. This constraint applies to almost all countries and even for rare countries with relaxed constraints (which I really do not think Germany fall in) this is not a problem but a good practice to follow.

---

<div class="post-metadata">

### Author: ![yangoon](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/y/67e7ee/32.png) [@yangoon](https://discuss.tryton.org/u/yangoon)
#### Post date: [January 12, 2022, 11:12am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/26 "2022-01-12T11:12:11Z")

</div>

Apart from the problem at hand, what is considered best practice in Tryton to solve the following use case (happened really last year):

A company sent out invoices in December 2021 that after an audit of the tax adviser are considered illegal. The company says we will send out corrected invoices, but we will no more manage that during this year.  
Note: The invoices have to be replaced with the same invoice date as the original invoices to be valid for the customers.

What is considered best practice in Tryton to solve the problem? Creating a separate period and sequence for each of those cases?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 12, 2022, 11:17am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/27 "2022-01-12T11:17:03Z")

</div>

> [@yangoon](#):
>
> The invoices have to be replaced with the same invoice date as the original invoices to be valid for the customers.

This can not be a requirement as the tax period can be closed etc.  
The only valid requirement for the customer is that the due date is at least the same or later.

---

<div class="post-metadata">

### Author: ![coogor](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/coogor/32/47_2.png) [@coogor](https://discuss.tryton.org/u/coogor)
#### Post date: [January 12, 2022, 3:20pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/28 "2022-01-12T15:20:56Z")

</div>

> [@yangoon](#):
>
> What is considered best practice in Tryton to solve the problem? Creating a separate period and sequence for each of those cases?

Do I understand you right that the current bookkeeping legislation in Germany can not be fulfilled with Tryton?

> [@ced](#):
>
> This can not be a requirement as the tax period can be closed etc.  
> The only valid requirement for the customer is that the due date is at least the same or later.

As a reference, in SAP you can book into the previous period (customizing setting)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 12, 2022, 3:23pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/29 "2022-01-12T15:23:12Z")

</div>

> [@coogor](#):
>
> As a reference, in SAP you can book into the previous period (customizing setting)

I doubt that in SAP you can book in a previous closed period.

---

<div class="post-metadata">

### Author: ![coogor](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/coogor/32/47_2.png) [@coogor](https://discuss.tryton.org/u/coogor)
#### Post date: [January 12, 2022, 3:36pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/30 "2022-01-12T15:36:52Z")

</div>

Knowing is better than believing (ddg helps in that case).  
Even if it is in the same month, an invoice with an earlier date than current (or last posted invoice) is not possible in Tryton (this is what the thread is about).  
So you cant fulfil german (and spanish) accounting requirements as it is now.

---

<div class="post-metadata">

### Author: ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)
#### Post date: [January 12, 2022, 3:40pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/31 "2022-01-12T15:40:55Z")

</div>

> [@yangoon](#):
>
> I did some research on the constraints for invoice sequences for _Germany_ …

Thanks @yangoon for your time.

> [@yangoon](#):
>
> As Tryton aims to be a generic solution I propose to remove the constraint in the base module (account\_invoice) and put it in localization modules where it applies. AFAIS this would at least serve the Spanish and German case.

Indeed the constraint is not the problem but the consistency criteria (which date to use).  
As there is no agreement probably by enabling a way to customize it would be enough …

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 12, 2022, 3:47pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/32 "2022-01-12T15:47:31Z")

</div>

> [@coogor](#):
>
> Knowing is better than believing (ddg helps in that case).

I still do not believe it.

> [@coogor](#):
>
> Even if it is in the same month, an invoice with an earlier date than current (or last posted invoice) is not possible in Tryton (this is what the thread is about).  
> So you cant fulfil german (and spanish) accounting requirements as it is now.

This is perfectly supported by Tryton. As anyone actually using Tryton knows about.

> [@sergyo](#):
>
> Indeed the constraint is not the problem but the consistency criteria (which date to use).

But we still do not have clear statement for Spanish accounting about your claimed requirement, nor counter argument about the consistency issue with your proposed workflow.

---

<div class="post-metadata">

### Author: ![coogor](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/coogor/32/47_2.png) [@coogor](https://discuss.tryton.org/u/coogor)
#### Post date: [January 12, 2022, 8:58pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/33 "2022-01-12T20:58:19Z")

</div>

> [@ced](#):
>
> > [@coogor](#):
> >
> > Even if it is in the same month, an invoice with an earlier date than current (or last posted invoice) is not possible in Tryton (this is what the thread is about).  
> > So you cant fulfil german (and spanish) accounting requirements as it is now.
> 
> This is perfectly supported by Tryton. As anyone actually using Tryton knows about.

OK, quick test in the demo DB, post an invoice with invoice and accounting date for today, then try to post an invoice for the first of Jan:

 ![grafik](https://discuss-cdn.tryton.org/uploads/default/original/2X/a/a22639a22d4d5b299663bf6680b0dbfe1fd3174b.png)  
That fails is a not really helpful error message.  
If you post a predated invoice with invoice date and accounting date for 31 january you won’t be able to post any other invoice before this date. As well if you post an invoice for today with those dates, you won’t be able to post any earlier invoice with this sequence.

Consequence: Your statement is plain wrong. With this setup, Tryton cant cope with real world requirements, as ‘anyone actually using Tryton knows about’

---

<div class="post-metadata">

### Author: ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)
#### Post date: [January 12, 2022, 10:18pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/34 "2022-01-12T22:18:22Z")

</div>

> [@coogor](#):
>
> If you post a predated invoice with invoice date and accounting date for 31 january you won’t be able to post any other invoice before this date. As well if you post an invoice for today with those dates, you won’t be able to post any earlier invoice with this sequence.

In Spanish case the accounting date would be 1 January and invoice date 31 January (or later until 16 February).

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 13, 2022, 8:58am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/35 "2022-01-13T08:58:35Z")

</div>

> [@coogor](#):
>
> That fails is a not really helpful error message.

I’m wondering what would be an helpful error message for you?

> [@coogor](#):
>
> Consequence: Your statement is plain wrong. With this setup, Tryton cant cope with real world requirements, as ‘anyone actually using Tryton knows about’

Wrong Tryton works correctly.  
Nobody has shown any proof that people can number invoices without following a sequence.

> [@sergyo](#):
>
> In Spanish case the accounting date would be 1 January and invoice date 31 January (or later until 16 February).

And this works correctly with Tryton.

You can also post an invoice with the invoice date on 31 December as it will be a different sequence.

---

<div class="post-metadata">

### Author: ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)
#### Post date: [January 13, 2022, 10:12am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/36 "2022-01-13T10:12:51Z")

</div>

> [@ced](#):
>
> > [@sergyo](#):
> >
> > In Spanish case the accounting date would be 1 January and invoice date 31 January (or later until 16 February).
> 
> And this works correctly with Tryton.

No it doesn’t as we have posted invoices with accounting date greater than 1 January.

Retrieving the origin of this thread … the accounting date of invoice taxes must be the moment the goods are delivered (this is called “momento del devengo” o “devengo del impuesto”). But invoice can be issued until 15th of next month.  
This is described in section " Cómo se devenga el IVA según el artículo 75 de LIVA" of [this article](https://www.carrilloasesores.com/post/liquidaciones-iva-aeat).

So if we limit the invoice sequence by accounting date, users cannot post an invoice with invoice\_date 10Feb (assume this is today) and accounting\_date 20Jan because they have post another invoices with accounting date greater than 20Jan.

I understand the usual thing in B2C is invoice\_date=accounting\_date but in certain B2B sectors this is not the case.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 13, 2022, 10:27am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/37 "2022-01-13T10:27:08Z")

</div>

OK so I think we could relax the constraint by searching for prior invoice sequence usage based only on the invoice date and using the invoice date of the numbered invoice. But we must still use the accounting date to get and generate the number.

Such change could not be back-ported but for me business having such constraint should use a sequence per period and use the last day of the period as accounting date. The exact date is not really important for tax report as long as it is on the right period.

---

<div class="post-metadata">

### Author: ![coogor](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/coogor/32/47_2.png) [@coogor](https://discuss.tryton.org/u/coogor)
#### Post date: [January 13, 2022, 12:23pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/38 "2022-01-13T12:23:03Z")

</div>

> [@ced](#):
>
> … But we must still use the accounting date to get and generate the number.

Why? Sales invoice is first of all related to the sales process. Then this is posted into accounting is a different story

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 15, 2022, 10:02pm UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/39 "2022-01-15T22:02:39Z")

</div>

I filled [Check invoice sequence against invoice date (#11139) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue11139)

---

<div class="post-metadata">

### Author: ![yangoon](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/y/67e7ee/32.png) [@yangoon](https://discuss.tryton.org/u/yangoon)
#### Post date: [January 18, 2022, 7:50am UTC](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840/40 "2022-01-18T07:50:49Z")

</div>

As already explained earlier in this thread the proposed solution is not enough for Germany. While there are very detailed requirements for the dates on invoices (invoice date, date of supply and service) there is **no combined constraint on date and numbers for the invoice number**.

Just some more additional links

> **[auxmoney Ratgeber](https://www.auxmoney.com/ratgeber/)**
>
> Im auxmoney Ratgeber finden Selbstständige und Existenzgründer Tipps rund zu den Themen Unternehmensgründung, Recht und Finanzierung.

> **[Kann ich Rechnungen rückwirkend ausstellen?](https://www.gruenderlexikon.de/checkliste/fuehren/rechnungen-schreiben/rechnungen-rueckwirkend/)**
>
> Eine Rechnung kann ohne Weiteres rückwirkend erstellt werden. Einen Zeitraum gibt es grundsätzlich nicht. Allerdings sollte darauf geachtet werden, dass...

> **[Was sind die Anforderungen an Rechnungsnummern?](https://www.billomat.com/magazin/anforderungen-an-rechnungsnummern/)**
>
> Eine fortlaufende Rechnungsnummer ist Pflicht für deine korrekt ausgestellten Rechnungen. Welche Anforderungen an Rechnungsnummern gibt es? ➤

> **[Rechnungsnummern - was Sie unbedingt wissen müssen](https://rechnungen-muster.de/rechnungsnummern)**

Instead of guessing and believing I would prefer a solution in Tryton based on evidence.

[Previous page](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840.md?page=1)

[Next page](https://discuss.tryton.org/t/prevent-using-same-sequence-on-earlier-customer-invoice-which-date-to-use/4840.md?page=3)
