[fiscus-capture] Receipts: read from an OCR's words; payment.receipt_attached (v0.9.0) #11

Manually merged
mnovak merged 1 commits from feature/receipts into main 2026-11-17 19:40:37 +01:00
Owner

Step 3 of PLAN-receipts-links.md (in the Fiscus workspace): the receipt parser and the ledger's receipt, pure and public. The OCR (Lector) runs in the app; the core gets its words.

Reading (fiscus_capture::receipt::read)

  • Input: lines of words with boxes and confidence in thousandths (the app converts; no float enters the core, and no_float.rs still passes).
  • Finds, by label only: the total (what is to pay beats Celkem; VAT, base, subtotal, rounding and change lines never count; split thousands; over 10 M refused whole), the date and time, the IČO with its check digit (or from a company DIČ), the DIČ, the shop's name above the IČO (Title Case, always to check).
  • sure per field (every word ≥ 800/1000). Nothing found is an empty result, not an error. Bounded (600 lines, 120 words, 80 characters), control characters dropped.
  • No shop templates: fixtures/receipts/ waits for redacted samples (as OCR text, never the photo).

Ledger

  • payment.receipt_attached { payment, receipt: { shop, ico, dic } }, checked; the payment keeps its merchant and key (rules stay); a later one replaces it; visible on either half of a confirmed pair.
  • State::known_shop(ico) (your latest receipt with it) and State::receipt_match(total, date) (exactly one outflow of that amount within 3 days without a receipt, else none).

Phone post: "source": "receipt" with optional ico, dic; an IČO/DIČ without it, or another source, is refused.

Tests: 157 pass (new: 10 reading incl. a proptest, 1 post, 4 ledger); clippy -D warnings clean. Two bugs found by the tests and fixed: a web address taken as the shop; an amount over the limit read as its tail.

Self-review: ReceiptInfo::check is the one validator for the post and the event; receipt_seq is the max of the pair's stamps, so known_shop takes the newest; #[serde(default)] on the new PaymentRecord field.

Step 3 of PLAN-receipts-links.md (in the Fiscus workspace): the receipt parser and the ledger's receipt, pure and public. The OCR (Lector) runs in the app; the core gets its words. **Reading** (`fiscus_capture::receipt::read`) - Input: lines of words with boxes and confidence in **thousandths** (the app converts; no float enters the core, and `no_float.rs` still passes). - Finds, by label only: the total (what is to pay beats `Celkem`; VAT, base, subtotal, rounding and change lines never count; split thousands; over 10 M refused whole), the date and time, the IČO with its check digit (or from a company DIČ), the DIČ, the shop's name above the IČO (Title Case, always to check). - `sure` per field (every word ≥ 800/1000). Nothing found is an empty result, not an error. Bounded (600 lines, 120 words, 80 characters), control characters dropped. - No shop templates: `fixtures/receipts/` waits for redacted samples (as OCR text, never the photo). **Ledger** - `payment.receipt_attached { payment, receipt: { shop, ico, dic } }`, checked; the payment keeps its merchant and key (rules stay); a later one replaces it; visible on either half of a confirmed pair. - `State::known_shop(ico)` (your latest receipt with it) and `State::receipt_match(total, date)` (exactly one outflow of that amount within 3 days without a receipt, else none). **Phone post:** `"source": "receipt"` with optional `ico`, `dic`; an IČO/DIČ without it, or another source, is refused. **Tests:** 157 pass (new: 10 reading incl. a proptest, 1 post, 4 ledger); clippy `-D warnings` clean. Two bugs found by the tests and fixed: a web address taken as the shop; an amount over the limit read as its tail. **Self-review:** `ReceiptInfo::check` is the one validator for the post and the event; `receipt_seq` is the max of the pair's stamps, so `known_shop` takes the newest; `#[serde(default)]` on the new `PaymentRecord` field.
mnovak added 1 commit 2026-11-17 19:40:26 +01:00
fiscus_capture::receipt::read takes the OCR's lines (words with boxes and confidence in thousandths) and finds
the total, date and time, IČO (check digit), DIČ and the shop's name by their labels, never a shop's layout;
unsure words mark their field, the shop is always to check; bounded, control characters dropped, a proptest.
The phone's post takes a receipt (source receipt, ico, dic). The ledger gains payment.receipt_attached (the
payment keeps its merchant and key), known_shop and receipt_match (exactly one candidate or none).
docs/07_receipts.md; fixtures/receipts/ waits for redacted samples. v0.9.0.
mnovak manually merged commit ec9519a234 into main 2026-11-17 19:40:37 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/FiscusPublic#11