API Reference

Available queries

Purchase - Returns a single purchase based on the id provided

query {
  Purchase (id: 100012) {
    id
    label
  }
}

Purchases - Returns a list of purchases based on the filter define

query {
  Purchases {
    data {
    	id
    	label
    }
  }
}


Available fields

id - Int
Unique identifier of the purchase
label - String
Title of the purchase
notes - String
Notes attached to the purchase
total_units - Float
Total units of the purchase
status - String
Status of the purchase (enum values : active, archived, cancelled, completed, unpublished).
update_incoming - Boolean
If true, the purchase products have their incoming updated until they are delivered
dated_at - Date
Date of the purchase
created_at - DateTime
Creation date of the purchase
supplier - Supplier - Subquery
Supplier of the purchase
shipping_at - Date
Date the shipping is planned
shipping_cost - Float
Shipping costs of the purchase
exchange_rate - Float
Exchange rate of the purchase
currency - String
Currency code of the purchase (GBP, USD, ...)
committed - Float
Quantity already added to a purchase receipt
delivered - Float
Quantity already delivered
purchase_receipt - Array of PurchaseReceipt - Subquery
List of the purchase receipts created from this purchase
orders - Array of Order - Subquery
List of the orders the purchase is created from to reorder
line_items - Array of LineItem - Subquery
List of the line items of the purchase
integrations - Integration - Subquery
List of the ID of the items of the integrated solutions linked to this purchase
has_batch_numbers - Boolean
Define if the purchase has batch numbers
tracking_completed - Boolean
If the purchase has batch numbers, are they all allocated


Filters

You can create filters based on following fields

label
Example: { "column" : "LABEL", "operator" : "LIKE", "value" : "%011%" }
status
Example: { column": "STATUS", "operator": "EQ", "value": {"id": "completed"}
total_units
Example: { "column": "TOTAL_UNITS", "operator": "GT", "value": 50 }
update_incoming
Example: { column": "UPDATE_INCOMING", "operator": "EQ", "value": true }
dated_at
Example: { "column": "DATED_AT", "operator": "EQ", "value": "2024-01-11" }
supplier_id
Example: { "column": "SUPPLIER_ID", "operator": "EQ", "value": 100002 }
committed
Example: { "column": "COMMITTED", "operator": "GT", "value": 149.09 }
shipping_at
Example: { "column": "SHIPPING_AT", "operator": "LT", "value": "2024-01-11" }
delivered
Example: { "column": "DELIVERED", "operator": "LT", "value": 349 }
variant_id
Purchase containing this variant
Example: { "column": "VARIANT_ID", "operator": "EQ", "value": 100076 }
variant_label
Example: { "column": "VARIANT_LABEL", "operator": "EQ", "value": "NICE SHOES" }
variant_sku
Example: { "column": "VARIANT_SKU", "operator": "EQ", "value": "10ABC45" }
location_id
Example: { "column": "LOCATION_ID", "operator": "EQ", "value": "100245" }
batch_number_id
Example: { "column": "BATCH_NUMBER_ID", "operator": "EQ", "value": "100024" }
tracking_completed
Example: { "column": "TRACKING_COMPLETED", "operator": "EQ", "value": {"id": true} }
has_batch_numbers
Example :{ column": "HAS_BATCH_NUMBERS", "operator": "EQ", "value": {"id": true} }

Sorting

You can sort data based on following fields : id, label, notes, total_units, status, update_incoming, dated_at, created_at, shipping_at, supplier_id, committed, delivered, currency

Example of a query

query Purchases(
  $orderBy: [QueryPurchasesOrderByOrderByClause!], 
  $where: QueryPurchasesWhereWhereConditions, 
  $first: Int = 50, 
  $page: Int
) {
  Purchases(
    orderBy: $orderBy
    where: $where
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
      count
      currentPage
      perPage
    }
    data {
      id
      label
      supplier {
        id
        label
      }
      line_items {
        id
        location {
          id
          label
        }
      }
      dated_at
      shipping_at
      total_units
      status
    }
  }
}
{
  "orderBy": [
    {
      "order": "ASC",
      "column": "DATED_AT"
    }
  ],
  "first": 50,
  "page": 1,
  "where": {
    "AND": [
      {
        "AND": [
          {
            "column": "SHIPPING_AT",
            "operator": "GT",
            "value": "2023-10-03"
          }
        ]
      }
    ]
  }
}

Example of data returned

{
  "data": {
    "Purchases": {
      "paginatorInfo": {
        "total": 1,
        "count": 1,
        "currentPage": 1,
        "perPage": 50
      },
      "data": [
        {
          "id": 100011,
          "label": "P00000012",
          "supplier": null,
          "line_items": [
            {
              "id": 100231,
              "location": {
                "id": 100010,
                "label": "error"
              }
            },
            {
              "id": 100232,
              "location": {
                "id": 100010,
                "label": "error"
              }
            },
            {
              "id": 100233,
              "location": {
                "id": 100010,
                "label": "error"
              }
            }
          ],
          "dated_at": "2024-01-15",
          "shipping_at": "2023-10-14",
          "total_units": 2435933.23635,
          "status": "active"
        }
      ]
    }
  }
}