Mutations

See the Queries page for a presentation of this resource.

CreatePurchase

Create a purchase

Note: This mutation can be used only for companies who can create purchases.

Parameters

input
Data of the purchase

Example

mutation {
  CreatePurchase(
    input: {
      id: null,
      label: null,
      notes: null,
      total_units: null,
      status: "active",
      dated_at: null,
      shipping_at: "2024-01-31",
      update_incoming: true,
      exchange_rate: 1,
      currency: "EUR",
      supplier: {
        id: 100001,
        label: "consequatur"
      },
      line_items: [
        {
          temporary_id: 1705668862433,
          is_kit: false,
          quantity: 3,
          cost: 10,
          weight: 0,
          description: "",
          location: {
            id: 100006,
            label: "assumenda"
          },
          variant: {
            id: 100290,
            label: "Amazeballs Humbro Shoes"
          }
        },
        {
          temporary_id: 1705665562433,
          is_kit: false,
          quantity: 20,
          cost: 10,
          weight: 0,
          description: "",
          location: {
            id: 100006,
            label: "assumenda"
          },
          variant: {
            id: 100280,
            label: "Cawabunga Assault Rifle
          },
          batch_numbers:[ 
            {
              batch_number:{
                id:189000
              }
              quantity:12
            },
            {
              batch_number:{
                id:189666
              }
              quantity:8
            }
          ]
        }
      ]
    }
  ) {
    id
  }
}

Returned data

{
  "data": {
    "CreatePurchase": {
      "id": 100012,
    }
  }
}

UpdatePurchase

Update a purchase

Parameters

id
Id of the purchase
input
Data of the purchase

Example

mutation UpdatePurchase($id: ID!, $input: PurchaseInput!) {
  UpdatePurchase(id: $id, input: $input) {
    id
    shipping_at
  }
}
{
  "id": 100012,
  "input": {
    "shipping_at": "2024-01-30"
  }
}

Returned data

{
  "data": {
    "UpdateOrder": {
      "id": 100012,
      "shipping_at": "2024-01-30"
    }
  }
}

TransformIntoPurchaseReceipt

Create a purchase receipt document based on a purchase

Parameters

id
Id of the purchase

Example

mutation TransformIntoPurchaseReceipt($id: ID!) {
  TransformIntoPurchaseReceipt(id: $id) {
    id
    label
    status
    dated_at
  }
}
{
  "id": 100012
}

Returned data

{
  "data": {
    "TransformIntoPurchaseReceipt": {
      "id": 100012,
      "label": "PRP00000013",
      "status": "unpublished",
      "dated_at": "2024-01-19"
    }
  }
}

DeletePurchase

Delete a purchase

Parameters

id
Id of the purchase

Example

mutation DeletePurchase($id: ID!) {
  DeletePurchase(id: $id)
}
{
  "id": 100009
}

Returned data

{
  "data": {
    "DeletePurchase": true
  }
}

GeneratePurchaseNumber

Generates the next available purchase number.

mutation {
  GeneratePurchaseNumber
}

PurchaseInput data type

id
Unique identifier of the purchase
label
Title of the purchase
notes
Notes attached to the purchase
status
Status of the purchase (enum values : active, archived, cancelled, completed, unpublished).
update_incoming
If true, the purchase products have their incoming updated until they are delivered
supplier_id
Unique identifier of the supplier
supplier
Supplier of the purchase
line_items
List of the line items of the purchase
dated_at
Date of the purchase
created_at
Creation date of the purchase
shipping_at
Date the shipping is planned
shipping_cost
Shipping costs of the purchase
exchange_rate
Exchange rate of the purchase
total_units
Total units of the purchase
currency
Currency code of the purchase (GBP, USD, ...)
orders
List of the orders the purchase is created from to reorder

OrderPurchaseInput data type

data
List of the orders the purchase is created from to reorder