fix(invoices): preserve leading zeros in invoice numbers - #76
Merged
Conversation
Reported: setting Next Invoice # to "0002" produced INV-2 — the leading zeros were stripped because invoiceNextNumber is stored as a number. Preserve the width the user typed and zero-pad to it: - Settings.invoiceNumberPadding (new, optional): the pad width. - Settings form: the "Next Invoice #" input is now text (leading zeros survive); on save we capture the raw digit width as the padding, and on load we show the padded value so the width persists across re-saves. - generateInvoiceNumber pads to that width (padStart never truncates, so larger numbers are unaffected). - Tests for the padded / unpadded / wider-than-pad cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying helm with
|
| Latest commit: |
d70962e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://be0460ca.helm-d5s.pages.dev |
| Branch Preview URL: | https://fix-invoice-number-padding.helm-d5s.pages.dev |
✅ AgentGate: Passed4 files changed · +63 -5 lines No issues found. Generated by AgentGate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Setting Next Invoice # to
0002producedINV-2— the leading zeros were stripped, becauseinvoiceNextNumberis stored as a number andgenerateInvoiceNumberdid${prefix}${next}.Fix — preserve the width you typed
Settings.invoiceNumberPadding(new, optional) — the zero-pad width.0002survives). On save, the raw digit width is captured as the padding; on load, the field shows the padded value (0002) so the width persists across re-saves.generateInvoiceNumber— zero-pads to that width.padStartnever truncates, so a number wider than the pad (e.g.12345) is unaffected.So
0002 → INV-0002,0003 → INV-0003, and existing 4-digit numbers like1001are unchanged.Verification
npm run build✓ ·npm run check:cycles✓ ·npm run test:run239 pass (+3: padded, unpadded, and wider-than-pad). Worth a quick real check: set Next Invoice # to0002, save, and confirm the next invoice isINV-0002.🤖 Generated with Claude Code