Repository navigation
feat(sales): lock an order's amount once Confirmed; Subtotal is the lines' sum on an order with lines (#2826) - #2834
Merged
objectstack-fleet[bot] merged 4 commits intoNov 27, 2026
Conversation
…s the lines' sum on an order with lines (#2826) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…ls, the docs site and a changeset (#2826) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…ft; swept refusal count 110 (#2826) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
Contributor
Author
|
repo:hotcrm#1 · huangyiirene · session_01J8VVAk8tegvAi1ECkgCFfc ACCEPT · 2026-11-27T09:17ZHead-sha: 维护者速读
席位核对
|
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.
Requested by Irene · project thread
Fixes #2826
Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — a hook changed: a person's edit of a confirmed, completed or cancelled order's amount, and a typed Subtotal on an order with lines, are now refused
维护者速读
What changes
sales_order_workflow(src/sales/objects/sales_order.hook.ts), onbeforeUpdateby a person (ctx.userpresent, the line lock's exemption):subtotal,discount,taxorshipping_handlingagainst the stored row, it is refused409 RECORD_LOCKEDwith reasonamount_confirmed/amount_completed/amount_cancelled: "Order X is Confirmed, so its amount can no longer be changed. Send it back to Draft first." (Completed / Cancelled: "… can no longer be changed."). Unchanged figures sent back by a form pass. A write that moves a Confirmed order to Draft and changes the amount in the same request is refused; the amount changes in the next write.subtotaland the order has lines, a value other than the lines' sum (the roll-up's own formula, rounded to cents) is refused with400 VALIDATION_FAILED: "Order X has lines, so its Subtotal is the sum of its lines and cannot be typed. Change the lines instead." I chose refuse over override: an override would drop the typed number without telling anyone why.sales_order_total_rollup's write carries the sum and passes. An order with no lines takes a typed Subtotal, as before.readonlyWhen, but objectql strips a TRUEreadonlyWhenfor every caller,isSystemincluded, and does it without an error. On the status lock that would also strip the seed's and an import's roll-up writes to confirmed orders. On "has lines" there is no field of the order to test, and adding a line count would strip the roll-up's own Subtotal write. So the form still shows the four fields as editable, and saving refuses. The Subtotal help text says so.RECORD_LOCKED, and a newVALIDATION_FAILEDentry. Each is translated in zh-CN, ja-JP and es-EShooks.ts; English is the declared message.subtotalgets a description (help text), en/zh-CN/ja-JP/es-ES.src/docs/crm_sales_orders.md(+.zh.md), and the site pagecontent/docs/(product)/sales/orders.mdx(+ zh-Hans and zh-Hant). The zh headings carry an explicit English anchor..changeset/2826-order-amount-lock.md(minor).Tests
test/sales-order.test.ts, new block "the header amount locks once the order leaves Draft (Sales orders: lock Subtotal, Discount %, Tax and Shipping once Confirmed; Subtotal read-only when the order has lines #2826)", 7 cases on the booted stack:hooks.run … { system: true }) changes a confirmed order's amount, and a seeded line on a confirmed order still rolls up;test/framework-contract-quota.test.ts: the raise and lower now go through Draft, and the test asserts the 409 on Confirmed first. The quota warning is still asserted on the raise and absent on the lower.test/o2c-parallel-figures.test.ts: the amount change goes Draft, then edit, then Confirm. Expectations are unchanged.test/refusal-envelope.test.ts: the swept call-site count goes from 108 to 110 (two newrefusecalls).if (false && …)), and the Sales orders: lock Subtotal, Discount %, Tax and Shipping once Confirmed; Subtotal read-only when the order has lines #2826 tests re-run:git checkout.Acceptance notes
src/sales/actions/sales_order.actions.ts) now says the lines and the amount lock, in en/zh-CN/ja-JP/es-ES; the site docs that quote it (orders.mdx + zh-Hans/zh-Hant) and the changeset say the same.Verification
Final head and readings are in the comment below. Two-minute check: in the console, confirm an order, edit its Tax, and save. Expected: the save is refused with "Order … is Confirmed, so its amount can no longer be changed. Send it back to Draft first."
Read first, by risk:
src/sales/objects/sales_order.hook.ts: the new block before "The header totals follow their inputs" (thectx.userexemption and theprevious.statusjudgement).test/framework-contract-quota.test.ts: the reworked raise and lower path.src/sales/translations/*/hooks.ts: the new sentences.🤖 Generated with Claude Code
https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc