Shaun Posted September 4, 2008 Share Posted September 4, 2008 I was looking for a way to emulate the way sequential invoices allows a customer invoice numbering scheme eg XXX-{Number}. Reason being i run this and myob and i wanted to know where to go when a customer inquired about invoice XYZ I first looked for a action hook for new invoices and it wasn't there. So the way to do it is to hook the db insert using a trigger. Installation: Connect to you phpMyAdmin. Open you WMHCS DB and goto the SQL tab Copy paste and inster the below row Rember to chane ##PREFIX## to your desired prefix delimiter ;; create trigger kdo_SetInvoiceNumber BEFORE INSERT on tblinvoices FOR EACH ROW BEGIN set new.invoicenum = concat('##PREFIX##',(SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tblinvoices')); END ;; Removal: Connect to you phpMyAdmin. Open you WMHCS DB and goto the SQL tab Copy paste and inster the below row Drop trigger kdo_SetInvoiceNumber ; This is the first hack i'm doing. I am going to take the time to build this into a full admin mod that allows you to add and remove the trigger and update it from inside the WHMC's panel. Matt: You could make it easier by adding a hook for invoice_Create Small Print: All care, no responsibility. 0 Quote Link to comment Share on other sites More sharing options...
nivlek78 Posted December 5, 2008 Share Posted December 5, 2008 This does not work. It says syntax error.... 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted December 5, 2008 Author Share Posted December 5, 2008 This does not work. It says syntax error.... i may have typed the code wrong. Ill look into it some more for you soon 0 Quote Link to comment Share on other sites More sharing options...
Blitz Posted May 8, 2009 Share Posted May 8, 2009 Anytime soon? 0 Quote Link to comment Share on other sites More sharing options...
jozeph Posted May 9, 2009 Share Posted May 9, 2009 V4 have a invoice_Create actionhook. 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted May 9, 2009 Author Share Posted May 9, 2009 V4 have a invoice_Create actionhook. This action hooks is called after the invoice email is sent. This means that when the invoice is sent its sent with the wrong number. I am going to look at this codee today for you guys. Its been running in my WHMCS for a while and i havn't touched it, i will just have to understand it again. 0 Quote Link to comment Share on other sites More sharing options...
LemonBarley Posted May 11, 2009 Share Posted May 11, 2009 i'm waiting for it 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted May 12, 2009 Author Share Posted May 12, 2009 I have just run the above code on mysql 5 and it runs. 0 Quote Link to comment Share on other sites More sharing options...
UltraUnix Posted September 5, 2009 Share Posted September 5, 2009 I'm looking to import invoices from another billing system which might have duplicate invoice number. Looking at your mod, seems to be able to fit into what I'm looking for. Base on your SQL query, it basically tells to append prefix on every new transaction. I tried manually change the ID in tblinvoice to XYZ{number} but later turned into 0. May I know hows the entry would look like after your mods? 0 Quote Link to comment Share on other sites More sharing options...
UltraUnix Posted September 6, 2009 Share Posted September 6, 2009 nevermind, got it figure. basically using append XYZ-{number} into invoicenum field. 0 Quote Link to comment Share on other sites More sharing options...
weba Posted January 19, 2010 Share Posted January 19, 2010 nice thinking shaun! 0 Quote Link to comment Share on other sites More sharing options...
suksuk.lee Posted May 30, 2011 Share Posted May 30, 2011 (edited) Would this still work in WHMCS 4.5? I'm just wanting to add a simple word like HOST-### in front of the number. I tried editing the lang file as follows: $_LANG["invoicenumber"] = "Invoice #: HOST-";$_LANG["invoicestitle"] = "Invoice #: HOST-"; This works but the email attachment sent out is still just ###.pdf - would be great if the PDF file name can be renamed too. Edited May 30, 2011 by suksuk.lee 0 Quote Link to comment Share on other sites More sharing options...
equipc Posted May 30, 2011 Share Posted May 30, 2011 I think this could be done with the EU VAT addon but I'm not sure 0 Quote Link to comment Share on other sites More sharing options...
suksuk.lee Posted May 30, 2011 Share Posted May 30, 2011 Thanks, the mod has this feature: the ability to assign custom invoice number formats when invoices are generated I'll give it a go... 0 Quote Link to comment Share on other sites More sharing options...
suksuk.lee Posted May 30, 2011 Share Posted May 30, 2011 I think this could be done with the EU VAT addon but I'm not sure Thanks, I think that addon did the trick! 0 Quote Link to comment Share on other sites More sharing options...
newgenservices Posted June 8, 2011 Share Posted June 8, 2011 Would this still work in WHMCS 4.5? I'm just wanting to add a simple word like HOST-### in front of the number. I tried editing the lang file as follows: This works but the email attachment sent out is still just ###.pdf - would be great if the PDF file name can be renamed too. You can just set the Sequential Invoice Number Format setting to HOST-{NUMBER} in WHMCS Admin General Settings \ Invoices More Info @ http://docs.whmcs.com/Invoicing#Proforma_Invoicing.2FSequential_Invoice_Numbering 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.