Repository navigation
feat(revenue): a quote discounted above 30% goes to a sales manager for approval (#2751) - #2848
Merged
Merged
Conversation
…ine lock (#2751) Work in progress, not for review: the ruling's line-item lock is not fully available on the pinned @objectstack 18.6.0 (plugin-approvals has no master-detail row lock there; it is merged upstream, unreleased). Parked on this branch so the card resumes from it once the maintainer decides. - QUOTE_DISCOUNT_APPROVAL_PERCENT = 30 beside the 60 ceiling - crm_quote: max_line_discount (summary, max), discount_approval_status (approval mirror), approved_discount, and the transition gate discount_approval_before_presented - quote_discount_approval (+ insert twin): Sales Manager position, excludeSubmitter, lockRecord; reject or recall -> Draft Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
… platform's line lock (#2751) The WIP's two flows become one record-after-write flow (protocol 19, flow-create-update-pair). The quote's lines are held by the platform's detail-row lock (bindDetailRowLockHook, @objectstack/plugin-approvals 19.0.0-next.2), so the 18.6.0 last-line gap is gone. Mark Presented, Reject and Revise are not offered while the approval is pending. The new fields, the gate's message and the flow's steps are in all four packs. The test pins the three symptoms: no approver, self-release, price edits during review. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
…l, the automation table, REQ-0013 and QUO-014; print-path pins; changeset (#2751) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
…fit in (#2751) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
…the line roll-up; counts and coverage follow the new flow (#2751) The settled-quote freeze refused the platform's recompute of max_line_discount, which the cascade of a quote delete triggers as the caller: the freeze now treats that roll-up as a platform field. The docs' flow and field counts read 51 and 641, the new flow's runAs carries its rationale, the print suite names the flow it drives, and the ceiling suite records the approval its presented quote needs. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Nov 29, 2026
…a discount approval is pending; the lock refuses them (#2751) The hiding goes past the ruling's words and moves to its own card. The record lock remains the control, pinned through the action door. Docs, the in-app manual, REQ-0013 and the changeset say "refused" instead of "not offered"; the changeset also names the settled-quote freeze change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
Brings in the shard-2 timeout fix from #2854. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
Contributor
Author
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns 维护者速读
席位核对 — ACCEPT · repo:hotcrm#2 · head f6fad95
|
Resolves the one conflict, docs/STATUS.md: the branch added 3 fields and 1 flow (the quote discount approval), main removed 2 pages (the quote and contract detail shells, #2740). The counters combine to 641 Fields, 2 Pages, 51 Flows, matching what `pnpm validate` prints on the merged tree. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
Contributor
Author
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns 席位核对 — ACCEPT · repo:hotcrm#2 · head 1a85f31This is a base update only. The ACCEPT of seat record 7250855170 (head
|
Contributor
Author
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns Merged as |
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.
Fixes #2751
Metadata-impact: maintainer — any other change to who can see or change what: a quote discounted above 30% can be presented only after a sales manager's approval, and the quote and its lines are locked while it waits; a hook changed (the settled-quote freeze lets the platform's line roll-up through)
Clause-②: no
Metadata-protocol: none
Ruling-ref: hotcrm#2751 comment 7157473292 — the maintainer, verbatim: 「2751 同意,开始认领并处理这个任务」 (
/pm-dispatch hotcrmsession, 2026-11-25T08:47Z), on option A narrowed (30% on the quote's or any line's discount, no amount threshold, sales-manager position withexcludeSubmitter, quote and lines locked, reject to Draft, the gate on every path to Presented including print, the platform approval process); held by his 「A,允许按卡开分支,四张卡二号席认领」 (comment 7158163459, 2026-11-25T09:18Z) until the platform line lock shipped, resumed on 19.0.0-next.2 (comment 7247295054)维护者速读
What changes
quote_discount_approval(src/revenue/flows/quote-discount-approval.flow.ts,record-after-write, one flow per protocol 19'sflow-create-update-pair): a quote moved into, or created in, In Review whose Discount % or any line's is aboveQUOTE_DISCOUNT_APPROVAL_PERCENT(30,src/sales/objects/_thresholds.ts) opens an approval for thecrm_sales_managerposition:excludeSubmitter,lockRecord,first_response,onEmptyApprovers: 'admin_rescue', mirrored intodiscount_approval_status. Approve stampsapproved_discount; reject or recall returns the quote to Draft.@objectstack/plugin-approvals@19.0.0-next.2bindsbindDetailRowLockHookbeside the record lock, so a held quote's master-detail lines refuse insert, update, delete and a move on or off, the last line included (the 18.6.0 gap that put this card on hold). No hotcrm-side line freeze is written.crm_quotegains three read-only fields in thepricinggroup:max_line_discount(amaxsummary of the lines),discount_approval_status(Not Required, Pending, Approved, Rejected) andapproved_discount; and the transition gatediscount_approval_before_presentedon the move into Presented (Mark Presented, Edit, REST, and the print flow, which runs as the rep).RECORD_LOCKED. Hiding them while Pending was split out of this PR at L1 and is Quote: hide Mark Presented, Reject and Revise while the discount approval is Pending (the courtesy half split out of PR #2848) #2850, blocked on this PR.quote_workflow,src/revenue/objects/quote.hook.ts) listsmax_line_discountamong the platform fields: the platform recomputes the roll-up as the caller when a settled quote's lines cascade on its delete, and the freeze refused that write (measured: fourtest/quote-line-freeze.test.tsdelete cases went 500 / cascade stopped before this line, green after).formsections (fields carrygroup), no permission-set change (no set hides the new fields, so View All / Modify All no longer opening fields does not reach them), the flow labels and steps in every locale (i18n/missing-flow0).content/docs/(product)/sales/quotes*.mdx(en, zh-Hans, zh-Hant), the automation table (three locales, 51 flows), the in-app Revenue manual (src/revenue/docs/crm_revenue_quotes*.md),docs/requirements/0013-quote-discount-approval.md(REQ-0013),docs/feature-inventory.mdQUO-014, the flow/field counts in README, introduction and STATUS. Changeset.changeset/2751-quote-discount-approval.md(minor).Tests
test/quote-discount-approval.test.tspins the three p1 symptoms of the hold comment against the real approval (action door, approvals door, data door, REST):RECORD_LOCKEDwhile pending, through the action door the console posts to; a manager's own quote cannot be approved by them (403) and another manager approves it; an over-the-line Draft refused straight to Presented (Edit and REST); approved then presented; a discount deepened after the approval refused; a rejection back to Draft and still not presentable;RECORD_LOCKEDwith nothing stored; a manager may still delete the held quote (quote, lines and request go); after the decision the quote and lines take edits again.test/flow-quote-print-presented.test.tsadds the print path: an unapproved over-the-line Draft keeps Draft, a pending quote keeps In Review, an approved quote is presented by printing.Red before, green after. The same file on
origin/main142e7a1 with only the constant added (anorigin/mainworktree,QUOTE_DISCOUNT_APPROVAL_PERCENT = 30in_thresholds.ts, nothing else). At 72326be the file held 23 cases and the reviewer measured 23 failed of 23 (this body first said 22 of 22, a miscount). At 8128731 it holds 22 (the button case went with the hiding) and reads 22 failed of 22. Not every one is red on behaviour: 9 fail on it (no pending approval request on the quote7,expected [] to have a length of 11,an over-the-line quote no manager approved was presented1), and 13 fail first on a fixture field the change adds, waiting for themax_line_discountroll-up to read a value (expected undefined to be 40,... to be 30,... to be +0), before reaching the behaviour they pin. On this branch: green.Full suite at 72326be
pnpm buildthenpnpm exec vitest run --maxWorkers=2under the shared verify lock:VERDICT command-exit 0,Test Files 346 passed (346),Tests 6625 passed | 58 skipped (6683). The run before the last commit (at aa40142) read 10 failed in six files, each fixed in 72326be: the four settled-quote delete cases (the freeze line above), the two ceiling cases whose quote now needs the approval verdict, the flow-elevation rationale, the runtime-coverage roster, and the STATUS / README / introduction counts.L1 fix round at 8128731
Under the shared verify lock:
pnpm validateexit 0 (Validation passed) ·pnpm typecheckexit 0 ·pnpm lintexit 0, 0 warnings, 54 suggestions ·pnpm hygieneexit 0 (source hygiene clean), allVERDICT command-exit 0. The test files that read the touched files (test/docs-*,test/quote-*,test/automation-docs-coverage,test/action-references,test/flow-quote-print-presented,test/changeset-version-wrapper):Test Files 57 passed (57),Tests 1073 passed | 9 skipped (1082). The full suite is CI's on this head.Acceptance notes
approved_discountrule ("approved for this deep a discount":discount_approval_before_presentedlets an over-the-line quote into Presented only whenapproved_discountis at least both its Discount % and its deepest line's, without which a discount deepened after the approval would be presented on the old approval), and the freeze listingmax_line_discount(without it a settled quote with lines could not be deleted). Hiding Mark Presented, Reject and Revise while pending is no longer in this PR: it moved to Quote: hide Mark Presented, Reject and Revise while the discount approval is Pending (the courtesy half split out of PR #2848) #2850.Roll-up summary recompute failed … Record … not found in crm_quote), the same warningcrm_project.approved_budgetalready logs onmain. Not filed from here; the seat may route it.src/revenue/pages/quote_detail.page.tsorsrc/sales/pages/contract_detail.page.ts.Verification
Two-minute check:
pnpm exec vitest run test/quote-discount-approval.test.ts— expect 22 passed. In the console: as a sales rep, give a quote a 40% discount and click Submit for Review: the quote reads In Review, Discount Approval Pending, and clicking Mark Presented is refused with "This Quote is locked while an approval is in progress"; signed in as a sales manager, the request is in the approvals Inbox.Read first, by risk:
src/revenue/objects/quote.object.ts(thediscount_approval_before_presentedcondition),src/revenue/flows/quote-discount-approval.flow.ts(the start condition and the closing writes),src/revenue/objects/quote.hook.ts(the one freeze line).Local gates at 72326be
pnpm validateexit 0 (38 Objects 641 Fields,51 Flows) ·pnpm typecheckexit 0 ·pnpm lint(os lint --strict) exit 0, 0 warnings, 54 suggestions ·pnpm hygieneexit 0 (source hygiene clean) ·pnpm buildexit 0 ·pnpm testas above. CI reads on the PR's own check-runs.Generated by Claude Code