Allow user-configurable invoice numbering start #6

Merged
odweta merged 1 commits from odweta-ideal-spork into main 2026-09-10 17:23:58 +02:00
odweta commented 2026-09-10 17:23:18 +02:00 (Migrated from github.com)

Invoice numbering always started at 001 for each new year, with no way for a user to pick up numbering at a different point (e.g. continuing from a previous system, or reserving a block of numbers).

Approach

  • Added a user_settings table with an invoice_starting_number column (default 1).
  • Added GET/PUT /api/settings to read and update this per-user setting.
  • Invoice creation now seeds a year's counter at GREATEST(existing max invoice number for that year, starting_number - 1). This means the setting only takes effect for a year that hasn't issued any invoices yet, so existing numbering for years already in use is never disturbed.
  • Added a "Číslování faktur" panel in the account menu (mirrors the existing "Změnit heslo" panel) where the user can view and change the starting number, with 1 as the suggested/default placeholder.

Notes for reviewers

  • The starting number only affects the next year that has no invoices; it won't renumber or skip existing invoices for the current year.
  • No migration needed for existing rows since the setting defaults to 1, matching current behavior.

Verified with npm test (existing suite passes).

Invoice numbering always started at `001` for each new year, with no way for a user to pick up numbering at a different point (e.g. continuing from a previous system, or reserving a block of numbers). ## Approach - Added a `user_settings` table with an `invoice_starting_number` column (default `1`). - Added `GET/PUT /api/settings` to read and update this per-user setting. - Invoice creation now seeds a year's counter at `GREATEST(existing max invoice number for that year, starting_number - 1)`. This means the setting only takes effect for a year that hasn't issued any invoices yet, so existing numbering for years already in use is never disturbed. - Added a "Číslování faktur" panel in the account menu (mirrors the existing "Změnit heslo" panel) where the user can view and change the starting number, with `1` as the suggested/default placeholder. ## Notes for reviewers - The starting number only affects the *next* year that has no invoices; it won't renumber or skip existing invoices for the current year. - No migration needed for existing rows since the setting defaults to `1`, matching current behavior. Verified with `npm test` (existing suite passes).
Sign in to join this conversation.