manicanldes-backend/docs/goods-receipts-api.md

1.9 KiB

Phase 2C: goods receipts and quality inspection

All routes are under /api/v1 and require a bearer token. Read routes require procurement.read; writes require procurement.manage. Records are scoped to the signed-in organization.

Method Route Purpose
GET /purchase-orders/:orderId/receipts List up to 100 receipts for an order
POST /purchase-orders/:orderId/receipts Record a partial delivery against an issued order
GET /goods-receipts/:id Read a receipt with its QC decisions
POST /goods-receipts/:id/inspect Make one atomic QC decision for every receipt line

Create a receipt with {"deliveryNote":"DN-001","lines":[{"purchaseOrderLineId":"<uuid>","quantity":"2.000"}]}. The delivery note is optional. Quantity strings use exactly three decimal places. Each line must belong to the order. A receipt cannot exceed outstanding quantity: previously accepted goods and goods awaiting QC consume the ordered quantity; rejected goods do not. This permits a replacement delivery after rejection.

Inspect with {"lines":[{"receiptLineId":"<uuid>","acceptedQuantity":"1.000","rejectedQuantity":"1.000","rejectionReason":"Damaged packaging"}]}. Every receipt line must be included exactly once. Accepted and rejected quantities must sum to the received quantity; rejected goods need a reason. Decisions and receipt records are immutable. The transaction records an audit event for creation and inspection.

This phase records receipt and QC evidence. Material on-hand balances, invoices, and supplier payments are separate future phases. Receipt creation is not idempotent; clients should read the order's receipts before retrying an uncertain write.