Skip to main content

createStockMovement

Requires permission inventory:stock_movement:create.

Records one stock movement and changes stock by its quantity. An issue must be negative and a receipt positive, and a movement of the wrong sign is refused; transfers, adjustments, returns and cycle counts carry their own sign. Which warehouse is affected depends on the type, and the movement needs one. A quantity entered in a pack unit is converted to base units. Needs the stock movement create permission.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation CreateStockMovement($input: CreateStockMovementInput!) {
createStockMovement(input: $input) {
id
batchNumber
movementNumber
serialNumber
status
type
fromWarehouse {
id
code
taxRegistrationNumber
name
status
type
}
}
}

Variables:

{
"input": {
"productId": "id",
"quantity": 0,
"type": "ADJUSTMENT",
"variantId": "id"
}
}

Response:

{
"data": {
"createStockMovement": {
"id": "id",
"batchNumber": "string",
"movementNumber": "string",
"serialNumber": "string",
"status": "CANCELLED",
"type": "ADJUSTMENT",
"fromWarehouse": {
"id": "id",
"code": "string",
"taxRegistrationNumber": "string",
"name": "string",
"status": "ACTIVE",
"type": "string"
}
}
}
}

Record a stock adjustment:

mutation CreateStockMovement($input: CreateStockMovementInput!) {
createStockMovement(input: $input) {
id
movementNumber
status
balanceQuantity
}
}

Variables:

{
"input": {
"productId": "PRODUCT_ID",
"variantId": "VARIANT_ID",
"type": "ADJUSTMENT",
"quantity": 5
}
}

Response:

{
"data": {
"createStockMovement": {
"id": "STOCK_MOVEMENT_ID",
"movementNumber": "MOVEMENT_NUMBER",
"status": "COMPLETED",
"balanceQuantity": 5
}
}
}
createStockMovement(
input: CreateStockMovementInput!
): StockMovement!

Arguments​

createStockMovement.input ● CreateStockMovementInput! non-null input​

The movement type, warehouses, product, variant, quantity and optional batch, serial number, reference, reason, notes and unit.

Type​

StockMovement object​

A movement of stock: a receipt, issue, transfer or adjustment.