Skip to content

Allow a fixed width for the invoice number counter - #192

Closed
Bouni wants to merge 1 commit into
kittendevv:mainfrom
Bouni:fix/invoice-numbering-pattern
Closed

Bouni wants to merge 1 commit into
kittendevv:mainfrom
Bouni:fix/invoice-numbering-pattern

Conversation

@Bouni

@Bouni Bouni commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #152

The reported bug

In #152 a custom pattern (Фактура-{SEQ}) was saved and "Enable Automatic Invoice Numbering" looked checked, but new invoices still got INV-2026-001. That is the legacy format, used whenever invoiceNumberingEnabled is stored as "false". Older versions showed that stored "false" as a checked box, so numbering looked enabled while the pattern was ignored. This was fixed by #188 and is released in 2.5.0. On a fresh 2.5.0 instance:

  • numbering stored as off: next number INV-2026-001, checkbox correctly unchecked
  • numbering on: next number Фактура-001

What this PR adds

The follow-up comment in #152 lists the Bulgarian requirements: invoice numbers must be exactly 10 digits (0000000001). {SEQ} was always padded to 3 digits, so that was not possible.

  • {SEQ:N} and {CSEQ:N} pad the counter to N digits (1–20), so {SEQ:10} gives 0000000001. Plain {SEQ} / {CSEQ} keep 3 digits, so existing patterns are unchanged (backend/src/database/init.ts).
  • Patterns with a width also allocate the real number when the invoice is created, like plain {SEQ} (backend/src/controllers/invoices.ts).
  • The numbering settings page explains the new option.

Not included

Two other points from that comment need separate PRs and have their own issues:

Verification

On a fresh instance built from this branch, each pattern shows the preview and then two invoices created via the API:

Pattern Preview Created
{SEQ:10} 0000000001 0000000001, 0000000002
Фактура-{SEQ} Фактура-001 Фактура-001, Фактура-002
INV-{YYYY}-{SEQ} INV-2026-001 INV-2026-001, INV-2026-002
C{CNUM}-{CSEQ:5} C-00001 (no customer selected) C001-00001, C001-00002

The new-invoice form shows 0000000003 for {SEQ:10}. deno check src/app.ts passes.

🤖 Generated with Claude Code

{SEQ} and {CSEQ} were always padded to 3 digits, so formats that
require a fixed number of digits (e.g. Bulgaria: exactly 10 digits,
0000000001) could not be produced. {SEQ:N} and {CSEQ:N} now pad the
counter to N digits; plain {SEQ}/{CSEQ} keep 3 digits.

Patterns with a width also allocate the real number when the invoice
is created, like plain {SEQ}.

Refs kittendevv#152

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Bouni

Bouni commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@kittendevv Any opinion on this and the other 3 PRs? Let me know if I need to change something or if you're not happy with one or more PR

@kittendevv

Copy link
Copy Markdown
Owner

I was still working through em, everything seems great so far. Thanks for you continued contribution to Invio. It is however taking a little longer for me due to school stuff etc.

@Bouni

Bouni commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

I don't want to stress you, it was just out of curiosity if you feel things going into the right direction or not! Take your time

@kittendevv

kittendevv commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Btw about this pr im so sorry but I was also working on this for a little while now. I also made an implementation for this and I am so full of myself I am gonna merge my implementation I made myself. I hope you dont mind

Ive had a branch for it

@kittendevv kittendevv closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoice Numbering does not change with a custom one

2 participants