Batch numbers in stock levels

BatchNumberStockLevel — Returns a single batch number stock level based on the id provided

query GetBatchNumberStockLevel($id: ID) {
  BatchNumberStockLevel(id: $id) {
    id
    on_hand
    variant { id }
    location { id }
    batch_number { id }
  }
}
{
  "id": 100012
}

BatchNumberStockLevels — Returns a list of batch number stock levels with grouping, filters, and ordering

query BatchNumberStockLevels(
  $groupBy: QueryBatchNumberStockLevelsGroupByGroupByClause,
  $where: QueryBatchNumberStockLevelsWhereWhereConditions,
  $orderBy: [QueryBatchNumberStockLevelsOrderByOrderByClause!]
) {
  BatchNumberStockLevels(
    groupBy: $groupBy
    where: $where
    orderBy: $orderBy
  ) {
    id
    on_hand
    variant { id }
    location { id }
    batch_number { id }
  }
}
{
  "groupBy": {
    "HAVING": [
      { "column": "ID", "value": 100012 }
    ]
  },
  "where": {
    "AND": [
      { "column": "BATCH_NUMBER_ID", "operator": "EQ", "value": 100010 }
    ]
  },
  "orderBy": [
    { "column": "ON_HAND", "order": "DESC" }
  ]
}

Available fields

FieldTypeDescription
idIntUnique identifier of the batch number stock level.
on_handFloatQuantity on hand for this batch number at this location.
variantObjectLinked variant entity.
locationObjectLinked location entity.
batch_numberObjectLinked batch number entity.

Filters

You can create filters based on following fields

id - Int
Example: { "column": "ID", "operator": "EQ", "value": 100012 }
on_hand - Float
Example: { "column": "ON_HAND", "operator": "GT", "value": 50 }
variant_id - ID
Example: { "column": "VARIANT_ID", "operator": "EQ", "value": 100076 }
location_id - ID
Example: { "column": "LOCATION_ID", "operator": "EQ", "value": 100245 }
batch_number_id - ID
Example: { "column": "BATCH_NUMBER_ID", "operator": "EQ", "value": 100010 }
batch_number_label - String
Example: { "column": "BATCH_NUMBER_LABEL", "operator": "LIKE", "value": "%BATCH%" }
batch_number_deleted_at - DateTime
Example: { "column": "BATCH_NUMBER_DELETED_AT", "operator": "IS_NULL", "value": null }

Sorting

You can sort data based on following fields: id, on_hand, variant_id, location_id, batch_number_id, expiry_date

query SortBatchNumberStockLevels(
  $where: QueryBatchNumberStockLevelsWhereWhereConditions
) {
  BatchNumberStockLevels(
    where: $where
    orderBy: [{ column: ON_HAND, order: DESC }]
  ) {
    id
    on_hand
    variant { id }
    location { id }
    batch_number { id }
  }
}

Example of data returned

{
  "data": {
    "BatchNumberStockLevels": [
      {
        "id": 100001,
        "on_hand": 150.5,
        "variant": { "id": 100076 },
        "location": { "id": 100245 },
        "batch_number": { "id": 100010 }
      },
      {
        "id": 100002,
        "on_hand": 75.0,
        "variant": { "id": 100077 },
        "location": { "id": 100246 },
        "batch_number": { "id": 100011 }
      }
    ]
  }
}