consul Posted January 12, 2018 Share Posted January 12, 2018 Dear all! Currently my configuration for Sequential Invoice Number Format form is: {YEAR}-{NUMBER} and this generate as first invoice the number 2018-1 If I wanted to get the number 2018-00001 , which setting should I use? Thank you! Best, Giorgio Link to comment Share on other sites More sharing options...
brian! Posted January 13, 2018 Share Posted January 13, 2018 Hi Giorgio, On 1/12/2018 at 14:29, consul said: If I wanted to get the number 2018-00001 , which setting should I use? you can't use an admin setting to change this - you'd need to use an action hook to modify it.... something along the lines of the hook 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 = date("Y").'-'.str_pad($invoiceid,5,"0",STR_PAD_LEFT); 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"); ?> bear in mind that this new format will only be used on future invoices - previously generated invoices would still use the old format. also, with this hook active, you shouldn't need to use {YEAR}-{NUMBER} in the sequential format box as this hook will overwrite those settings - though you can leave them in there if you prefer. Link to comment Share on other sites More sharing options...
Recommended Posts