StockLevelService
The StockLevelService is responsible for managing the stock levels of ProductVariants.
Whenever you need to adjust the stockOnHand or stockAllocated for a ProductVariant,
you should use this service.
constructor
method
(connection: TransactionalConnection, stockLocationService: StockLocationService, configService: ConfigService) => StockLevelServicegetStockLevel
method
(ctx: RequestContext, productVariantId: ID, stockLocationId: ID) => Promise<StockLevel>Returns the StockLevel for the given ProductVariant and StockLocation.
getStockLevelsForVariant
method
(ctx: RequestContext, productVariantId: ID) => Promise<StockLevel[]>getAvailableStock
method
(ctx: RequestContext, productVariantId: ID) => Promise<AvailableStock>Returns the available stock (on hand and allocated) for the given ProductVariant. This is determined by the configured StockLocationStrategy.
updateStockOnHandForLocation
method
(ctx: RequestContext, productVariantId: ID, stockLocationId: ID, change: number) => Updates the stockOnHand for the given ProductVariant and StockLocation.
updateStockAllocatedForLocation
method
(ctx: RequestContext, productVariantId: ID, stockLocationId: ID, change: number) => Updates the stockAllocated for the given ProductVariant and StockLocation.
Was this chapter helpful?