Hi, there! bubblers I’m Mohamed i need assistant recently i created a project about an inventory management tool , so my issue is how to add an invoice number my Receipt Order which contains fields [ date purchased , Invoice Number, customer name, phone and list of items ordered] so read in detail this article what i need to assist me.
Invoice number based on date input´s year date
I want to get the invoice number automatically generated based on this:
• The invoice number has to start always by number 1 and correlative based on the invoice´s year date.
• If you eliminate the latest invoice of that year then that number it will be available for the next invoice.
Here is an example: when creating the invoice, I select on the invoice date field this “01/01/2024” (dd/mm/yyyy format) and this is the first invoice of 2024 so the invoice number generated will be “1/2024”, after when I clicked my button save data the next invoice number if I select again a date in 2024 year will be “2/2024”, “3/2024”, “4/2024”, …
Now if I delete (or set the state of deleted) the latest invoice (the latest invoice will be the only one that can be deleted always) and this one was “4/2024”, then this number will be available. So after deleting the invoice “4/2024” the next invoice will be again the “4/2024”.
Now if I create a new invoice with the date´s year as 2025 and there is no invoice on 2025, the first one will start by “1/2025”, “2/2025”, …