Skip to content

fix(marketing,sales): Response Rate %, ROI % and Attainment % read as percentages (#2919) - #2931

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-2919-percent-formulas
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-2919-percent-formulas

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Closes #2919

Clause-②: no
Metadata-protocol: none
Metadata-impact: reviewer — three existing formula fields change only how they are drawn (returnType: 'percent', max: 100); the expressions are byte-identical, nothing is stored, the API value is unchanged (measured below), and nothing changes who can see or change what. Precedent note: #2910 declared the same kind of change maintainer; the reviewer decides.

维护者速读

  1. 用户能看到什么变化:营销活动的响应率、投资回报率和销售预测的达成率,在记录页和列表里由裸数字(如 41.67)变成带百分号显示(41.67%)。
  2. 为什么做:延续项目预算使用率和毛利率的同一做法(按百分点存取的裁定),让同一类百分比在各处读法一致。
  3. 出错会怎样:只改显示,接口和导出读到的数字不变;如显示不对,整个改动可直接撤回。
  4. 要你做什么:无。

What changes

  • crm_campaign.response_rate (Response Rate %) and crm_campaign.roi (ROI %): returnType: 'percent', max: 100, percentDisplay: 'plain' (a rate, and ROI goes negative on a loss, so no progress bar). Expressions unchanged, still * 100.0 /.
  • crm_forecast.attainment_pct (Attainment %): returnType: 'percent', max: 100; keeps the bar (progress toward the quota). Expression unchanged.
  • This follows docs/developers/number-formats.md (ruling B on feat: totals of amounts show the tenant currency; Budget Used % and Gross Margin % read as percentages (#2569) #2910): a max above 1 is the platform's statement (percentScaleOf gives whole) that the value is in percentage points, so the API keeps reading 41.67.
  • The forecasting docs (en, zh-Hans, zh-Hant) say the zero case reads 0.00% and that the API reads 106.00 where the screen shows 106.00%.
  • One changeset.

Readers checked (none changes behaviour)

  • Views: src/sales/views/forecast.view.ts lists attainment_pct as a column in three views and deliberately does not sort by it (a formula). No view lists response_rate or roi.
  • Datasets and dashboards: forecast_metrics' Attainment measure is a derived closed_sum / quota_sum ratio and does not read attainment_pct; no dataset, dashboard, report or page reads response_rate or roi.
  • Flows and hooks: forecast-snapshot.flow.ts and opportunity.campaign-metrics.hook.ts name the formulas only in comments; they write the stored operands, never read the formula. No validation reads any of the three.
  • Actions: campaign.actions.ts mentions response_rate in a comment only.
  • Tests: campaign-member-unique asserts response_rate reads 100 through the engine, still green; campaign-member-lifecycle, campaign-enrollment-gates, seed-consistency, hooks-runtime-service, flow-scheduled green.
  • Translations (four packs per field) carry labels and help only; no change.

Measurement

objectstack dev on this branch and on the origin/main declarations, same seed, admin, Chromium on the record pages and GET /api/v1/data/...:

Field API before API after Page before Page after
Response Rate % (Q3 Enterprise Email Nurture) 41.67 41.67 41.67 41.67%
ROI % (same campaign) 400 400 400.00 400.00%
Attainment % (quarter, quota 1,400,000) 106.07 106.07 106.07 106.07%

All 7 campaigns and all 7 forecasts read identical API values before and after (sorted diff, ids aside).

Tests

  • test/money-rollup-currency.test.ts: a new block pins the three declarations (returnType: 'percent', percentScaleOf gives whole, expression keeps * 100, percentDisplay plain for the two rates and absent on Attainment %), and holds every percent formula in the app to percentage points.
  • Ablation: with max: 100 removed from ROI %, 2 of 35 go red ("points, not a fraction: expected 'fraction' to be 'whole'", in the pin and the app-wide row); restored, 35 passed.

Acceptance notes

Verification

Files to read first: src/marketing/objects/campaign.object.ts (the two formulas), src/sales/objects/forecast.object.ts (Attainment %), test/money-rollup-currency.test.ts (the new block).

Two-minute check: pnpm exec vitest run test/money-rollup-currency.test.ts reads 35 passed; open a campaign with responses and Response Rate % reads with a %.

Local readings on f661bec
  • pnpm validate "Validation passed", pnpm typecheck, pnpm lint, pnpm hygiene: chain exit 0 (os-verify-lock VERDICT command-exit 0).
  • vitest run money-rollup-currency, docs-locale-callouts, docs-object-coverage, docs-role-hierarchy, docs-setup-navigation-names, skills-integrity, campaign-member-unique, flow-scheduled: 8 files, 181 passed.
  • Earlier on the same source: money-rollup-currency, campaign-member-unique, campaign-member-lifecycle, campaign-enrollment-gates, flow-scheduled, seed-consistency, hooks-runtime-service, psa-objects: 8 files, 347 passed.
  • NOT MEASURED locally: full pnpm test and pnpm build; CI runs them.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xRBcUpajguxop2zMyDN9K

… percentages (#2919)

Declare the campaign's Response Rate % and ROI % and the forecast's
Attainment % as `returnType: 'percent'` with `max: 100`, the way #2910
declared a project's Budget Used % and Gross Margin % (maintainer ruling
B, docs/developers/number-formats.md). The expressions keep `* 100`, so
the API value is unchanged in percentage points; the console now draws
`41.67%` where it drew `41.67`. Response Rate % and ROI % are rates and
draw plain; Attainment % is progress toward the quota and keeps the bar.

The three declarations are pinned in test/money-rollup-currency.test.ts,
with every percent formula in the app held to percentage points. The
forecasting docs say the field reads `0.00%` and that the API reads
`106.00` where the screen shows `106.00%`.

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 2:08am UTC

Request Review

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

Independent read-only review (Fable) · head f661bec · 2026-12-03T01:58Z

  1. 结论:通过(以 CI 8 个 Test shard 全绿为前提)。
  2. 依据:19.0.0-next.3 上 returnType: 'percent' + max: 100 按百分点处理,舍入位数仍为 scale;表达式逐字未改;三字段所有读者行为不变,只是界面多了 %。
  3. 风险:无阻塞。小提示:达成率超 100% 时进度条封顶、文字显示真实值;导出/筛选值不变系读代码推得,未实测。
  4. 类别:审核员类——只改显示,不存数据、接口值不变、不动可见/可改范围;feat: totals of amounts show the tenant currency; Budget Used % and Gross Margin % read as percentages (#2569) #2910 归维护者类是因当时比例尚未裁定,现「2910 选 B」已写入 number-formats.md,本 PR 照章执行。

Evidence: percentScaleOf (spec dist chunk-YAJDVW3H:7382), formulaRoundingScale (objectql dist :17706), max_value check skips computed types (:2379, :2199); readers at forecast.view.ts:39/95/133, forecast.dataset.ts:120; test money-rollup-currency.test.ts:123-148.

Seat: per AGENTS.md ("maintainer until the reviewer says otherwise"), the independent reviewer rules reviewer-class. The seat lands it once every check is finished and green.

Resolve test/money-rollup-currency.test.ts by keeping both appended
blocks: the #2920 approved-discount pin and the #2919 three-formula pin
with its app-wide percent-formula row (approved_discount is a
Field.percent, not a formula, so the row is unaffected).

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

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

L1 review: ACCEPT · reviewer-class (per the independent review above) · seat lands (2026-12-03T02:17Z)

  • 8d5c9c5 merges main (fix(revenue): read a quote's Approved Discount % in percentage points (#2920) #2930) into the branch with no rebase. The one conflict, test/money-rollup-currency.test.ts, keeps both blocks; the app-wide points row still holds because approved_discount is a field, not a formula. Locally 350 tests pass, and validate, typecheck and lint pass.
  • All 19 checks on 8d5c9c5 finished green, and the PR is mergeable. Readying and queueing for merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 3, 2026 02:19
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 191c564 Dec 3, 2026
20 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

2 participants