Repository navigation
feat(contract): framework contract shows Order Amount and Remaining Quota; an order over the quota warns (#2807) - #2818
Merged
Conversation
…uota; an order over the quota warns (#2807) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…help; changeset (#2807) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…ign only (#2807) 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. |
Contributor
Author
|
repo:hotcrm#1 · huangyiirene · session_01J8VVAk8tegvAi1ECkgCFfc ACCEPT · 2026-11-26T12:13ZHead-sha: 维护者速读
席位核对
|
huangyiirene
pushed a commit
that referenced
this pull request
Nov 26, 2026
…-parallel (#2806) docs/STATUS.md keeps both sides: 636 fields and 55 flows, as pnpm validate prints on the merged tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
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
Part of #2807: this PR lands the roll-up and the warning. The admin switch to block waits on a decision (see Acceptance notes).
Clause-②: no
Metadata-protocol: none
Metadata-impact: reviewer — a new formula field (Remaining Quota), a new field group (Order Totals) that the three roll-up fields move into, and a warning-only validation on the order that refuses no write
维护者速读
What changes
Order Totals on the contract. A new field group
orders("Order Totals") oncrm_contractholds:order_amount(the Contracts: a contract form (order / framework / other), the order contract's amount follows its order, and an active contract changes only through Change #2804 summary of linked orders'total_price), now shown on framework contracts as well as order contracts. This is the ordered amount. One roll-up serves both forms, so the quota and an order contract's value count an order the same way: tax included, every linked order whatever its status.remaining_quota(new formula, currency):contract_value − order_amounton a framework contract. It is below zero once the orders are over. It is empty while the roll-up is still NULL (a contract that predates the summary, untilmigrate summary-nulls).order_amount_differs, moved here and nowvisibleWhenorder contract only.The three moved out of
valuebecausecontract_print_pageprints thevaluegroup whole ("every member is something the customer signs"). Running totals do not belong on the signed document.The warning.
crm_sales_order.framework_quota_exceededis aconditionalrule (whenthe order names a contract) withseverity: 'warning'. It fires when:total_price);stored order_amount − previous share + new total > contract_value.The previous share is
previous.total_pricewhen the order was already linked to the same contract (read asrecord.crm_contract.id, because a predicate that reads through a reference may not also read it as a value). An edit that leaves the share as it was, or lowers it, is not judged, so an order already over is not flagged on every save and lowering is always free. The answer carries it inwarningsand the console shows "Saved — with warnings" (browser-verified below).Not here: the admin switch to block. See Acceptance notes.
Text. Labels, help, section and warning in en / zh-CN / es-ES / ja-JP. The Contracts manual (three locales) and the in-app Contracts and Orders help (two) gain the quota.
docs/STATUS.mdfield count is 636→637, aspnpm validateprints.Tests
Run on head
ffe1c5a9. The logs are in the folded blocks below.test/framework-contract-quota.test.ts(new, 10 tests, REST data door as a sales rep) covers:Local runs
Acceptance notes
The admin switch to block is not in this PR. Measured on 18.6.0:
activeis one of the two settings an installation may set on a packaged rule (ADR-0029 D9.2a,tenantRuleSettingsOf). ButPUT /api/v1/meta/object/crm_sales_orderas the admin answers403 NOT_OVERRIDABLE: "'object/crm_sales_order' is provided by a managed package and is sealed" (ADR-0131 D6).HookContexthas no settings accessor,defineStacktakes no settings manifest, andmanifest.configurationwas removed in spec 17.So an admin-switchable block needs either a platform capability or an app-made setting. The options are in the report on Framework contracts: roll up the orders under them (ordered amount, remaining quota) and warn on over-limit, with an admin switch to block #2807, for the maintainer. A block rule shipped switched off with no switch would be declared-and-not-enforced, so none is shipped.
A line's save does not show the warning. A line raises the order's total through
sales_order_total_rollup's own write to the order. The platform hands that nested write's advisories to no listener: "A nested write a hook or a flow makes inside this one carries its own options". The contract's Remaining Quota below zero is the sign that stays. Documented in the help.Cancelled orders still count toward the Order Amount, as they already did on an order contract since Contracts: a contract form (order / framework / other), the order contract's amount follows its order, and an active contract changes only through Change #2804. This follows the ruling's "sum of the linked orders". Excluding them would change Contracts: a contract form (order / framework / other), the order contract's amount follows its order, and an active contract changes only through Change #2804's order-contract value too, so it is left as ruled.
The record page shows the three fields on every form. Measured: the console's synthesized record page does not apply a field's
visibleWhenin its detail sections. An Other contract shows Order Amount, Differs and Remaining Quota, empty or computed. This was already the case for Contracts: a contract form (order / framework / other), the order contract's amount follows its order, and an active contract changes only through Change #2804's two fields. The metadata states the condition, and the renderer gap is reported for upstream filing, not worked around.One seeded order already sits over its framework contract. The seed load reports it once as an advisory hit, and nothing fails.
src/sales/pages/**,docs/STATUS.md, the in-app help and the changeset are outside the claim's file list or under "user manual". No page file was changed. The print page is only read, by the test.src/sales/objects/_thresholds.tssays aseverity: 'warning'rule has "no observable surface at all". On 18.6.0 that is no longer true (warningson the REST answer, a console toast). It is noted here and not changed.Verification
On a dev server from this branch (port 4017, fresh database, headless Chrome as the dev admin):
Two-minute check:
pnpm exec vitest run test/framework-contract-quota.test.tsshould show 10 passed. Or, in the app, link an order to a framework contract so that the orders exceed its value. The save goes through with a yellow warning, and the contract's Remaining Quota goes negative.Read first, by risk:
src/sales/objects/sales_order.object.ts:QUOTA_*andframework_quota_exceeded, especially the previous-share term (previous.crm_contract == record.crm_contract.id).src/sales/objects/contract.object.ts:remaining_quotaand theordersgroup move.content/docs/(product)/sales/contracts.mdx: the quota section, the business wording users read.🤖 Generated with Claude Code
https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc