Why do I have invoices with the same number?
These are documents of different types (invoice and invoice-receipt), with each type of document following a sequential and chronological order. That is:
Invoice seriesname/1, seriesname/2, seriesname/3, and so on.
Invoice-receipt seriesname/1, seriesname/2, seriesname/3, and so on.
Credit note seriesname/1, seriesname/2, seriesname/3, and so on.
This is the correct behavior and in accordance with the rules of the Portuguese tax authority.