Jump to content

Invoice prefix


Recommended Posts

Is there really no way to prefix invoices but to change the templates?

We have three companies under the same holding company, all using WHMCS. Seen from a legal point, we're not allowed to have 2 invoices that share the same invoice number. We'd like to prefix (or suffix) all invoices from company A to be A-1234, from company B to be B-1234 and company C to C-1234.

Link to comment
Share on other sites

8 minutes ago, DennisMidjord said:

One is using the newest version while the two other are using 5.3.14.

then if there are 3 installations, i'd be tempted to use a hook to create a custom invoice number - similar to the one I posted in the thread below...

in terms of v7+, the hook below would prefix invoices with a custom invoice number...

<?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 = "A-".$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");
?>

then for v5, you could rewrite the above and replace the capsule code with similar mysql code.... or just edit the templates! :P

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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