Inversed98 Posted November 8, 2023 Share Posted November 8, 2023 Hey guys, due to recent changes in laws in my country now we are obligated to use 10 digits as invoice numbering for example first invoice starts with 0000000001 and I have no idea how to go about this. Also I need to delete all invoices and transactions and each new invoice should use the numbering system. Has anybody done this before ? I'm not a programmer so I have no idea how to go about this. I've contacted WHMCS and they suggested using InvoiceCreation hook point to execute custom code to add a new custom invoice number (with leading zeros) via the UpdateInvoice API command here: https://developers.whmcs.com/hooks-reference/invoices-and-quotes/#invoicecreation https://developers.whmcs.com/api-reference/updateinvoice/ However I can't do this by myself, is anybody able to help ? 0 Quote Link to comment Share on other sites More sharing options...
Nelson Neoh Posted November 10, 2023 Share Posted November 10, 2023 The suggestions isn't the full details that can lead you to success, as the invoiceid is only limited to integers, which means not support leading zeros. I guess the rules didn't mention you must start the invoice with leading zeros? Then I have a workaround suggestion. If so, just a simple method: Why not add the date as part of the leading numbers? Steps: Enter to System Settings Find the Invoice tab. Locate the option: Sequential Invoice Number Format place this and save: {YEAR}{MONTH}{DAY}{NUMBER} Hope it helps. 0 Quote Link to comment Share on other sites More sharing options...
Inversed98 Posted November 10, 2023 Author Share Posted November 10, 2023 1 hour ago, Nelson Neoh said: The suggestions isn't the full details that can lead you to success, as the invoiceid is only limited to integers, which means not support leading zeros. I guess the rules didn't mention you must start the invoice with leading zeros? Then I have a workaround suggestion. If so, just a simple method: Why not add the date as part of the leading numbers? Steps: Enter to System Settings Find the Invoice tab. Locate the option: Sequential Invoice Number Format place this and save: {YEAR}{MONTH}{DAY}{NUMBER} Hope it helps. Hello, thanks for taking your type to post here. Well the issue is this won't work due to the strict local laws. The invoices have to be numbered exactly as I explained otherwise they will not be valid. I was thinking about something else, can a hook be made to change the invoice number after every order ? It would work like this in my head: 1. Order 1 comes in with invoice number 1 2. Hook detects the order and changes the invoice number to 0000000001 in the database and then it increases for every following one. 0 Quote Link to comment Share on other sites More sharing options...
Nelson Neoh Posted November 14, 2023 Share Posted November 14, 2023 As the natual of what going to store in database, it won't able to store leading zeros. In other means, there will have no way to store the exact figure with leading zeros in DB. Hook can come to help only on the views. Since the exact figure with leading zeros is not able to store in DB, you will need to code for every view that will show the invoice number. Not an easy work. 0 Quote Link to comment Share on other sites More sharing options...
Inversed98 Posted November 14, 2023 Author Share Posted November 14, 2023 16 hours ago, Nelson Neoh said: As the natual of what going to store in database, it won't able to store leading zeros. In other means, there will have no way to store the exact figure with leading zeros in DB. Hook can come to help only on the views. Since the exact figure with leading zeros is not able to store in DB, you will need to code for every view that will show the invoice number. Not an easy work. I understand, it looks like I won't be able to achieve this easily. 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted November 17, 2023 Share Posted November 17, 2023 Is this what you are looking for; 0 Quote Link to comment Share on other sites More sharing options...
lulzkiller Posted November 19, 2023 Share Posted November 19, 2023 Instead of 0000000001 as a start, why not use 1000000000 instead , then it goes 100000001 1000000002 etc etc 0 Quote Link to comment Share on other sites More sharing options...
99modules Posted November 20, 2023 Share Posted November 20, 2023 Hello, You can change AUTO_INCREMENT value in table operations, first make sure you have table data backup then you can change it to any number you like, for example 100000 to start from that. 0 Quote Link to comment Share on other sites More sharing options...
Remitur Posted November 22, 2023 Share Posted November 22, 2023 DO NOT MODIFY EXISTING INVOICE NUMBERS!!!! If you do it you'll have years of bad times, realizing it has been a very bad idea. FIX: modify just the .tpl files, adding the leading zeroes to the invoice number if, after this modification, you really need to renumber existing invoices, don't modify the current invoice number, but create a new field in MySQL table ("myinvoicenumber") and modify the .tpl files in order to display this number instead of invoice number (you can still print also the original invoice number as "internal document number" or something like this) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.