重构财务台账工具与异常优先页面(05-30-finance-ledger-tools-redesign)

这个提交包含在:
2026-05-30 12:22:06 +08:00
父节点 c4edb12bb8
当前提交 51a1347827
共修改 17 个文件,包含 305 行新增和 117 行删除
@@ -558,6 +558,13 @@ screen.
filing or full accounting software. Real payment stays in offline banking or
existing finance/accounting workflows; OA records status, evidence and
handover summaries.
- Payment, AP and invoice pages default to task/exception visibility: `付款`
shows review, payment-marking, receipt and exception attention before batch
creation; `应付账款` shows pending payment, exceptions, risks and differences
before export; `票据` shows OCR status, failed invoices and bindable invoices
before broad-scope handover tools. Batch creation, export, full-scope views
and agency-accounting handover controls live in `台账工具` or selected-context
panels, never as the first-screen primary action.
- Payment actions require the finance/payment context: amount, payee or target
object, source records, offline payment explanation, evidence completeness,
receipt requirement and correction boundary. Do not place `标记已付款`,
@@ -14,3 +14,67 @@ duplicate detection or attachment behavior.
- Reimbursement flow tests should cover upload/OCR, duplicate handling,
submission, approval, payment batch, receipt attachment and AP export when the
Trellis task scope touches those areas.
## Scenario: Payment Batch Receipt Attention Count
### 1. Scope / Trigger
- Trigger: payment list pages need a first-screen `待补回单` metric without
loading or exposing every receipt attachment.
- Applies to payment batch list/detail APIs and the PC `付款` page.
### 2. Signatures
- `GET /api/payment-batches` returns each batch with
`receiptAttachmentCount: number`.
- `GET /api/payment-batches/:id` returns the same field on `data.item`.
- The count comes from Prisma `_count.receipt_attachments`; the list response
must not include receipt file names, hashes, storage paths or download URLs.
### 3. Contracts
- Only users who can read payment batches may receive the count.
- Frontend `待补回单` is list-level attention: batch status is `reviewed` or
`failed`, at least one pending/failed item resolves to bank channel, and
`receiptAttachmentCount` is `0`.
- Receipt preview, upload, delete and download stay in the selected batch detail
panel and continue to use receipt attachment endpoints with their own
permission, governance and audit checks.
### 4. Validation & Error Matrix
- `payment_batch_v1` disabled -> existing `409 VALID_001`.
- Reader lacks batch permission -> existing `403 PERM_001`.
- Count missing from an older mocked payload -> frontend treats it as `0` for
backward-compatible tests, but real backend responses should include it.
### 5. Good/Base/Bad Cases
- Good: a reviewed bank batch with no receipt contributes `1` to `待补回单`.
- Base: a reviewed bank batch with uploaded receipt contributes `0`.
- Bad: counting only the currently selected batch, which hides missing receipts
elsewhere in the list.
### 6. Tests Required
- Server focused route tests when payment batch mapping changes.
- `cd client && npm run typecheck && npm run build`.
- Focused Playwright around `付款`, `应付账款`, `票据` and finance ledger tools.
### 7. Wrong vs Correct
#### Wrong
```ts
const selectedNeedsReceipt = selectedBatch && selectedReceiptCount === 0 ? 1 : 0;
```
#### Correct
```ts
const needsReceipt = batches.filter((batch) =>
["reviewed", "failed"].includes(batch.status) &&
(batch.receiptAttachmentCount ?? 0) === 0 &&
batch.items.some((item) => (item.paymentChannelOverride ?? batch.defaultPaymentChannel) === "bank"),
).length;
```