Jump to content

Sequential Invoice Number Format


d3m0n

Recommended Posts

Hello,

i have a question related to Sequential Invoice Number Format , that i have not been able to solve. I need to adjust WHMCS in accordance with the current system.

i have a pattern id - client id , number - invoice number , year - year invoice is issued .

the only tags that are currently available are :{YEAR} {MONTH} {DAY} {NUMBER}

is there a way how to add a client id into the pattern ? so that whmcs could generate the invoices like: {clientid}-{NUMBER}-{YEAR}

is it possible?

any help is highly appreciated , thx in advance.

thank

Link to comment
Share on other sites

it's going to be a variation on the hook 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'];
	$id = Capsule::table('tblinvoices')->where('id', $invoiceid)->value('userid');
	$year = date('Y');
	
	$customnumber = $id."-".$invoiceid."-".$year;
	
	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");
?> 

u0CE1bU.png

 

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