Execute Inventory Item Movement

Execute Inventory Item Movement Mutation

Executes a pending item movement, transferring the inventory and updating stock levels.

Arguments

Name
Type
Description

id

UUID!

ID of the movement to execute

Return Type

InventoryItemMovementOutput - Contains the executed movement and any triggered workflows.

Field
Type
Description

itemMovement

ItemMovement!

The executed item movement

workflows

[TemporalWorkflow]

Any workflows triggered by this operation

Usage Example

mutation {
  executeInventoryItemMovement(
    id: "movement-123"
  ) {
    itemMovement {
      id
      quantity
      executedAt
      executedBy
      fromRepository {
        id
        name
      }
      toRepository {
        id
        name
      }
      item {
        id
        sku
      }
      transactions {
        id
        quantity
        repositoryID
      }
    }
    workflows {
      id
      type
      status
      runID
    }
  }
}

What Happens During Execution

  1. Validation: Checks if movement can be executed

    • Movement must be pending (not already executed)

    • Not blocked by business rules

    • Sufficient stock available (unless from virtual repository)

  2. Stock Updates:

    • Decreases stock in source repository

    • Increases stock in destination repository

    • Updates parent repository aggregations

  3. Transaction Creation:

    • Creates outgoing transaction in source repository

    • Creates incoming transaction in destination repository

  4. Movement Update:

    • Sets executedAt timestamp

    • Records executedBy user ID

Error Cases

  • Movement already executed

  • Movement is blocked

  • Insufficient stock in source repository

  • Movement not found

Notes

  • Execution is atomic - either fully completes or rolls back

  • Virtual repositories bypass stock validation

  • Triggers any configured workflows

  • Cannot be undone - create reverse movement to undo

Last updated

Was this helpful?