AlmondTill/G3N API

On this page

captureVendorInvoice

mutation · in the family Purchasing

What it does

Capture a vendor’s invoice against a purchase — what they billed you.

CAPTURE a draft VendorInvoice (draft -> captured — the 3-way match + the landed TRUE-UP in ONE transaction, -g/h): per match line, CUMULATIVE captured-sibling invoiced + this vs the PO line receivedQty rollup AND invoiced unit cost vs the PO line's — tolerance ZERO, variance FLAGS matchStatus/matchFlags (first-8) and NEVER blocks. Landed ACTUALS true up against the POSTED receipts estimates of the SAME component type (first capture of a type consumes them; later bills of that type are compensating additions): the estimate allocation re-derives deterministically over the stored posted lines, and each touched book takes ONE cost_true_up value-only movement (qty 0, signed costImpact, refs [VI, PO]) re-weighting its WMA over the CURRENT cost-bearing quantity — an empty/unabsorbing book keeps its WMA (the sold-share stays a reports-only fact). A cost bill with NO posted receipt refuses VALIDATION/INVALID. Requires the doc CURRENT revision (OCC) + the unrestricted capability.

What happens

The three-way story (ordered vs received vs billed) builds from here.

Who may call it

Capability area: Purchasing — Purchase orders, returns to vendors, vendor invoices and supplier records.

Arguments

NameTypeRequiredNotes
idID ID!yesThe id of the record.
revisionID ID!yesThe revision id you read on the record; the change is refused if an edit landed in the meantime.
reasonStringnoNo further notes.

Returns

VendorInvoice VendorInvoice! — A captured vendor bill: the 3-way match and the landed-cost TRUE-UP run from it at capture. NOT a payables subledger. Parent = the PO (the match is per-PO; N invoices per PO are legal — partial-shipment invoicing); invoiceOrgVendorId MAY differ from the PO vendor: ONE construct covers merchandise invoices (match lines) AND cost bills (landed ACTUAL components) — either or both, never neither. CAPTURE stamps matchStatus matched|flagged at tolerance ZERO (price/qty variance FLAGS, never blocks — the flag IS the approval queue until) and posts the landed true-up (actuals vs the receipts NOT-yet-trued estimates per component type -> cost_true_up value-only movements re-weighting each touched book at its CURRENT cost-bearing quantity; the sold-share stays a reports-only fact — the precedent). The (invoiceOrgVendor x normalized invoice number) UNIQ pair is the double-pay gate (CONFLICT/IDENTITY_TAKEN naming the holder; a cancelled holder is taken over). captured is the immutable fact (corrections are compensating entries, never un-capture); cancelled is the doomed terminal (lists filter it).

Example request

mutation ExampleCaptureVendorInvoice($id: ID!, $revision: ID!, $reason: String) {
  captureVendorInvoice(id: $id, revision: $revision, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    invoiceOrgVendorId
    invoiceNumber
    invoiceDate
    notes
    matchStatus
  }
}

Variables:

{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "reason": "Correcting a miscount."
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

{
  "data": {
    "captureVendorInvoice": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "VI-EXMP-0000-000F",
      "type": "VendorInvoice",
      "caption": "Blue jeans",
      "status": "draft",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "invoiceOrgVendorId": "01900000-0000-7000-8000-38bdd2a10000",
      "invoiceNumber": "<invoice number>",
      "invoiceDate": "2027-01-31",
      "notes": "Restock before the weekend.",
      "matchStatus": "matched"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer

Used in