Skip to content

fix(expense): nobody deletes an approved or paid expense report, administrators included (#2761) - #2793

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-2761-refuse-approved-report-delete
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-2761-refuse-approved-report-delete

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2761

Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — a hook changed (expense_report_rules refuses a person's delete of an approved or paid expense report): administrators (platform_admin, org_owner, org_admin) lose the delete of an approved or paid report, which they had through the repair exemption; every other role already could not delete one and still cannot. Nothing is deleted or renamed; no existing data changes.

维护者速读

  • 用户能看到什么变化:管理员在费用报销里删除「已批准」或「已付款」的报销单时,会看到一条用他自己语言写的提示,说明这张单会保留在记录中,单和费用都不动;删除「已提交」「已驳回」的报销单照旧可以,费用回到草稿。
  • 为什么做:按你在这张卡上「3 选三」的裁定;顺带把常见问题里「没有回收站」那句改成真实情况(平台已经有回收站,删除的记录保留 30 天;管理员以及少数角色可以在各自管理的对象上找回误删的记录)。
  • 出错会怎样:最坏是管理员想清理一张已批准或已付款的报销单时删不掉,数据不会丢;撤回这次合并就恢复原来的行为。
  • 要你做什么:这是你来合并的类别,请审阅后自己合并(它保持草稿)。

What changes

src/expense/objects/expense_report.hook.ts, beforeDelete: before the administrator's repair exemption, a delete by a person of a report that is approved or paid is refused, administrators included, with RECORD_LOCKED / 409 — the code and status this hook already uses to refuse a non-administrator's delete of a sent report. Two new catalogued reasons, delete_approved and delete_paid, each naming the report; their sentences are in the zh-CN, ja-JP and es-ES packs (src/expense/translations/), and English is the declared message.

  • Submitted and rejected reports: unchanged from fix(expense): expenses released by deleting a submitted or rejected report go back to Draft (#2761) #2762. An administrator may delete one, and its expenses go back to Draft.
  • A non-administrator: still refused on every report that is not a draft. On an approved or paid report the sentence is now the new one ("… is approved, so it cannot be deleted: an approved or paid report stays on record.") instead of "… has been submitted."; same code and status.
  • A delete with no person on it (system identity): not judged, as before. Measured, see Acceptance notes.
  • Only this object. The other objects with the same administrator exemption are not changed.

Manuals: the paragraphs #2762 wrote for the approved and paid case are rewritten, in-app (src/expense/docs/crm_expense_recording.md, .zh.md) and on the site (content/docs/(product)/expenses/index.mdx, .zh-Hans.mdx, .zh-Hant.mdx). Only those paragraphs; #2773 edits other paragraphs of the same files.

Rider, docs truth: content/docs/(operate)/reference/faq.mdx (and zh-Hans, zh-Hant) said there is no recycle bin. On the pinned 18.6.0 there is one, measured below, so the answer now says a delete goes to the recycle bin for 30 days by default, that an administrator restores it under Setup → Recycle Bin, and which other roles can restore which objects, measured on 18.6.0 (head 46fd23cb, after the review round): Sales Manager on leads, accounts, contacts, opportunities, quotes, orders, tasks and events; Finance Controller (and Project Director and PMO, which carry it) on rate cards and expense standards; AR Accountant on invoices, payments and expense standards; nobody else, own deletes included. The first version said no other role had the bin; the independent review measured that as false (modifyAllRecords folds into manageRecycleBin). The audit-log sentences are kept.

test/refusal-envelope.test.ts: the hand-maintained refusal count goes from 99 to 101, with the reason in its history comment.

Tests

test/expense-module.test.ts, one new booted case on the shipped app (@objectstack/verify), through DELETE /api/v1/data/crm_expense_report/:id:

  • an administrator deleting an approved report: 409 RECORD_LOCKED, the English sentence naming the report; the report and its expense stay as they were (Approved, on the report);
  • the submitter deleting it: 409 RECORD_LOCKED;
  • an administrator deleting a paid report, and the submitter: 409 RECORD_LOCKED; the report stays Paid, its expense Approved on it;
  • the same administrator delete read in zh-CN (exact sentence), ja-JP and es-ES (each pack's row with the name filled).

The #2762 case beside it (an administrator deletes a submitted and a rejected report, its expenses go back to Draft; the submitter is refused) is unchanged and passes.

Ablation, once: src/expense/objects/expense_report.hook.ts replaced by its origin/main copy (delete_approved count 0 on disk), the new case run alone → red, expected { status: 200, code: undefined } to deeply equal { status: 409, code: 'RECORD_LOCKED' } with the body {"success":true,"recycleBinEntryId":…}. Restored with git checkout HEAD --; blob hash equal to HEAD's, git diff HEAD empty.

Acceptance notes

  • System-identity delete (not ruled). Measured on 18.6.0 with the engine's delete under { isSystem: true } on an approved report: it passes, the report is gone, and its expense reads {"status":"approved","report":null}. That is today's behaviour, kept; the code comment beside the release says so.
  • The PM's "since 18.3" for the recycle bin measured as 18.4.0. @objectstack/objectql's CHANGELOG under 18.3.0 still says "There is no soft-delete or recycle-bin path"; the bin's write side, restore, purge, grants and REST doors are all under 18.4.0. The FAQ says 18.4.0.
  • Recycle bin, measured on the booted app at 18.6.0. A sales rep's DELETE /data/crm_expense/:id of their own draft expense answered 200 with a recycleBinEntryId; the administrator's GET /data/crm_expense/recycle-bin answered 200 with the entry (retentionDays: 30, purgeAfter 30 days on); the rep's list answered 403 PERMISSION_DENIED, and so did the rep's restore of their own entry (a sales rep holds neither allowRestoreOwnDeleted nor manageRecycleBin; the roles above do on their objects, through modifyAllRecords); the administrator's restore answered 200 and the row was back. The Setup navigation entry is nav_recycle_bin, "Recycle Bin" (zh-CN 回收站), in @objectstack/platform-objects 18.6.0. One-off measurement file, not committed.
  • Not changed, outside this card's file surface: content/docs/(operate)/reference/security-and-compliance.mdx (and zh-Hans, zh-Hant), the erasure paragraph, still says there is no recycle bin and links to the FAQ. Reported to the seat, filed as Docs: the right-of-erasure paragraph says a delete is a hard delete with no recycle bin; on 18.6.0 a deleted record stays 30 days in the recycle bin #2794.
  • The UI was not walked in a browser; the refusal was measured at the REST door the record page's delete calls.

Verification

Two-minute check: pnpm exec vitest run test/expense-module.test.ts -t "nobody deletes an approved" → 1 passed. Or in the app as the dev admin: open an approved expense report, ⋯ → Delete → a message that it is approved and stays on record; the report is still there.

Files to read first: src/expense/objects/expense_report.hook.ts (the two new throws at the top of beforeDelete, before the admin exemption), test/expense-module.test.ts (the new case), content/docs/(operate)/reference/faq.mdx (the rewritten answer).

Local runs at 7db3022
  • pnpm validate exit 0 (✓ Validation passed); pnpm typecheck exit 0; pnpm lint (os lint --strict) exit 0, 49 suggestions; pnpm hygiene exit 0 (✓ source hygiene clean).
  • vitest run over test/docs-*, test/i18n-*, test/locale-*, test/refusal-*, test/hook-refusal-catalogue, test/expense*, test/package-ownership, test/org-locale-stored-text: 52 files passed, 1099 tests passed, 9 skipped.
  • The full pnpm test and pnpm build were not run locally; CI runs them.

Generated by Claude Code

…nistrators included (#2761)

The maintainer's ruling on hotcrm#2761 (option 3): an approved or paid
report is refused on delete for every person, with a translated 409
RECORD_LOCKED reason; the administrator's repair stays for submitted and
rejected reports. The manuals say the same, and the FAQ's recycle-bin
answer now matches the pinned platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
@vercel

vercel Bot commented Nov 25, 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 Nov 25, 2026 10:53am 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 Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns

席位核对 — REWORK · repo:hotcrm#2 · head 7db3022d

The independent review ran at head 7db3022d7090a4c95b79e1d2c17cbd48efa01dec as a read-only subagent that took no part in the change. Verdict: REJECT on one must-fix. The hook, refusals, booted tests (with ablation), expense manuals, Metadata-impact: line and CI (20/20 success) all passed.

  • must-fix: content/docs/(operate)/reference/faq.mdx:60 (also .zh-Hans.mdx:60, .zh-Hant.mdx:62) says no permission set but the admin's gives the recycle bin. That is false on 18.6.0.
    • The installed spec folds modifyAllRecords into manageRecycleBin + allowRestoreOwnDeleted (@objectstack/spec dist chunk-534DCYGQ.mjs:94-97).
    • Sales Manager, Finance Controller and AR Accountant hold modifyAllRecords on named objects.
  • nits:
    • zh-Hant emphasis;
    • "keeps a copy" is wider than the engine (multi and permanent deletes skip the bin).
  • Sent back to the dev for a new commit on this branch. The seat re-reviews the delta.
  • Out of scope: goes to follow-up cards (bulk-delete wording; restore after an admin delete).
  • Deviation, noted: commit 7db3022d carries a model-named Co-Authored-By trailer. Rewriting branch history was not permitted from this session, so it is left for the maintainer to judge at merge.

…#2761 review)

The recycle-bin answer said HotCRM's permission sets give nobody but an
administrator the bin. On 18.6.0 modifyAllRecords folds into
manageRecycleBin and allowRestoreOwnDeleted, so a Sales Manager, a Finance
Controller (Project Director, PMO) and an AR Accountant restore on the
objects whose every record they may change; measured on the booted app.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcV3h25dAMNWki8e1ns
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns

维护者速读

  • 改了什么: 报销单「已批准」「已付款」两种状态谁都删不了,管理员也不行,删除时返回 409 RECORD_LOCKED,原因有四种语言。管理员删除「已提交」「已驳回」报销单的修复通道不变,系统身份的删除路径不变,只改这一个对象。手册同步改写;FAQ 的「没有回收站」改成真实情况:删除的记录保留 30 天,并写明哪些角色能在哪些对象上恢复。
    • 角色得失: 管理员失去删除已批准、已付款报销单的能力。其他角色本来就删不了。没有任何角色获得新能力。
  • 为什么、谁提的: 管理员删除已提交的报销单后,单上的费用停在「已提交」但不在任何报销单上 #2761,管理员删掉已批准的报销单后,费用卡在「已批准」、不在任何报销单上。你 2026-11-25 裁定「3 选三」(7157774277)。
  • 最坏情况与撤回: 管理员确实需要删一张已批准或已付款的单时没有通道(「已批准未付款能否撤回」你没有裁)。不改任何数据,revert 即可撤回。
  • 要你做什么: 合并本 PR(maintainer 类,draft 由你合)。独立评审:首轮 REJECT(FAQ 一句不实),修复后复审 ACCEPT,Head-sha 46fd23cb0ab48c6cd48a58d23f3b358bb6b77fd6。
  • 另请知悉: 首个提交 7db3022d 的 trailer 里带了模型名,本会话不允许改写分支历史,所以留着;squash 合并时可以在提交信息里删掉。

席位核对 — ACCEPT · repo:hotcrm#2 · head 46fd23cb

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns

Review requested: the seat record is 7160565756 (ACCEPT at Head-sha 46fd23cb0ab48c6cd48a58d23f3b358bb6b77fd6, carrying the maintainer brief). This PR is maintainer class under hotcrm AGENTS.md 〈Who decides a change〉: admins lose the delete of approved and paid expense reports. It is the maintainer's own merge; the seat leaves it a draft and arms nothing.

@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 Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns

Landing on the maintainer's word. His words in seat 2's session (session_017xRBcV3h25dAMNWki8e1ns, 2026-11-25): 「合并 #2792 和 #2793。」. This is a maintainer-class PR (hotcrm AGENTS.md 〈Who decides a change〉), so his merge decision is what it waited for. The seat flips it ready and arms auto-merge; the merge queue squashes it.

reading value
head 46fd23cb0ab48c6cd48a58d23f3b358bb6b77fd6, the head the seat record 7160565756 accepted
check-runs on head all completed; none failed
governed / size not governed; under 3000 lines

State: pm:awaiting-merge comes off at landing. The card #2761 closes through Fixes #2761 on 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

管理员删除已提交的报销单后,单上的费用停在「已提交」但不在任何报销单上

2 participants