Skip to content

fix(revenue): read a quote's Approved Discount % in percentage points (#2920) - #2930

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-2920-approved-discount-scale
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-2920-approved-discount-scale

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Closes #2920

Clause-②: no
Metadata-protocol: none
Metadata-impact: reviewer

维护者速读

  • 销售和经理在报价单详情页看到的「已批准折扣」从错误的 3,500.00% 变回正确的 35.00%,与「折扣」并排一致。
  • 属于报价折扣审批功能(收入模块),修正审批后显示的折扣数值被放大一百倍的问题。
  • 只改显示刻度,存储的数值和审批判断都不变;出错时整改可直接撤回,不影响已有数据。
  • 无

What changes

crm_quote.approved_discount (Approved Discount %) was a Field.percent with no max, so the platform (percentScaleOf, @objectstack/spec/data) read it as a fraction. It now declares max: 100, the percentage-points scale of the two discounts it is compared with (discount and the line items' discount, both max: 100), per docs/developers/number-formats.md and ruling B on #2910.

Readers keep their behaviour: the quote_discount_approval flow stamps the larger of discount and max_line_discount (each at most 100, so the new bound refuses nothing it can write); discount_approval_before_presented compares raw stored numbers; no view, dataset or report names the field.

Tests

  • test/money-rollup-currency.test.ts: a new block pins crm_quote.approved_discount, crm_quote.discount and crm_quote_line_item.discount on the whole (points) scale.
  • Ablation: with max: 100 removed, crm_quote.approved_discount fails (1 failed, 33 passed); restored, 34 passed.

Acceptance notes

Verification

Local runs (head 2ec1247)
  • vitest run test/money-rollup-currency.test.ts test/quote-discount-approval.test.ts test/quote-discount-ceiling.test.ts test/flow-quote-print-presented.test.ts: 4 files, 116 tests passed, VERDICT command-exit 0.
  • pnpm validate && pnpm typecheck && pnpm lint && pnpm hygiene: VERDICT command-exit 0 ("Validation passed").
  • pnpm build and the full pnpm test: left to CI.

Read first: src/revenue/objects/quote.object.ts (the approved_discount declaration), then the new block at the end of test/money-rollup-currency.test.ts.

Two-minute check: pnpm exec vitest run test/money-rollup-currency.test.ts, expect 34 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xRBcUpajguxop2zMyDN9K

…#2920)

crm_quote.approved_discount is a Field.percent with no max, so the
platform's percentScaleOf read it as a fraction: an approved 35 drew as
3,500.00% on the record page beside Discount % 35.00%. Declare max: 100,
the scale of the two discounts it is compared with, and pin all three
on the whole-points scale in test/money-rollup-currency.test.ts.

Claude-Session: https://claude.ai/code/session_017xRBcUpajguxop2zMyDN9K
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hotcrm Ignored Ignored Dec 3, 2026 1:42am UTC

Request Review

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

L1 review: ACCEPT · reviewer-class · seat lands (2026-12-03T01:52Z)

  • Measured before the edit: an approved 35 % discount drew 3,500.00% on the record page. With max: 100 it draws 35.00%. The stored value, the API and the approval are unchanged.
  • The ablation fails without max: 100, and the reader suites (approval, ceiling, print) pass. All 18 checks on 2ec1247 finished green.
  • Readying and queueing for merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 3, 2026 01:54
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 58efdc4 Dec 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quote: Approved Discount % (approved_discount) is a Field.percent with no max, so the platform reads it as a fraction — a stored 15 may draw as 1500%

2 participants