Repository navigation
fix(expense): nobody deletes an approved or paid expense report, administrators included (#2761) - #2793
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns 席位核对 — REWORK · repo:hotcrm#2 · head
|
…#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
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns 维护者速读
席位核对 — ACCEPT · repo:hotcrm#2 · head
|
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns Review requested: the seat record is 7160565756 (ACCEPT at Head-sha |
|
repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns Landing on the maintainer's word. His words in seat 2's session (
State: |
Fixes #2761
Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — a hook changed (
expense_report_rulesrefuses 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.维护者速读
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 isapprovedorpaidis refused, administrators included, withRECORD_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_approvedanddelete_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.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 (head46fd23cb, 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 (modifyAllRecordsfolds intomanageRecycleBin). 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), throughDELETE /api/v1/data/crm_expense_report/:id:RECORD_LOCKED, the English sentence naming the report; the report and its expense stay as they were (Approved, on the report);RECORD_LOCKED;RECORD_LOCKED; the report stays Paid, its expense Approved on it;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.tsreplaced by itsorigin/maincopy (delete_approvedcount 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 withgit checkout HEAD --; blob hash equal to HEAD's,git diff HEADempty.Acceptance notes
deleteunder{ 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.@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.DELETE /data/crm_expense/:idof their own draft expense answered 200 with arecycleBinEntryId; the administrator'sGET /data/crm_expense/recycle-binanswered 200 with the entry (retentionDays: 30,purgeAfter30 days on); the rep's list answered 403PERMISSION_DENIED, and so did the rep's restore of their own entry (a sales rep holds neitherallowRestoreOwnDeletednormanageRecycleBin; the roles above do on their objects, throughmodifyAllRecords); the administrator's restore answered 200 and the row was back. The Setup navigation entry isnav_recycle_bin, "Recycle Bin" (zh-CN 回收站), in@objectstack/platform-objects18.6.0. One-off measurement file, not committed.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.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 ofbeforeDelete, 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 validateexit 0 (✓ Validation passed);pnpm typecheckexit 0;pnpm lint(os lint --strict) exit 0, 49 suggestions;pnpm hygieneexit 0 (✓ source hygiene clean).vitest runovertest/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.pnpm testandpnpm buildwere not run locally; CI runs them.Generated by Claude Code