Skip to content

feat(psa): Prepare Billing puts a project's approved billable time and expenses on a payment plan (#2621) - #2926

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-2621-plan-step-project
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-2621-plan-step-project

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2621

Round 3 (43c63e3): an unexpected error is no longer re-labelled 409 CONFLICT, and it leaves as thrown after the rollback. The docs name the 30-second run limit. The plan notes that a driver without transactions is not atomic. Round 2 (d7ca739, after the independent review 7342846946). Where this note and the text below disagree, this note wins.

  • Atomicity. Prepare Billing runs as one ctx.api.transaction (capability api.transaction, available on 19.0.0-next.3). The read of unbilled rows, the plan-step insert and every Billed On stamp happen inside it. The hand-written take-back is gone. A failure, including the platform's wall-clock cut, leaves no step and no stamp.
  • Concurrency. Stamps are a predicate-path compare-and-set (where: { id: {$in}, crm_billing_milestone: null }, batches of 200). Before commit, the stamped rows are counted against the rows summed; a short count throws CONFLICT and rolls back.
  • Tests. test/psa-prepare-billing.test.ts has 17 cases (adds director/PMO/admin positives, forced failure, two-at-once, and a deterministic interleave). test/psa-prepare-billing-timeout.test.ts has 1 case (1.5 s wall ceiling, zero residue). Ablations: removing the transaction fails 3 cases; removing the compare-and-set or the count check fails the interleave case.
  • Member 404. This is the measured /meta withholding (objectstack action-run-visibility.ts, ADR-0106 D1 there). The earlier "member reads no plan step" claim is dropped.
  • crm_project declares actionLayout.record pinned ['prepare_billing'] (HotCRM:商机等手写记录页回到平台默认页结构;审批提示文案改正;为主从明细对象打开一起保存 #2720 landed meanwhile). The docs' failure sentences now say all-or-nothing.
  • Round 4 (af9824a), the maintainer's ruling 「B 选 B1,C 接受」. B1: crm_billing_milestone gains Order to Cash's own read-only Created From (origin: manual / order_confirmation / billing). The confirmation flow writes order_confirmation and Prepare Billing writes billing. sales_order_amount_plan_step leaves a lone billing step alone when the order's total changes. Order to Cash reads no PSA field. Pinned: the reviewer's 10,000→12,000 case keeps the 300 step at 300, and a sole hand-typed step still follows (12,000). Ablation: dropping the skip turns the 300 into 12,000. C: accepted. The docs (3 locales), the PSA manual and the O2C manual say billing steps sit beside an order's automatic full-amount step, so the order shows Payment Plan Differs, revisited before Project Delivery phase 3, step 3b: billed and not yet billed on the project, in the project financials and on the dashboard; manual and docs #2622.

Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — permission set: project_member gains two readable: false field rows (Billed On on crm_time_entry and on crm_expense); also a hook changed (time_entry_costing lets the billed-on stamp through the timesheet lock); a field on an existing Order to Cash object (crm_billing_milestone.origin) and a flow condition change (sales_order_amount_plan_step), per the ruling 「B 选 B1,C 接受」

维护者速读

  • 用户能看到什么变化:项目经理、项目总监、PMO 和管理员在项目页面上点"准备开票",选一个截止日期,项目里已批准、可计费、还没开过票的工时和费用就合成一条新的回款计划,挂在项目的订单(没有订单就挂合同)下;团队成员看不到这个按钮。
  • 为什么做:这是项目交付第三阶段的第一步(你 11 月 17 日定的"依赖订单与回款"),让项目能记下哪些工时和费用已经开过票;下一步(在项目上显示已开票和未开票)等这张合并后再做。
  • 出错会怎样:最坏是某次开票金额不对或漏标,管理员删掉那条回款计划,工时和费用就恢复成未开票,可以重新运行;整体改动可以直接撤回,已有数据不受影响。
  • 要你做什么:这张改了权限集(对团队成员隐藏"开票于"字段),按规定要你审核合并,PR 保持草稿。

What changes

  • The edge. app.objectstack.hotcrm.psa declares app.objectstack.hotcrm.o2c (module-split-plan.md, new Decisions recorded (2026-11-17), item 21 — the card asked for item 20, which the 2026-11-16 re-measure already holds, so it is 21). Registration order was already right (o2cStack before psaStack). Pins updated, each with a sentence: test/psa-module-package.test.ts, test/expense-module.test.ts (two), test/package-ownership.test.ts.
  • Fields. crm_billing_milestone.crm_project (optional lookup, contributed by PSA, related list on the project page; no column in any view). crm_time_entry.crm_billing_milestone (PSA's own, readonly, indexed) and crm_expense.crm_billing_milestone (contributed, readonly, merged into PSA's one crm_expense extension entry: os validate refuses a second entry for the same object).
  • Prepare Billing (src/psa/actions/billing.actions.ts), a script action on crm_project, one param (Bill Up To). It takes billable entries on the project's approved timesheets and the project's approved billable expenses, dated up to the date and on no step yet; inserts one step under the order, else the contract (name = project number + date range, planned amount = total at bill rates, planned date = run day); stamps each row. Refusals are a declared catalogue in four locales: FORBIDDEN, RECORD_NOT_FOUND, VALIDATION_FAILED (no_date, non_billable, no_source, o2c_off, nothing_to_bill), CONFLICT.
    • Who: the project's own Project Manager, positions crm_project_director and crm_pmo (they hold project_manager + finance_controller), and platform_admin / org_owner / org_admin. ⛔ Never a project member.
    • Order to Cash disabled: the button is hidden (current_user.can("crm_billing_milestone", "read") reads false: /auth/me/permissions leaves the module's objects out, measured), and the body refuses before any write. The body's signal: the platform withholds a disabled module's contributed fields from every read, the body's in-process read included (measured on 19.0.0-next.3: with O2C off the order's and contract's planned_amount key is absent; on, present). objectstack#34900 closed as "served", so the body has to check.
    • One transaction: the reads of unbilled rows, the step insert and every Billed On stamp run in one ctx.api.transaction (capability api.transaction, in the pin). A failure or the sandbox's wall-clock cut rolls all of it back: no step, no stamp. Stamps are a predicate-path compare-and-set (where: { id: {$in}, crm_billing_milestone: null }, multi: true, batches of 200), and the rows on the step are counted before commit. A short count is the action's own 409 CONFLICT. Any other error leaves as thrown (a hook's throw is the platform's 400 HOOK_ABORTED, a timeout its 500), never re-labelled as CONFLICT.
  • Timesheet lock (time_entry_costing): an update whose only change, besides the engine's updated_at / updated_by, is crm_billing_milestone is let through. A person's own write of the field never reaches the hook as a stamp: the platform withholds a person's value for a readonly field from beforeUpdate and drops it (measured: the lock still answers 409 on an approved timesheet; on a draft the value is dropped).
  • Permissions. project_member hides both Billed On fields. No grant on plan steps for any project set. Measured: /meta/action does not serve the action to a member, and the platform answers a run of an action it does not show a caller as an unknown name, so the door answers 404, not 403 (objectstack packages/runtime/src/action-run-visibility.ts, the rule it cites as ADR-0106 D1). Which reference the member's projection drops is the platform's to decide and is not pinned.
    • The two grant choices the probe named are for summaries; 3a adds none, so neither is made here. Stated for 3b: ar_accountant reading time entries for a step's labor figure; project_member hidden from the project's billed figure, as the cost block is.
  • Deleting a billed step. objectstack#34899's fix is in the pin: an administrator's delete clears the rows' Billed On (pinned), so no Undo Billing was built. The engine clears them as the person deleting, so a sales manager (who deletes an ordinary step) gets 403 on a step that billed time, and nothing changes (pinned).
  • Where the merged code differs from the card. Since the 2026-11-26 ruling (hotcrm#2806) an invoice hangs on no plan step: finance records the payment against the billing step and the invoice against the order or contract. The test pins the payment.
  • Docs. Docs site projects/time-and-expenses (en, zh-Hans, zh-Hant), section Billing the time and expenses; in-app manual crm_psa_projects_cost (en + zh); module-split-plan.md item 21; dated notes in psa-module-plan.md, order-to-cash-module-plan.md, REQ-0002, REQ-0007; counts (STATUS, both READMEs: 57 actions; STATUS 643 fields since origin).

Tests

Business facts, `test/psa-prepare-billing.test.ts` (through `@objectstack/verify`)

Twenty cases on the shipped app, at af9824a (19 in test/psa-prepare-billing.test.ts, 1 in test/psa-prepare-billing-timeout.test.ts; the two added in round 4 are the B1 case and its control): one step under the order with the right total (8 h + 4 h at 150 plus one approved billable expense = 2,030.50), unbillable / draft-timesheet / unapproved / later rows left alone, the stamp through the approved timesheet's lock, and a payment recorded against the step by an AR accountant (Received = 2,030.50); a second run takes only what is new and a third refuses nothing_to_bill with no step; contract fallback, and no_source refusal with nothing written; Non-billable refused; a member not shown the action (/meta/action) and answered 404, and not reading Billed On (manager control reads it); a finance controller refused 403 FORBIDDEN before any write; a project manager's direct POST and PATCH on a plan step answer 403; a person's write of Billed On refused by the lock (409) on an approved timesheet and dropped on a draft; a forced failure on the last stamp (an engine hook refuses it) answers the platform's 400 HOOK_ABORTED and leaves no step and no stamp, and the retry bills each row once (700); two runs at once give exactly one 900 step and refuse the other; a row billed by another write inside the run's unit makes the stamps fall short, so the run answers 409 CONFLICT and rolls back, the other write included; a project director, the PMO and an administrator each run it (300); a run cut off at a 1.5 s wall ceiling with 120 rows (an engine hook holds each stamp 50 ms) answers 500, leaves no step and no stamp (re-checked 7 s later), and a run up to an earlier date then bills its 20 rows once; an administrator's delete clears the stamps and the next run bills again; a sales manager's delete of a billing step answers 403 with step and stamp intact; Order to Cash disabled: /auth/me/permissions drops the step (the button's gate), the run refuses o2c_off, nothing stamped, the project opens, and on enable the step's Project and the stamps are back.

pnpm exec vitest run --maxWorkers=2 test/psa-prepare-billing.test.ts …(11 files)
 Test Files  11 passed (11)
      Tests  242 passed (242)

Other local batches at the same tree: script-bodies (new crm_project:prepare_billing invocation), authorization-coverage, permission-set-descriptions, o2c-module-package, module-disabled-actions, psa-objects, psa-weekly-time, record-tab-order: 8 files, 151 passed, 1 skipped. Every docs-* / i18n-* file: 39 files, 796 passed, 9 skipped. psa approvals / budget / tasks / members, project-, o2c-, hooks-runtime-o2c, expense report / request / submit / standard: 25 files, 398 passed, 1 skipped.

Ablation

Each guard removed on disk, the suite run, the file restored by an EXIT trap (restore confirmed by grep):

  • time_entry_costing's billed-on exemption removed → 9 failed | 3 passed (every run hits 409 RECORD_LOCKED).
  • the Order to Cash check removed → the disabled case fails: {"success":true,…} expected [400, 'VALIDATION_FAILED'] (a step was written into the disabled module).
  • the transaction removed (the callback run bare, at d7ca739) → 3 failed: the wall-clock case, the forced failure, and two-at-once.
  • compare-and-set and the count check removed, or the count check alone → the interleave case fails (200 with 450 instead of 409 CONFLICT). On the SQLite test boot the transaction serializes two runs, so two-at-once stays green without these two guards; the interleave case is their discriminator.

Acceptance notes

  • Not measured here (CI or the seat's browser pass): the browser pass in en and zh-CN as project manager, finance and member; the 6.5.0 upgrade reading (the probe measured it on 18.5.0); every list and page opening with each module disabled.
  • A step Prepare Billing adds under an order makes the order's plan total differ from its Total Price, so the order shows Payment Plan Differs. Ruled C (accepted for 3a): documented in the three locales and both manuals, and revisited before Project Delivery phase 3, step 3b: billed and not yet billed on the project, in the project financials and on the dashboard; manual and docs #2622.
  • A billed timesheet that is later sent back to Draft and edited changes hours that were already billed; the stamp stays on the entry. Not handled here.
  • ar_accountant reads plan steps but not projects, so a billing step's Project shows as a restricted record to them.
  • Deleting a billing step as a sales manager answers the generic "You do not have access to this record" (the set-null walk runs as the caller).

Verification

Local, at af9824a's tree (exit captured before any pipe): pnpm validate 0 (38 Objects, 643 Fields, 57 Actions), pnpm typecheck 0, pnpm lint (os lint --strict) 0, pnpm hygiene 0; pnpm build 0 was last read at cb2e2eb. NOT MEASURED locally: the full pnpm test (369 files; a 60-file batch outran the container's time limit), so CI's run is the full reading.

Two-minute check: pnpm exec vitest run --maxWorkers=2 test/psa-prepare-billing.test.ts test/psa-prepare-billing-timeout.test.ts — 20 tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xRBcUpajguxop2zMyDN9K

…d expenses on a payment plan (#2621)

Project Delivery phase 3 step 3a. Project Delivery now depends on Order to
Cash (module-split-plan item 21). A plan step names its project (a field
Project Delivery contributes to crm_billing_milestone, with the project
page's list of steps); a time entry and an expense name the step they were
billed on (Billed On, read-only, stamped only by the action). Prepare
Billing, a script action on the project for its project manager, the
director and PMO positions and administrators, takes the billable hours on
approved timesheets and the approved billable expenses up to a date onto
one new step under the project's order, or its contract; it refuses with a
sentence on a Non-billable project, with no order or contract, with nothing
to bill, and while Order to Cash is disabled, before writing anything. A run
that fails midway takes its writes back. time_entry_costing lets through an
update that changes only Billed On. project_member hides Billed On.

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

vercel Bot commented Dec 2, 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 2, 2026 11:44am UTC

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd CI plumbing and the verification pipeline metadata Declarative metadata — schema, security posture, UI surfaces backend Server-side behaviour — hooks, flows, actions labels Dec 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

席位核对 · independent review · head cb2e2ebe78 · 不通过,退回修改 · 2026-12-02T10:41Z

独立审阅结论(只读,隔离运行;依据 AGENTS.md「Who decides a change」):

  • 改什么:PSA 新增对 O2C 的依赖。回款计划多一个「项目」字段;工时和费用各多一个只读的「开票于」字段。项目上新增「准备开票」动作。工时单锁放行「只改开票于」的更新。project_member 看不到「开票于」。
  • 为什么、谁要的:维护者 2026-11-17 派单「项目交付第三阶段」,并在决策卡上选了依赖 O2C。本 PR 申报 Metadata-impact: maintainer,申报正确,保持草稿。
  • 最坏情况、能否撤回:回款计划金额在三种情况下会静默算错(见阻断 1–3)。管理员删除回款计划即可恢复,代码可以整体回退。但并发重复开票时,如果删错一条,已开票的工时会被再开一次。
  • 没验证的:浏览器走查、6.5.0 升级读数、模块停用时各页面、真实数据库上的每行耗时。

权限与依赖:没有问题。 能运行「准备开票」的只有本项目的项目经理、总监和 PMO 岗位、三种管理员身份,没有超出卡片。PSA→O2C 依赖与拆分计划第 21 条的裁决一致。工时单锁的放行没有找到可被人利用的路径。

阻断(席位已退回 dev 修复):

  1. 运行超时(平台 30 秒墙钟)会留下半截数据,重试会重复开票。实测(1.5 秒时限、120 条工时):返回 500,留下一条全额 18,000 的回款计划,只标了 42 行;重试又生成一条 11,700。这违反卡片的硬要求「失败不留痕、重试不重复」。
  2. 卡片说「没有事务」,这是在 18.5.0 上测的,钉住的 19.0.0-next.3 已提供 ctx.api.transaction。审阅者实测:用平台事务替换手写撤回后,PR 的 12 个测试全部通过,超时场景下零残留。
  3. 两次同时运行会重复开票。实测:6 条各 150 的工时,两个请求并发都返回 200,生成 900 和 450 两条回款计划。
  4. 订单只有一条回款计划且它是开票生成的时,改订单总价会把这条覆盖成订单总价(Invoices and payments run in parallel: unlink them, show Unpaid and Uninvoiced instead of Receivable Balance, measure overdue on the payment plan, and generate a plan step when an order is confirmed #2806 的流程)。实测:300 被改成 12,000。

不阻断(一并修): src/psa/index.ts:132 的注释过时;psa-module-plan.md:380-384 过时;ADR 出处写错;撤回失败时提示有误;缺少总监、PMO、管理员能运行的正向测试,以及并发、超时的测试;三种语言的手册里「失败会撤回」的表述要按修复后的实际行为改写。

需维护者裁决:

  • B. 订单总价变动时,自动改写「唯一一条回款计划」的流程,要不要避开开票生成的那条? 审阅者建议避开:开票回款计划的金额是从工时算出来的,被订单总价覆盖后,就与已标记的行对不上。做法有三种:
    • B1:在回款计划上加一个 O2C 自己的「来源」标记,流程跳过开票来源的那条。多一个字段,依赖方向不变。推荐。
    • B2:让 O2C 的流程读 PSA 贡献的「项目」字段。会形成反向的隐性依赖,不推荐。
    • B3:接受现状,写进手册。用户得自己发现金额被改。
  • C. 按工时开票的订单,确认时自动生成的「全额回款计划」和之后的开票回款计划并存,接受吗? 审阅者建议 3a 先接受并写进用户文档,在 3b 之前定规则。代价是订单的计划金额会重复计数,并显示「回款计划不一致」。另一种做法是让按工时计费的订单不自动生成回款计划,这要改 O2C 的确认流程并重新裁决。

Generated by Claude Code

…e under concurrent runs (#2621)

The independent review of #2926 measured three ways a run left a wrong
step: a run cut off by the sandbox's wall clock left a full step with part
of its rows stamped, and its retry billed the rest again; the hand-written
take-back could not cover that; and two runs at once both billed the same
rows. The pinned 19.0.0-next.3 gives a script body ctx.api.transaction.

- The reads of unbilled rows, the step and every Billed On stamp now run in
  one platform transaction (capability api.transaction); the take-back is
  gone. A forced failure and a wall-clock cut-off each leave no step and no
  stamp, and the retry bills each row once.
- Stamps go through the engine's predicate path (multi), so a stamp lands
  only on a row still unbilled, and the rows on the step are counted before
  the commit: a short count refuses (CONFLICT) and rolls the run back.
- Tests: two runs at once give one 900 step; a row billed by another write
  inside the run's unit refuses and rolls back; a run cut off at a 1.5 s
  ceiling with 120 rows leaves nothing; a project director, the PMO and an
  administrator each run it.
- crm_project declares actionLayout.record pinned prepare_billing (#2720,
  merged from main); stale comments, the plan's phase-3 text, the ADR
  citation on the member's 404, and the docs' failure sentences in three
  locales and both manuals are rewritten.

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

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

link-check red on d7ca739aaa · not this PR's · 2026-12-02T11:05Z

The run checked links in README.md and README.zh-CN.md, which this PR changes only to bump counts. Every failing link is a github.com/objectstack-ai/hotcrm/blob/main/… URL (README.zh-CN.md, CONTRIBUTING.md, LICENSE, README.md), and each answered HTTP 503, a GitHub-side outage at run time. All of those files exist on main. The seat re-runs the failed job once.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

席位核对 · independent re-review · head d7ca739aaa · 阻断 1–3 已修复 · 2026-12-02T11:17Z

复审结论(只读、隔离):

  • 改什么:「准备开票」整次运行放进一个平台事务,手写撤回已删除。打标改为带条件的批量更新:只标「开票于」仍为空的行,每批 200 行。提交前核对已标行数,不符就拒绝并回滚。权限没有再变化。
  • 为什么、谁要的:第一轮审阅(7342846946)退回了阻断 1–3。卡片是维护者 2026-11-17 派的。
  • 最坏情况、能否撤回:单次运行不再留下半截数据,也不再重复开票。剩下两种最坏情况:
    • 未开票工时单约 1,100 张时,运行会触到 30 秒上限而开不出票。这种情况零残留,选更早的截止日期即可分批开。
    • 阻断 4 仍在,等维护者裁决 B。
  • 没验证的:真实 PostgreSQL 上的并发(只读了代码;READ COMMITTED 下行锁等待,重新判定后命中 0 行,核对不符即回滚);不支持事务的驱动;浏览器走查;6.5.0 升级读数。

复审实测:

  • 18 个测试全部通过。
  • 消融:去掉事务,3 个失败;去掉条件更新或核对,交错用例失败;三者全去掉,「两次同时点击」重现两条 900。
  • 自己的探针:450 行和 1,000 行跨批,金额正确,每行只标一次;偷走一行返回 409,零残留;三个请求并发,总额不超过 900。
  • CI:21/21 通过。link-check 第一次失败是 GitHub 503,重跑后通过。

不阻断(席位交 dev 修第 1、2 条):

  1. 文档没有写大项目超时后怎么办。
  2. 未声明的错误一律包装成 409「请再试一次」,会掩盖确定性错误(例如来源订单没有客户)。回滚已由事务保证,这一层包装没有必要。
  3. SQLite 上长时间运行会占住唯一的数据库连接。
  4. 不支持事务的驱动上会静默失去原子性,应在 psa-module-plan.md 记一句。
  5. PR 正文的旧段落需要清理。

仍需维护者裁决 B、C(见 7342846946):

  • B:订单总价变动时,改写唯一回款计划的流程要不要跳过开票生成的那条。推荐 B1:给回款计划加一个 O2C 自己的「来源」标记。
  • C:自动生成的全额回款计划与开票回款计划并存。推荐 3a 先接受,写进用户文档。

维护者类改动:PR 保持草稿,等维护者裁决并合并。


Generated by Claude Code

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Dec 2, 2026
…cs name the run limit (#2621)

- The transaction already rolls a failed run back, so the body no longer
  wraps every undeclared error as 409 CONFLICT "try again". A refusal of
  its own (nothing to bill, the short count) keeps its code; any other
  error leaves as thrown: a hook's plain throw is the platform's 400
  HOOK_ABORTED, a timeout its 500. The forced-failure test pins the new
  answer and keeps its zero-residue assertions.
- The docs site (three locales) and the in-app manual (en, zh) say that a
  very large backlog can reach the 30-second run limit, leaving nothing
  behind, and that an earlier Bill Up To date bills it in parts.
- psa-module-plan.md: on a driver without transactions the run is not
  atomic; HotCRM's shipped SQL drivers both support transactions.

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

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

Ruling recorded · 2026-12-02T11:26Z

The maintainer, in chat: 「2926 B 选 B1,C 接受」. This settles questions B and C in 7342846946.

  • B → B1. The billing milestone gets an O2C-owned source marker. Prepare Billing sets it on the steps it creates. O2C's order-amount flow (sales-order-amount-plan-step.flow.ts) skips any step whose source is billing, so a billing step is never overwritten with the order's total. The dependency direction stays PSA → O2C. The dev adds this in this PR, with a test that reproduces the 300 → 12,000 overwrite and pins it fixed.
  • C → accept. For 3a, the auto-generated full-amount step on order confirmation and the billing steps live side by side, and the order shows "Payment Plan Differs". The user docs say so in three locales and the in-app manual. The rule is revisited before 3b (Project Delivery phase 3, step 3b: billed and not yet billed on the project, in the project financials and on the dashboard; manual and docs #2622).

The PR stays a draft (maintainer class). After the push and a green CI, the seat posts the head update for the maintainer's merge.


Generated by Claude Code

…p keeps its amount when the order's total changes (#2621)

The maintainer's ruling on PR #2926: 「B 选 B1,C 接受」.

B1. crm_billing_milestone gains Order to Cash's own Created From (origin:
manual, order_confirmation, billing), read-only to people; rows from before
it read empty and count as manual. The confirmation flow writes
order_confirmation, Prepare Billing writes billing, and
sales_order_amount_plan_step no longer moves a lone billing step to the
order's new total. Order to Cash reads only its own field; the dependency
stays PSA to Order to Cash. Labels in the four O2C packs.

Tests: an order written as Confirmed (no generated step), a 300 billing
step, the total from 10,000 to 12,000: the step stays 300 and the order
shows Payment Plan Differs. Control: a sole step typed by hand still
follows the total (12,000), and a generated step reads order_confirmation.

C. The docs site (three locales), the Project Delivery manual (en, zh) and
the Order to Cash manual (en, zh) say that billing steps sit beside an
order's automatic full-amount step, so the order shows Payment Plan Differs,
and that the rule is revisited before step 3b. Plan notes, changeset and the
field count follow; origin/main merged.

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

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

link-check on head af9824a failed with GitHub returning 503 for github.com/objectstack-ai/hotcrm/blob/main/{README,CONTRIBUTING,LICENSE} — a transient GitHub outage, not a dead link from this PR's docs. Re-running the job once. (2026-12-02T11:47Z)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

Head update — af9824a, rulings implemented, CI all green (2026-12-02T11:54Z)

  • B → B1: billing_milestone.origin (readonly select: manual default / order_confirmation / billing). Prepare Billing stamps origin = billing; the amount-plan flow (edges e6/e7) treats a lone billing-origin step as not the order's own plan.
  • Concurrency (re-review finding): Prepare Billing now runs in one transaction, stamping with a compare-and-set (crm_billing_milestone = null, batches of 200) plus a count check → CONFLICT, so two concurrent runs cannot double-bill.
  • C: accepted as proposed.
  • Independent read-only review of the B1 diff: matches the ruling.
  • CI: every check finished and green (link-check passed on re-run after two GitHub 503s).

Stays draft with pm:awaiting-merge — the maintainer's merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side behaviour — hooks, flows, actions ci/cd CI plumbing and the verification pipeline documentation Improvements or additions to documentation metadata Declarative metadata — schema, security posture, UI surfaces pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue

Projects

None yet

2 participants