Sales Order OCR
Upload Customer PO PDF
Upload a customer PO PDF to start the OCR extraction process. Returns the extraction ID and a tracked-job ID; the actual OCR work runs asynchronously via Azure Document Intelligence. Poll GET /sales-orders/ocr/{id} until status is 'pending_review' (or 'failed' / 'duplicate_detected').
Get OCR Extraction
Retrieve a single OCR extraction record by ID. Returns the extracted header (customer PO number, dates, customer match, totals), per-line items with quantities/prices/match status, and the current review status.
Delete OCR Extraction
Delete an OCR extraction record and its associated uploaded PDF. Use this to discard an extraction that will not be converted to a sales order.
Stream Extraction PDF
Stream the original uploaded PDF back to the client through the backend (avoids CORS issues when fetching from S3 directly). Returns Content-Type: application/pdf with inline disposition. 404 if the underlying S3 object is missing.
Create Sales Order from Extraction
Create a sales order from a reviewed OCR extraction. The request body contains the confirmed/edited field values from the review UI.
Clone Lines from Sales Order
Clone confirmed lines from a prior sales order into this extraction's lines_data.
Reclassify as Supplier Invoice
Reclassify a Customer PO OCR extraction as a Supplier Invoice. Used when an inbound email was routed to orders@ but the attached PDF is actually a supplier invoice.
Rescan Customer PO OCR
Re-run OCR extraction on an existing Customer PO record. Resets status to 'processing', clears any prior error_message, and re-dispatches the OCR job. Useful when the extraction failed initially (status='failed') or when the matching/parsing logic has improved and the user wants to re-derive the extracted data from the original PDF or email body.