2.9 KiB
2.9 KiB
Reimbursement / Invoice / OCR
Source Docs
Read docs/报销发票附件规则.md before changing reimbursement, invoice, OCR,
duplicate detection or attachment behavior.
Rules
- PDF invoice OCR is the maintained main path.
- Image OCR remains frozen unless a later Trellis task explicitly reopens it.
- Do not write raw invoice images, sensitive form values or full OCR payloads to repo docs, Issue CSV, Trellis task files or chat.
- 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-batchesreturns each batch withreceiptAttachmentCount: number.GET /api/payment-batches/:idreturns the same field ondata.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 isreviewedorfailed, at least one pending/failed item resolves to bank channel, andreceiptAttachmentCountis0. - 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_v1disabled -> existing409 VALID_001.- Reader lacks batch permission -> existing
403 PERM_001. - Count missing from an older mocked payload -> frontend treats it as
0for backward-compatible tests, but real backend responses should include it.
5. Good/Base/Bad Cases
- Good: a reviewed bank batch with no receipt contributes
1to待补回单. - 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
const selectedNeedsReceipt = selectedBatch && selectedReceiptCount === 0 ? 1 : 0;
Correct
const needsReceipt = batches.filter((batch) =>
["reviewed", "failed"].includes(batch.status) &&
(batch.receiptAttachmentCount ?? 0) === 0 &&
batch.items.some((item) => (item.paymentChannelOverride ?? batch.defaultPaymentChannel) === "bank"),
).length;