Skip to main content

StockMovement

StockMovement

A StockMovement is created whenever stock of a particular ProductVariant goes in or out.

Signature
class StockMovement extends VendureEntity {
@Column({ nullable: false, type: 'varchar' })
readonly type: StockMovementType;
@Index()
@ManyToOne(type => ProductVariant, variant => variant.stockMovements)
productVariant: ProductVariant;
@Index()
@ManyToOne(type => StockLocation, stockLocation => stockLocation.stockMovements, { onDelete: 'CASCADE' })
stockLocation: StockLocation;
@EntityId()
stockLocationId: ID;
@Column()
quantity: number;
}

type

property
StockMovementType

productVariant

stockLocation

stockLocationId

property

quantity

property
number

Allocation

An Allocation is created for each ProductVariant in an Order when the checkout is completed (as configured by the StockAllocationStrategy. This prevents stock being sold twice.

Signature
class Allocation extends StockMovement {
readonly type = StockMovementType.ALLOCATION;
constructor(input: DeepPartial<Allocation>)
@Index()
@ManyToOne(type => OrderLine, orderLine => orderLine.allocations)
orderLine: OrderLine;
}

type

property

constructor

method
(input: DeepPartial<Allocation>) => Allocation

orderLine

property

Cancellation

A Cancellation is created when OrderItems from a fulfilled Order are cancelled.

Signature
class Cancellation extends StockMovement {
readonly type = StockMovementType.CANCELLATION;
constructor(input: DeepPartial<Cancellation>)
@ManyToOne(type => OrderLine, orderLine => orderLine.cancellations)
orderLine: OrderLine;
}

type

property

constructor

method
(input: DeepPartial<Cancellation>) => Cancellation

orderLine

property

Release

A Release is created when OrderItems which have been allocated (but not yet fulfilled) are cancelled.

Signature
class Release extends StockMovement {
readonly type = StockMovementType.RELEASE;
constructor(input: DeepPartial<Release>)
@ManyToOne(type => OrderLine)
orderLine: OrderLine;
}

type

property

constructor

method
(input: DeepPartial<Release>) => Release

orderLine

property

Sale

A Sale is created when OrderItems are fulfilled.

Signature
class Sale extends StockMovement {
readonly type = StockMovementType.SALE;
constructor(input: DeepPartial<Sale>)
@ManyToOne(type => OrderLine, line => line.sales)
orderLine: OrderLine;
}

type

property

constructor

method
(input: DeepPartial<Sale>) => Sale

orderLine

property

StockAdjustment

A StockAdjustment is created when the stockOnHand level of a ProductVariant is manually adjusted.

Signature
class StockAdjustment extends StockMovement {
readonly type = StockMovementType.ADJUSTMENT;
constructor(input: DeepPartial<StockAdjustment>)
}

type

property

constructor

method
(input: DeepPartial<StockAdjustment>) => StockAdjustment