12 lines
2.1 KiB
Markdown
12 lines
2.1 KiB
Markdown
|
|
# Delivery reconciliation API
|
||
|
|
|
||
|
|
`GET /api/purchase-orders/{poId}/delivery-reconciliation` is a read-only snapshot for a daily n8n workflow or agent. Send the existing `x-ingest-secret: <N8N_INGEST_SECRET>` header. The endpoint does not run OCR, create receipts, dismiss duplicates, or change a purchase order.
|
||
|
|
|
||
|
|
The response groups pending scans by normalized document reference and returns each candidate's batch, pages, check failures, and booking preview. `pagePaths` identify the cached source pages; fetch them with the same header if an agent must inspect the attachments. Posted receipts include `slipPath`. The workflow can compare these sources with the PO and return decisions to the human reviewer.
|
||
|
|
|
||
|
|
Each PO line returns its ordered quantity and ex-VAT value, quantities and ex-VAT value already posted, and the provisional outstanding quantity. Candidate previews show the slip quantity, conversion into the PO unit, rate, and prospective value. **Pending candidates never enter posted totals.** A pipe supplied as 11 each and priced by the PO at R1,584.02 per metre for a 2.5 m length previews 27.5 m and R43,560.55 ex VAT.
|
||
|
|
|
||
|
|
`possibleDoubleCountQuantity` reports equal quantities appearing on both an invoice and a delivery note for the same PO line. It is a review warning, not an automatic deduction: two genuine deliveries can have the same quantity. `reviewRequired` is true when there are pending candidates, possible double counts, or incomplete PO quantity/rate data. An agent should compare primary and alternate document references, dates, source images, supplier, item wording, and cumulative quantities before recommending which copy to retain. The ordinary candidate posting route remains the only way to book a new receipt.
|
||
|
|
|
||
|
|
For the daily workflow: enumerate the POs of interest, call this endpoint once per PO, fetch only relevant `pagePaths` and `slipPath` attachments, and store a concise proposed action per candidate. Re-run the endpoint after any reviewed posting or correction; the totals are calculated from the current ledger each time. If a ledger read fails, the endpoint returns an error rather than an apparently complete order.
|