Repository navigation
Conversation
…'t skip numbers Invoice.postAdd() took the next invoice number as soon as an Invoice object was created. Checkout recalculation (/checkout/update), card payment createSession validation, the "Duplicate and reverse" preview and funding invoices built during checkout all create invoices that are never committed, so each of them burned a number and left gaps in the sequence. The number is now allocated in prePersist(), i.e. on commit only. Since an unsaved invoice has no number until then, getOriginalInvoiceLine() in Enrolment, EnrolmentMixin and EnrolmentService share one null-safe comparator that keeps lines of a not yet committed invoice last, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude reviewJira: CS-649. The Jira tool wasn't available in this run, so I couldn't check the change against the ticket. This incremental range adds no new CS-649 code changes. Reviewed range: Assessment: This range is only a merge of Issues: No issues found. Reviewed up to fff397e |
This branch has not been deployed
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.
Summary
Invoice numbers were taken when an
Invoiceobject was created, not when it was saved. Several flows build invoices that are never committed, and each one burned a number. CCE's gap (469922 → 469927 with consecutive DB ids 469916, 469917) matches this: no invoice is missing, four numbers were taken and thrown away.Flows that used to burn a number without saving anything:
An unsaved invoice now has no number until commit, so
getOriginalInvoiceLine()(Enrolment, EnrolmentMixin, EnrolmentService) uses one shared null-safe comparator,EnrolmentService.BY_INVOICE_NUMBER. It keeps lines of a not yet committed invoice last, as before. Without it the Java version would throw an NPE and the Groovy ones would treat the unsaved invoice as the oldest.A number set explicitly before commit (e.g. quote → invoice) is kept.
Evidence
New
InvoiceTest.testInvoiceNumberIsAllocatedOnCommitOnly:postAdd()): fails withexpected: <null> but was: <2>, because the unsaved invoice took a number.After:
InvoiceTest6/6 passed.ClassBudgetUtilTest(4) andClassCostUtilTest(21) go throughgetOriginalInvoiceLine()and all passed.These ran locally under
server:integrationagainst MariaDB withTZ=Australia/Sydney.Merge Danger
Door: two-way
No schema or data change. Reverting restores the old behaviour. Numbers that were already skipped stay skipped.
Blast Radius: invoicing
Any code that reads
invoiceNumberof a new, not yet committed invoice now getsnull. I checked checkout:submitPaymentandsucceedPaymentcommit beforefillResponsereads the number, and the client shows it only in the post-payment message./checkout/updatenow returnsinvoiceNumber: null, which the summary doesn't display. Customer scripts that read the number of a brand-new invoice before it is saved would also seenull.🤖 Generated with Claude Code