Jump to content

Letters in invoice numebrs


izghitu

Recommended Posts

Hi,

Is there any way to make WHMCS use letters in invoice numbers as well? For example I need invoices to have numbering like this:

US{NUMBER}

and also have the number increment automatically. I tried putting the US{NUMBER} thing in the invoice admin area but the letters are being ignored.

 

Please let me know.

Thanks

Link to comment
Share on other sites

5 hours ago, izghitu said:

Is there any way to make WHMCS use letters in invoice numbers as well?

from the settings, you could enable sequential invoicing...

https://docs.whmcs.com/Invoicing_Setup#Enabling_Sequential_Invoice_Numbering

or if you don't need Sequential Numbering, you could use a hook similar to the one I posted in the thread below...

<?php

/**
* Generate Custom Invoice Number Format
* @author brian!
*/

use Illuminate\Database\Capsule\Manager as Capsule;

function generate_custom_invoice_number_hook($vars) {
   $invoiceid = $vars['invoiceid'];
   $customnumber = "US".$invoiceid;
   
   if (isset($customnumber)) {
       try {
           $updatedInvoiceNumber = Capsule::table('tblinvoices')
                                   ->where('id', $invoiceid)
                                   ->update(['invoicenum' => $customnumber,]);
       }
       catch (\Exception $e) {
           // Deal with error
       }
   }
}
add_hook("InvoiceCreationPreEmail",1,"generate_custom_invoice_number_hook");
?>

 

Link to comment
Share on other sites

Magic! Sometimes I wonder how do you know all this stuff.

It did the trick but it seems there's an additional problem. Please see attached image, when I view the invoice in the client area it shows the required format in one place but not in the other. Any way to change that to match as well?

 

Please let me know.

Thanks

Screenshot_2018-08-27 support drivers md - Invoice #US41.png

Link to comment
Share on other sites

The reference number on the right is the ID of the invoice in database (tblinvoices.id). It has nothing in common with invoice number (tblinvoices.invoicenum).

Depending on your configuration, both numbers may seem identical, very similar (like in your case) or totally different.

If you want to use #US41 as reference number you have to edit bank transfer module and "play" with replace() or create a new one just for this purpose.

Link to comment
Share on other sites

5 hours ago, izghitu said:

Magic! Sometimes I wonder how do you know all this stuff.

occasionally, I surprise myself! 💡

5 hours ago, izghitu said:

It did the trick but it seems there's an additional problem. Please see attached image, when I view the invoice in the client area it shows the required format in one place but not in the other. Any way to change that to match as well?

the simplest solution would be to edit the gateway module code - both the 'banktransfer' and 'mailin' modules have unencrypted code and so can be edited.

https://docs.whmcs.com/Bank_Transfer

so in /modules/gateways/banktransfer.php (same line of code is in mailin.php too), you can change...

$code = '<p>'.nl2br($params['instructions']).'<br />'.$_LANG['invoicerefnum'].': '.$params['invoiceid'].'</p>';

to...

$code = '<p>'.nl2br($params['instructions']).'<br />'.$_LANG['invoicerefnum'].': '.$params['invoicenum'].'</p>';

... and that should now make both invoices numbers match.

S7A8OLD.png

if you're using the WHMCS auto-updater, you may need to manually edit the banktransfer.php file after each update, but as you can see, it's only a trivial change to make.

the documentation does correctly state that another option is to duplicate the file, and then edit that duplicate file - but then you'd have to reassign clients using 'banktransfer' to use the modified 'banktransfer2' instead - but whether that's worth the hassle, depends on the number of clients to change... personally i'd just edit banktransfer.php and leave them using it.

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