Single sequential number in Invoice Form Print Format

Hello,

I’m trying to get my Invoices to only list a single sequential number that reverts to 0 on Jan 1st and gets +1 for every confirmed invoice throughout the year.
I tried looking into Naming Series but I can’t just use .### and reset it at the beginning of the year as I guess that will conflict with last year’s invoices.

How can I implement this function?

I’m based in Italy, where invoices follow a numbering scheme like this:

n°1 - 10/01/2022
n°2 - 05/03/2022
[...]
n°22 - 03/07/2022
[... new year ...]
n°1 - 08/01/2023 etc.

A workaround I thought about is this: Use a naming series which includes .YYYY and reset the number manually every new year. Filter the text out to only get the sequential number. I’m not sure how I could do that though.

Is there an easier way?
I’m happy to script something but might need a little info on how to integrate that in the DocType + how to store a sequential counter’s value permanently, since my machine gets switched off every evening.

TIA

Name is the primary key in the database and you cannot have duplicate entries for it. So a naming series YYYY.-.## will reset the counter to zero every year (like 2022-01, 2023-01 etc). You can define a custom field and populate that with counter from naming series on submit

Thanks!
Is there a way I can filter that 2022-1 to make it become just 1?

Edit:

I did a little jinja thing on the Print Format and I achieved the result I was looking for :slight_smile:

{% set spl = doc.name.split('-') %}
<small>n° {{ spl[1] }} - {{ doc.posting_date }}</small>