Skip to main content

Create Vendor Credit from Extraction

POST 

/api/vendor-credits/ocr/:extraction/create-credit

Create a draft vendor credit from a reviewed OCR extraction. The OCR'd PDF is automatically attached to the new credit and the extraction is marked confirmed.

Required scope: orders:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Body fields (all top-level fields optional unless noted):

  • supplier_id: optional integer, must exist in suppliers
  • purchase_order_id: optional integer, must exist in purchase_orders
  • warehouse_id: optional integer, must exist in warehouses
  • currency_id: optional integer, must exist in currencies
  • credit_date: optional date
  • supplier_reference: optional string, max 255
  • vendor_credit_note: optional string
  • lines: REQUIRED array, min 1 element

Line fields (per element of lines):

  • quantity: required, numeric, min 1
  • amount: required, numeric, must be less than 100000
  • purchase_order_line_id: optional integer (existing PO line)
  • product_id: optional integer (existing product)
  • description: optional string, max 255
  • unit_cost: optional numeric
  • nominal_code_id: optional integer (for non-product/financial lines)
  • is_product: optional boolean
  • restock_inventory: optional boolean

Returns 201 with the new vendor_credit_id. Returns 422 with a message when the manager rejects the request (e.g. duplicate or invalid state).

The created credit's vendor_credit_number defaults to the supplier's credit reference (extracted credit_number / supplier_reference) when that number is not already in use; otherwise the next local VC-#### number is generated.

Reference fields:

  • vendor_credit_number (string, max 255) — The supplier's credit memo number. On create it becomes the credit's number (falls back to the OCR-detected credit_number, auto-generates VC-xxxxx if taken). On apply it renames the credit — skipped silently if another credit already uses that number.
  • supplier_po_number (string, max 255) — The PO number printed on the supplier's memo, recorded as TEXT only (defaults from the OCR-detected po_number on create). It does not link a purchase order; use purchase_order_id for an actual link.
  • supplier_reference (string, max 255) — Any additional reference on the document (e.g. the vendor's internal credit-order number). No longer auto-filled with the memo number.

Request

Responses

Created

Response Headers
    Content-Type