AlmondTill/G3N API

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: 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. A cost bill with NO posted receipt refuses VALIDATION/INVALID. Requires the doc current revision + the unrestricted capability.

Before you call

A bearer session from an API key (see Authentication and key hygiene) or a signed-in user.

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

Roles that may call it:

What happens

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

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.
reasonStringno

Concurrency

Send the record’s current revision from your last read as revision. A stale revision is refused as CONFLICT/REVISION_STALE — read the record again and retry with the new value.

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 and posts the landed true-up. 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

graphql
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:

json
{
  "id": "01900000-0000-7000-8000-2bdde69a0000",
  "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

json
{
  "data": {
    "captureVendorInvoice": {
      "id": "01900000-0000-7000-8000-2bdde69a0000",
      "sysId": "VI-EXMP-0000-000F",
      "type": "VendorInvoice",
      "caption": "Blue jeans",
      "status": "captured",
      "parentId": "01900000-0000-7000-8000-da3499da0000",
      "rootId": "01900000-0000-7000-8000-a1295a650000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-53c6eea90000",
      "invoiceOrgVendorId": "01900000-0000-7000-8000-ba06d1ac0000",
      "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