l10n-dominicana
l10n-dominicana copied to clipboard
[13.0][IMP] l10n_do_accounting: avoid contraint validation of unique sequence if invoice is not from same year
When a company generates a large number of fiscal sequences, the current constraint on method _check_unique_sequence_number
located at l10n_do_accounting\models\account_move.py:203
might become a bug by not letting the user generate a new sequence.
Steps to Reproduce Steps to reproduce the behavior:
- User generates several invoices over the years to the a recurrent partner
- Since the sequences can be restarted to 01 again
- When it does, there is a possibility of the user generating an invoice for a partner when the next number is one already used for the same partner in prior years
Expected behavior
Improve the method _check_unique_sequence_number
to consider the invoice year when validating if and invoice with that sequence number already exists. By doing this, a user could generate a invoice for the same partner, with the same sequence number as long as the sequence is from another year.
Thanks @evaldez89
I took the time to do some research about this use case and it turns out that DGII do not allows a taxpayer to re-use a sequence based on the period (year) per se, but the sequence running out of digits. Being more specific, eight and ten for B and E series respectively.
In other words, issuing one invoice per second, it would take 3 years to deplete all serie B and 317 years for serie E. I think we can use this as a reference.
Can we improve the query so it considers each amount of years for both B and E series?
Cc: @andrp92
ping!