Jump to content

[MOD] Custom Invoice Numbers


Shaun

Recommended Posts

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 :cry:

 

Small Print: All care, no responsibility.

Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...
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.

Link to comment
Share on other sites

  • 3 months later...

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?

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...

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 by suksuk.lee
Link to comment
Share on other sites

  • 2 weeks later...
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated