修复报销金额阻断文案门禁(08-30-b2-submit-error-ocr-fallback)

这个提交包含在:
2026-08-31 23:22:41 +08:00
父节点 f39b43cce3
当前提交 fddf3a3bc7
共修改 7 个文件,包含 29 行新增和 12 行删除
@@ -104,6 +104,7 @@ and verification contracts. Do not copy broad aesthetic guidance from
Rewriting Host to `127.0.0.1:3000` makes full-page reloads lose the session
with `AUTH_005`.
- Run `cd client && npm run typecheck && npm run build` for frontend changes.
- Any task that changes user-visible frontend copy must also run `node scripts/qa/check-ui-design-rules.mjs --strict` before commit and again before deployment. Treat the public bundle copy scan as a post-deploy witness, not the first place to discover forbidden user-facing terms. For reimbursement/invoice flows, regression assertions cover all four internal terms: `绑定整单`, `不绑定明细`, `发票池`, and `OCR`.
## Scenario: Playwright API Mocks Against A Production PWA Build
+1
查看文件
@@ -45,6 +45,7 @@ const PAGE_TITLES: Array<{ path: string; title: string; group: string }> = [
{ path: "/mobile/purchase-requests", title: "移动采购", group: "移动工作台" },
{ path: "/mobile/reimbursements", title: "移动报销", group: "移动工作台" },
{ path: "/mobile", title: "移动首页", group: "移动工作台" },
{ path: "/system/settings", title: "管理", group: "管理" },
{ path: "/settings/profile", title: "个人设置", group: "账号设置" },
{ path: "/dashboard", title: "数据看板", group: "更多" },
];
@@ -1158,7 +1158,7 @@ export function MobileReimbursementDetailPage() {
/>
</label>
{shouldShowOfficeElectronicsHint(
expenseTypes.find((type) => type.id === itemForm.expenseTypeId)?.code,
expenseTypes.find((type) => type.id === itemForm.expenseTypeId),
itemForm.amount,
) ? (
<p className="col-span-2 text-xs text-amber-600">该金额通常应选择办公电子设备。</p>
@@ -1199,7 +1199,7 @@ export function MobileReimbursementDetailPage() {
<div className="shrink-0 text-base font-semibold text-zinc-900">{formatMoney(item.amount)}</div>
</div>
{item.description ? <p className="mt-2 text-sm leading-5 text-zinc-600">{item.description}</p> : null}
{shouldShowOfficeElectronicsHint(item.expenseType?.code, item.amount) ? (
{shouldShowOfficeElectronicsHint(item.expenseType, item.amount) ? (
<p className="mt-2 text-xs text-amber-600">该金额通常应选择办公电子设备。</p>
) : null}
{invoiceGuardItemMessages(invoiceGuardIssues, item.id).map((message) => (
@@ -1259,7 +1259,7 @@ export function MobileReimbursementDetailPage() {
{detail.invoiceAmountManualReviewRequired ? (
<p className="mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm leading-6 text-amber-800">
本单包含未执行 OCR 的发票,系统未自动比较相关明细金额;财务审批时需查看发票原件核对。
本单包含票面金额未自动读取的发票,系统未自动比较相关明细金额;财务审批时需查看发票原件核对。
</p>
) : null}
@@ -1418,7 +1418,7 @@ export function MobileReimbursementDetailPage() {
) : null}
{invoice.amountEvidenceStatus === "ocr_failed" ? (
<p className="mt-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm leading-5 text-red-700">
OCR 已处理但未取得票面金额,提交前需要重试识别或联系财务。
该发票的票面金额未能读取,暂时无法提交;请重新上传这张发票,或联系财务处理。
</p>
) : null}
{canMaintainReimbursement && !invoice.linkedItemId ? (
+1 -1
查看文件
@@ -138,7 +138,7 @@ export function PaymentAccountsPage() {
{canManage && companyState.kind === "multiple" ? (
<SectionPanel title="公司信息需要处理">
<div className="space-y-3 text-sm text-red-600">
<p>检测到多条启用的公司信息,系统不会猜测付款账户应关联哪一条。请先处理公司信息。</p>
<p>检测到多条启用的公司信息,系统不会猜测付款账户应关联哪一条。请先完善公司信息。</p>
{canManageCompanyInformation ? (
<Button asChild type="button" variant="secondary">
<Link to="/system/master-data">查看公司信息</Link>
+3 -3
查看文件
@@ -1346,7 +1346,7 @@ export function ReimbursementDetailPage() {
</TableCell>
<TableCell>
<div>{item.description ?? "-"}</div>
{shouldShowOfficeElectronicsHint(item.expenseType?.code, item.amount) ? (
{shouldShowOfficeElectronicsHint(item.expenseType, item.amount) ? (
<div className="mt-1 text-xs text-amber-600">
该金额通常应选择办公电子设备。
</div>
@@ -1480,7 +1480,7 @@ export function ReimbursementDetailPage() {
{detail.invoiceAmountManualReviewRequired ? (
<p className="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm leading-6 text-amber-800">
本单包含未执行 OCR 的发票,系统未自动比较相关明细金额;财务审批时需查看发票原件核对。
本单包含票面金额未自动读取的发票,系统未自动比较相关明细金额;财务审批时需查看发票原件核对。
</p>
) : null}
@@ -1541,7 +1541,7 @@ export function ReimbursementDetailPage() {
) : null}
{invoice.amountEvidenceStatus === "ocr_failed" ? (
<p className="rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs leading-5 text-red-700">
OCR 已处理但未取得票面金额,提交前需要重试识别或联系财务。
该发票的票面金额未能读取,暂时无法提交;请重新上传这张发票,或联系财务处理。
</p>
) : null}
{canMaintainReimbursement && !invoice.linkedItemId ? (
@@ -8,9 +8,12 @@ import { Textarea } from "../../components/ui/textarea";
export const OFFICE_ELECTRONICS_HINT_THRESHOLD = 2000;
export function shouldShowOfficeElectronicsHint(expenseTypeCode: string | null | undefined, amount: string | number) {
export function shouldShowOfficeElectronicsHint(
expenseType: Pick<ExpenseType, "code"> | null | undefined,
amount: string | number,
) {
const numericAmount = Number(amount);
return expenseTypeCode === "office_supplies"
return expenseType?.code === "office_supplies"
&& Number.isFinite(numericAmount)
&& numericAmount >= OFFICE_ELECTRONICS_HINT_THRESHOLD;
}
@@ -70,7 +73,7 @@ export function ReimbursementItemEditor({
const selectedExpenseType = expenseTypes.find((item) => item.id === expenseTypeId) ?? null;
const numericAmount = Number(amount || 0);
const shouldWarnOfficeEquipment =
shouldShowOfficeElectronicsHint(selectedExpenseType?.code, numericAmount);
shouldShowOfficeElectronicsHint(selectedExpenseType, numericAmount);
const standardsQuery = useQuery({
enabled: Boolean(expenseTypeId),
@@ -955,7 +955,7 @@ test.describe("R111 国内报销发票与附件双端体验", () => {
const ocrFailedInvoice = {
...buildInvoice(),
id: "77777777-7777-4777-8777-777777777777",
invoiceNumber: "OCR-FAILED",
invoiceNumber: "AMOUNT-UNAVAILABLE",
originalName: "金额未识别.pdf",
totalAmount: null,
linkedItemId: "item-ocr-r111",
@@ -1010,6 +1010,12 @@ test.describe("R111 国内报销发票与附件双端体验", () => {
).toBeVisible();
await expect(page.getByText("这张发票还没有选择报销明细,请在下方完成关联。")).toBeVisible();
await expect(page.getByText("票面金额未自动识别,需由财务查看原件核对。")).toBeVisible();
await expect(page.getByText(
"该发票的票面金额未能读取,暂时无法提交;请重新上传这张发票,或联系财务处理。",
)).toBeVisible();
for (const forbiddenTerm of ["绑定整单", "不绑定明细", "发票池", "OCR"]) {
await expect(page.locator("body")).not.toContainText(forbiddenTerm);
}
await expect(page.getByText(unlinkedInvoiceId, { exact: false })).toHaveCount(0);
await expect(page.getByText("item-missing-r111", { exact: false })).toHaveCount(0);
await page.getByLabel("选择报销明细").selectOption("item-missing-r111");
@@ -1059,7 +1065,13 @@ test.describe("R111 国内报销发票与附件双端体验", () => {
await expect(page.getByText("尚未关联正式发票,请到“报销材料”添加发票并选择本明细。")).toBeVisible();
await expect(page.getByText("这张发票还没有选择报销明细,请在下方完成关联。")).toBeVisible();
await expect(page.getByText("票面金额未自动识别,需由财务查看原件核对。")).toBeVisible();
await expect(page.getByText(
"该发票的票面金额未能读取,暂时无法提交;请重新上传这张发票,或联系财务处理。",
)).toBeVisible();
await expect(page.getByLabel("选择报销明细")).toBeVisible();
for (const forbiddenTerm of ["绑定整单", "不绑定明细", "发票池", "OCR"]) {
await expect(page.locator("body")).not.toContainText(forbiddenTerm);
}
});
test("企业微信手机端保持移动布局,发票和附件能力与 PC 一致", async ({ browser }) => {