Repository navigation
Conversation
Marking a project task Completed writes 100 into Percent Complete. Moving it back out of Completed left the 100 in place, so a task nobody had started counted as finished and the project's Percent Complete overstated progress. project_task_rules now sets Percent Complete back to 0 when the status leaves Completed, whichever status the task moves to, unless the same save gives a new percentage. A payload that posts the stored 100 back with the new status is not a new percentage. The project roll-up already recomputes on every task write, so the project figure follows. Tests pin the reopen for every target status, the percentage given in the same save, and the moves that must stay untouched. The in-app manual, the product page (en, zh-Hans, zh-Hant) and the field help text state the rule.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
6 tasks done
Collaborator
Author
|
Seat record · 独立评审 · HOLD · head 独立评审(只读子代理,xhigh,未参与改动)结论:通过(有 nit)。Metadata-impact 同意
Findings
已核实:导入为 insert 不受影响,按 id upsert 走同一规则;非已完成状态之间切换不变;项目进度随之重算(测试验证 20/80/50/62);四语齐全,文档与手册均已改;与 #2772 共享两个文件,三方合并无冲突、无行为重叠。 |
…ned-task-percent-30ab3e
- project_task_rules stands down the leaving-Completed reset on a predicate update (ADR-0058 Addendum II D3, as in forecast.hook.ts): one shared payload made the second row read the first row's 0 as given, and the engine refused the batch with MultiUpdateHookKeyDivergenceError. - Only the 100 the hook wrote is taken back: a Completed task stored at another figure (a row from before #2545) keeps it, also when a full form echoes it back. - Docs: the pre-completion estimate is not restored automatically; field history still shows it (was "is not kept").
This was referenced Nov 25, 2026
This branch has not been deployed
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 #2768
The problem
Marking a project task Completed writes 100 into its Percent Complete. Moving the task back out of Completed left that 100 in place, so a task nobody had started counted as finished and the project's Percent Complete overstated progress until someone typed the task's percentage back by hand.
The rule chosen (please overrule it if you disagree)
A task moved out of Completed, to any other status, has its Percent Complete set back to 0, unless the same save gives a new percentage.
{ status: 'in_progress', percent_complete: 70 }keeps 70.percent_completethat differs from the stored one. A form that posts every field back sends the old 100 along with the new status; that is not a new estimate, so it is treated as not given. The one case this cannot express is "reopen and deliberately keep 100", which contradicts the status anyway.multi: true+where) leaves the figure alone (the ADR-0058 Addendum II D3 stand-down, as inforecast.hook.tsandtask.hook.ts). One payload serves every matched row, so a reset decided on one row'sctx.previousmade the next row see it as given, and the engine refused the batch withMultiUpdateHookKeyDivergenceError. Every writer of a task in this app saves by id, where the reset happens.The alternative I did not take: remember the pre-completion percentage and restore it. It needs a new field on
crm_project_task, and the issue asks only that the 100 does not survive.What changed
src/psa/objects/project_task.hook.ts:project_task_rules(beforeUpdate) writes 0 when the status leavescompletedand the save gives no new percentage.project_task_progressis unchanged: it already recomputes the project on every task write, so the project figure follows.src/psa/objects/project_task.object.tsand the four PSA translation files: the Percent Complete help text states both halves of the rule.src/psa/docs/crm_psa_project_plan.mdand.zh.md, and the product pagecontent/docs/(product)/projects/project-planin en, zh-Hans and zh-Hant..changeset/2768-reopened-task-percent.md(patch).Tests
test/psa-project-tasks.test.tsgains a block on a booted stack with a two-task project (40 h at 50 % and 60 h at 0 %, project 20 %). Before the fix, three of its cases failed withexpected 100 to be 0.MultiUpdateHookKeyDivergenceError.Checks
pnpm verify(validate, typecheck, lint --strict, hygiene, build, test): green. 332 test files, 6382 tests passed, 58 skipped.1d4d8f94, on top oforigin/mainmerged inecaf7f6d): validate, typecheck, lint --strict, hygiene and build green. The test stage ran twice on a machine at load average 64–117; each run had onlyTest timed out in 5000msfailures, 6 and 8 tests, in different files outside PSA (campaign, forecast, flow-scheduled, clone, price book, PSA approvals). No assertion failed. Every one of those files passes when rerun alone (7 files, 214 tests, withtest/psa-project-tasks.test.ts, 25 tests). CI is the clean run.{"status":"not_started"}).percent_complete: 40in the same request: task 40 %, project 45.4 %.Metadata-impact: maintainer — a hook changed (
project_task_rulesnow writes Percent Complete 0 when a task leaves Completed)