marcato21's avatar

Invoice Number in Controller

Hi,

I need to make an Invoice code with the following template :

INV-YYYYMMDDXXXXX (XXXXX = 5 digit running number)

Then, I write these codes in my 'store' for the Controller

$inv = 'INV-';
$invcode = $request->$inv.date().$invnum;
$invnum = $invnum + 1;

But the invnum is only 1 digit, and I need like 00001 when the 1st Invoice is generated.

Can anyone help me? Thanks

0 likes
2 replies
realrandyallen's avatar
Level 44

You can use sprintf for this:

$invnum = sprintf('%05d', $invnum + 1);

Please or to participate in this conversation.