Remove repeated Plant, Financial and Workforce shortcut cards. Add site-scoped Plant and Financial sidebar attention status with automatic refresh. Include accumulated delivery processing, purchase order recovery, supplier reconciliation, plant data and user management changes and audit records.
4.8 KiB
Delivery-note processing preview
The approved increment adds a separate, fresh AI processing call to an existing delivery-note candidate. It consumes saved extraction, operator corrections, the confirmed supplier and PO, that supplier's applicable rules, and prior receipts. It does not read the photo again or change financial posting.
Operator flow
Open an unposted delivery note from the inbox and use Run AI preview. The panel shows source descriptions/counts, proposed PO quantities, monetary basis, kit groups and specific review questions. Correct the document with the existing controls, then run a fresh preview. Closed candidates cannot run a preview.
Draft supplier rules may inform proposals but remain draft. Each call starts a
new MiniMax conversation without tools or prior chat history. The provider uses
the existing MINIMAX_API_KEY and MINIMAX_BASE_URL; DN_RECONCILIATION_MODEL
can override MINIMAX_MODEL. The user explicitly approved sending the pilot
extraction, PO details, supplier rules and prior receipts to
https://api.minimax.io on 1 October 2026.
For MiniMax-M3 the default is direct structured response mode after the extended
reasoning pilot timed out; DN_RECONCILIATION_THINKING=adaptive opts into its
slower adaptive mode. The completion budget includes reasoning, if enabled.
Data and validation
One optional JSON field, dn_batch_notes.reconciliation_preview, stores the
latest proposal separately from items, page extraction and readiness checks.
No new collection is required. Supplier guidance remains in
suppliers.reconciliation_rules. A review event records actor, model, rule
versions, snapshot hash and generation time. The ordinary batch lease fences
the save and audit event in one transaction.
The context fingerprint includes document fields, grouping, correction decisions, page extraction, supplier knowledge, PO lines and prior receipts. Source line IDs are scoped to that snapshot; they are not ledger allocation IDs. Corrections make old results stale. A changed snapshot during the AI call is rejected before saving, and GET checks freshness again when loading a result.
Code validates line coverage, unique allocation ownership, supplier/site/PO ownership, known PO item IDs and rule keys. Omitted source lines become review questions, never disappear. Numeric results are calculated from saved data: single-line quantities, multiplication by a proposed conversion factor, equal component counts for simple kits, source amounts, or discounted PO rates. AI interpretations and VAT-basis proposals still need human review. The model cannot turn a blank PO unit into a confirmed unit or override a manual item link silently. A corrected quantity inconsistent with the source rate/amount stays in review.
Explicit zero-price accessories retain their counts and add no paid-product quantity. Missing price is unknown, even when a draft convention suggests free supply. Unmatched service lines may carry supported source amounts at PO level. Unequal/unknown kit ratios remain review questions.
Previous receipt money is explicitly an estimate at current PO rates, because
the existing ledger lacks confirmed amount snapshots. Estimated net totals are
compared with the calculated net PO-line baseline, not with an assumed tax basis
for total_value. The preview labels incomplete subtotals, quantity excess and
possible repeated references. It does not certify historical receipts or confirm
that an unmatched legacy receipt had no cost.
Installation and limits
Apply the additive storage migration:
node --env-file=.env.local scripts/migrations/2026-10-01-add-dn-processing-preview.mjs --apply
Without --apply it is read-only. The migration backs up the schema and verifies
existing fields, access rules and indexes after adding the optional field. It
has been applied to the configured PocketBase instance.
The preview is manually initiated, not yet part of automatic ingestion. It does not change candidate status, extraction, supplier rules, PO authorisation, delivery notes or received quantities. Existing posting continues to use the existing checks. Per-line Confirm and post, confirmed amount snapshots, partial posting and authoritative cumulative monetary checks remain the next increment; nightly proposed corrections follow those.
Local validation: 531 delivery pipeline/API/UI tests passed, TypeScript checking
passed, and lint passed for the new modules. The touched existing detail-view
file has a pre-existing set-state-in-effect lint error in its image viewer, plus
two existing warnings. The new preview panel was inspected on the real Avidan
IO019079 document in the running development app. Live model pilot outcomes are
recorded in docs/audits/2026-10-01-delivery-processing-preview.md. The final
23 focused preview tests also passed after provider and validation fixes.