As @ramielian stated in his post you have to reload the page or if that doesn’t work logout and in again as the number will be held until you do that. In a multiuser environment this will never work reliably as someone could be creating a new invoice as you are trying to reload or logout and the gap will then be created and that missing number will not be allocated again.
am not sure who to disturb and tag to suggest a reload function to be triggered after deletion of any submitted doc…
Yes, right, but I did in this way and still the number of invoice is increasing. I created a draft of invoice which has number 000020, next I delete it and I add new one, which has number 000021, but not 000020 ? After deletion I reload page from user menu as you said. Different users have the same problem.
I’ve never used reload however I do know if you log out and log back in again it doesn’t create a gap as I have used that in testing. You are right this issue has arisen before as gaps are not permitted in the invoice numbers in the EU for VAT purposes. My suggestion was that invoice numbers should not be allocated until submitted. They can use a temporary number in the background however the actual invoice number should not be assigned until that submission has taken place. For the EU areas after submission cancellation would be the only permitted way of handling an order that is cancelled after being accepted/submitted. If you make a mistake and submit an order you shouldn’t have then just cancel it. Does it really matter if it is deleted or cancelled. The result is the same and not deleting permits far more control within the business If someone is persistently having to delete orders then it is a sign they need to pay more attention or need more training.
Maybe simpler solution would be new field which can be increase automatically, what do you think ?
I guess it would depend on how it’s implemented because there would be the system giving one invoice number and the paperwork another. If you search the number given on the paperwork would you even find the right invoice on the system?
The simpler solution is to simply not delete invoices.
As described above by myself gaps can be created without deleting any sales invoice. Click on Sales Invoice by mistake. Press the back button and press the invoice again and you get a new invoice number. For EU VAT purposes that is not acceptable.
Let’s just take this question from a completely different angle but much more important angle. When is an invoice an invoice? I’d argue it’s only an invoice once it is submitted and indeed this basic concept is well understood because we have a draft status. If it wasn’t then a draft would not be necessary. So my question would then would be why allocate an invoice number before it even exists? Model that you and are modelling the real business logic which is the real goal.
Draft and Submit are two states of Transaction document, meaning that in Draft you can change values, items and prices. so you can create invoice in draft state and wait for adding billing details or confirm rates.
After confirming details, you can submit invoice. After final submission one can not change any information in invoice but if needed one can make revision of invoice by canceling and amending it.
If you don’t want to cancel/delete invoice, you can create sales order and make sales invoice after final confirmation.
I’m sorry a draft is a pro forma invoice if you want to talk about documents. A pro forma invoice is not an invoice. A pro forma is never acceptable for VAT. Only an invoice is. You can argue until you are blue in the face but HMRC, UK Tax Authority, are clear about the difference and therefore we have to be clear about the difference.
You don’t address my initial point about how you can create a gap in invoice numbering simply by hitting the sales invoice option by mistake. Using sales orders doesn’t address that at all.
I’m delighted for those countries that don’t have to deal with VAT but I do.
You can create print format for Pro-Forma invoice on Sales Order.
For removing gap, one need to add rename option in Sales Invoice, So we can rename invoice to missing number, but its not good design.
Also if we keep another auto number for invoice, then there is also same change for missing numbers in auto-number.
Yeah. I can see all those problems which is why you can only ever resolve this issue by allocating the invoice numbers as part of the submission process. Whilst the sales invoice submission process is running then any new sales invoices should queue until that submission process has finished which allows you to roll back the number if submission fails. Only foolproof way I can think of doing this but then again I’m not a programmer.
Add custom field
Invoice Number in sales invoice.
Add script to calculate existing MAX(Invoice Number).
Add script to update Invoice Number on submission of Sales Invoice.
Note: In this case, if you cancel or delete any old invoice then this will not give you solution.
@kolate_sambhaji The correct order of things should be the one that matches the be the one that is based on sound business logic and if we are talking about sound logic then it’s simple. A sales invoice should never have gaps in the sales invoice numbers unless a sales invoice has been explicitly deleted. The fact that you can get this behaviour of gaps appearing without explicitly deleting is regrettable not least because it then fails to meet needs of all users across the European Union who have to deal with VAT whether they understand their obligations or not. It would also be a concern to any auditor across the world. Anyway I’ve made my point and my reasons so I don’t see much point in pursuing this point any further as I’m bored listening to myself now
This is not how numbers are usually generated, and if this is happening it must be a bug. Invoice numbers are generated when the invoice is saved as a draft. If numbers are being created before being saved as a draft, then a git hub issue should be created, because this is a bug. A draft invoice is not the same as a pro-forma invoice though. At least in my company, we use Sales Orders for Pro-Forma invoices.A draft invoice is simply a draft invoice, i.e. it’s not complete.
Draft invoices must be numbered, else it would ruin the organization. If you have an invoice that is still a draft, a mistake, and you don’t want any gaps, then you should submit then cancel the invoice. It won’t affect any accounts, and will still be a permanent record.
You should change permissions so that nobody can delete invoices.
It’s simple an invoice can never be amended. An invoice is a tablet of stone. What the customer has must be exactly the same as your records which is why it can never be amended. That is why if you should never delete and invoice and why you never amend one and why you instead create credit notes. I will accept that a sales order can serve the same purpose as a pro forma however that being the case there is never a need for a draft invoice because the draft invoice serves the same purpose as the sales order. When you have a draft status you have pro forma irrespective of whether that is duplicate of a sales order or not the very fact that it exists means it can only be one document and that is pro forma. Pro forma are not invoices therefore to generate an invoice number at this stage is not following the business process.
@cpurbaugh Thanks. I’ve checked out the Sales Invoice numbering and they do only get created on saving so that gets rid of my biggest concern. The issue about pro forma invoices and invoices is still a reality however it’s not something that would overly concern myself with as I agree that when saving the pro forma you can easily cancel which is perfectly acceptable. I was more concerned about gaps appearing before submission as that would have been a big issue for me and that isn’t the case now. I now have no idea whether this was ever a problem or if I misinterpreted what I’d seen. No way of telling now as that was about 8 months ago and I have done that much testing since it’s impossible to tell now. Oh well. At least that’s one more thing I can stroke of my list of issues
The same situation for Delivery Notes. Although that I deleted delivery note e.g. number 5 and if I add new one, the new number of DN is 6, but not 5. Is there any way to control or understand how the numbering works ? Because yours answers don’t give full solution.
Did anybody ever find a solution for this please? I deleted the last sales invoice (made a mistake) and try to remake it but it skips a number now so there is a gap in the numbering.
Is there any way to solve this in DB or code?
Thanks in advance
EDIT: First I tried to fix it with imports, which gave me the right numbers (manually set via xlsx file) but when adding a new sales invoice it gave me an error on duplicate naming so the numbering was not really “registered”. Then I found the solution (super easy, wish I found it earlier): Duplicate name Item Price RFD/03610
Setup → Settings → Naming Series and set the “last entry” number to the one you desire for the prefix you want.
There is tabSeries in the db which will have the last doc name created for Sales Invoice, change it there