How to format Invoice Numbers incremented automatically?

Need help to auto number invoices, proposals and other documents. General convention followed in India is to identify these documents using financial year. Like FA2324-0001 is the Invoice done on Financial Year 2324 with number 1.

Please see the above graphic. I am unable to automatically set current year plus one so as to make a financial year format.

Can you please help how to do this or point me to the code where I can do changes.

thanks
yesbee

have you tried wrapping the digit and + in curly braces{}?
FA{yy}{yy+1}-{0000}

Skeptical, but give it a try

Ok. This shows logical thinkers think in similar pattern. But it didnt work in Dolibarr. :frowning:

We use this to automatically reset the numbering.
{yy} is here exchanged with the year from the systemdate.

grafik

Each January the counter is reseted.
grafik

Hope this helps…

Hi,

Thanks a ton for the reply. However, I was trying to achieve standard invoice numbering practice in India. Like IN2324-0001 (where 23 is current year achieved by {yy}) But I could not achieve {yy+1} as 24.

@eldy , @ksar any help please.

thanks and regards,
yesbee

Ηι @RiseValInfotech
If at years end last generated invoice is IN2324-0101 then for next fiscal year would be IN2425-0001 or IN2425-0102?

If you start every year with IN2324-0001 then use the mask as i wrote above and from 01.01.2024 your invoices start automatically with IN2424-0001.
Mask = IN{yy}24-{0000@0}

However, if you want your counter to be consecutive over the years, then unfortunately I can’t help you.

Hello :slight_smile:

in version 18.0.3, you can obtain this result with this change in htdocs/core/lib/functions2.lib.php…

Good continuation

2 Likes

In version 19.0.2

To have add dash, hypen or minus signs between current and next year. I used the following code in htdocs/core/lib/functions2.lib.php

		// We replace special codes except refclient
		if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') {	// yearoffsettype is - or +, so we don't want current year
			$numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal);
			$numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal);
			$numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal);
		} else { // we want yyyy to be current year
			$numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal);
			//$numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); // disable default {yy} to be current year
			$numFinal = preg_replace('/\{yy\}/i', date("y", $date). '-' .(intval(date("y", $date)) + 1), $numFinal); // Modified Date to be 24-25 if using {yy}
			$numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal);
		}

But this doesn’t get reflected throughout the system, like on invoice no. while on invoice card or generatting PDF file