Repository navigation
fix(numbering): keep order and bill numbers unique across resets - #1387
Conversation
A daily-reset series with the date/period toggle off reissued the same number every day (e.g. 0001), which violated the UNIQUE bill_number / order_number constraint and failed bill generation after midnight. - Resetting series always carry their date or period; only a series that never resets may omit it. Enforced in the generators and normalized by the order-numbering settings API. - Hide the include toggles in settings when the choice is forced. - Allocate numbers collision-safely: an already-issued number lifts the counter past the highest issued under the same head instead of failing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoKeep order and bill numbers unique across resets and setting changes
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
…unter An imported order or bill number with a suffix too large for the counter could lift the sequence past its incrementable range and halt future numbering. Only suffixes up to 9 digits now raise the counter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Problem
A store with an empty invoice prefix, "include period" off and daily reset issued bills as
0001,0002, … each day. On the next day the counter restarted at0001, violating theUNIQUEbills.bill_numberconstraint, sobill.generatefailed withpersistence.failedafter midnight. Orders had the same latent bug.Changes
generateOrderNumber/generateBillNumber.PUT /api/settings/order-numberingstores the effective include flags andGETreports them. The settings screen hides the include toggles when the choice is forced, and previews match.docs/architecture/data-and-migrations.md.Verification
test:sequence31/31,test:order-numbering-settings25/25; new cases fail against the previousmain/db.tswith the original UNIQUE error.npm run build,npm run build:frontend,npm run i18n:check,npm run docs:checkpass.🤖 Generated with Claude Code