Repository navigation
fix(expense): Mark as Paid refuses in the caller's language (#2763) - #2765
Merged
Merged
Conversation
mark_expense_report_paid threw four English literals, so a zh-CN, ja-JP or es-ES user read the refusal in English. The action now declares a refusals catalogue (FORBIDDEN 403, VALIDATION_FAILED 400, RECORD_NOT_FOUND 404, CONFLICT 409 with the report name as a declared param) and the script body throws by code. The English wording and each status are unchanged; the three locale packs carry the sentences. Every throw the body can reach carries a declared code. A missing or invisible record and a bad payment_date are answered by the platform before the body runs, so the body's RECORD_NOT_FOUND is only read when the report is deleted between the platform's load and the body's read; the booted test stages that on the real engine. Fixes #2763
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Collaborator
Author
|
Seat record · 独立评审 · head 独立评审(只读子代理,未参与改动)结论:通过(有 nit)。Metadata-impact 同意
Findings
|
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.
Description
Mark as Paid on an expense report (
crm_expense_report.mark_expense_report_paid) refused with four English literals thrown from the script body, so a zh-CN, ja-JP or es-ES user read the reason in English. The action now declares arefusalscatalogue and the body throws by code; the three locale packs carry the sentences.Fixes #2763
Metadata-impact: reviewer
Type of Change
Changes Made
src/expense/actions/expense.actions.ts—MarkExpenseReportPaidActiondeclaresrefusals, one code per sentence, English wording and status unchanged:FORBIDDENVALIDATION_FAILEDRECORD_NOT_FOUNDCONFLICT{{name}}is not approved. (params: ['name'])The body throws
Object.assign(new Error('<log text>'), { code, params? }); thefailhelper is gone.SUBMIT_FOR_REIMBURSEMENT_SOURCEand the two submit actions are not touched (zh-CN:「提交报销」「按出差申请报销」的拒绝原因是英文 #2759 stays blocked on refusals: one throw answers one declared sentence — an action that refuses a selection for several reasons at once cannot list them in the person's language (after #34273) objectstack#36877).src/expense/translations/{zh-CN,ja-JP,es-ES}.ts— four rows each underobjects.crm_expense_report._actions.mark_expense_report_paid.refusals.<CODE>.message. zh-CN follows the vocabulary ofsrc/expense/docs/crm_expense_recording.zh.md(报销单、已批准、财务).en.tscarries no such keys and is unchanged.test/expense-report-paid-refusals.test.ts— booted stack, 11 cases..changeset/2763-mark-as-paid-refusals-localised.md(patch).No user doc quotes any of the four sentences, so no doc changed.
Every throw the body can reach
Once a catalogue exists, an undeclared throw answers 500, so each path was checked on
@objectstack/*18.6.0:throwstatements in the body each carry a declared code (the test counts them: fourthrow, four declared codes).recordIdnaming no report, or one the caller cannot see, is answered by the platform before the body runs (its own 404RECORD_NOT_FOUND, already localised). A missing or malformedpayment_dateis answered by the param contract before the body (400VALIDATION_ERROR).RECORD_NOT_FOUND("This expense report no longer exists.") is read only when the report is deleted between the platform's load and the body's read. The test stages exactly that on the real engine: a spy holds the body's read (the one asking forid, name, status) until a real system delete of the row has finished; both locales answer 404 with the action's sentence.Measurements
POST /api/v1/actions/crm_expense_report/mark_expense_report_paidon the booted stack.Before (unchanged action) — the same English for
accept-language: enandzh-CN:FORBIDDEN"Only finance marks an expense report as paid, once it is approved."recordIdVALIDATION_FAILED"Open the expense report to mark it as paid."CONFLICT"Only an approved expense report is marked as paid. Expense report 2026-11-02 is not approved."After — same status and code in each case;
error.messageanderror.userMessagecarry the pack's sentence for zh-CN, ja-JP and es-ES and the unchanged English for en. For zh-CN:recordIdThe success path still answers 200 and a second mark on a paid report answers the same 409 without touching the row.
Testing
Run locally on this branch:
pnpm validate— exit 0 ("Validation passed")pnpm typecheck— exit 0pnpm lint— exit 0 (49 suggestions, informational; none about this action)pnpm hygiene— exit 0pnpm vitest runon 13 files (expense-report-paid-refusals,expense-module,expense-report-request,expense-skills,script-bodies,psa-approvals,hook-refusal-catalogue,refusal-envelope,refusal-labels,i18n-package-ownership,i18n-references,i18n-shared-widget-parity,locale-label-collisions) — 13 files passed, 277 tests passed.src/changes reverted, the new suite fails 9 of 11. The two that stay green are the platform's own 404 and the English race case, both true before the change.Not run / not verified:
pnpm verify(build plus the whole suite) was not run locally; CI runs it.sys_emailfrom another suite. The new file run alone prints none. Observed, not investigated.Checklist
src/declare their class (Metadata-impact: reviewerabove — text and translations of one action; who may mark a report as paid, and when, is unchanged)Additional Notes
Noticed, not touched:
test/hook-refusal-catalogue.test.tsPACKAGESdoes not listexpense.