🚨 Announcing Vendure v2 Beta

StockMovementService

StockMovementService

Contains methods relating to StockMovement entities.

Signature

class StockMovementService {
  shippingEligibilityCheckers: ShippingEligibilityChecker[];
  shippingCalculators: ShippingCalculator[];
  constructor(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, eventBus: EventBus)
  getStockMovementsByProductVariantId(ctx: RequestContext, productVariantId: ID, options: StockMovementListOptions) => Promise<PaginatedList<StockMovement>>;
  async adjustProductVariantStock(ctx: RequestContext, productVariantId: ID, oldStockLevel: number, newStockLevel: number) => Promise<StockAdjustment | undefined>;
  async createAllocationsForOrder(ctx: RequestContext, order: Order) => Promise<Allocation[]>;
  async createAllocationsForOrderLines(ctx: RequestContext, lines: Array<{ orderLine: OrderLine; quantity: number }>) => Promise<Allocation[]>;
  async createSalesForOrder(ctx: RequestContext, orderItems: OrderItem[]) => Promise<Sale[]>;
  async createCancellationsForOrderItems(ctx: RequestContext, items: OrderItem[]) => Promise<Cancellation[]>;
  async createReleasesForOrderItems(ctx: RequestContext, items: OrderItem[]) => Promise<Release[]>;
}

Members

shippingEligibilityCheckers

property

shippingCalculators

property

constructor

method
type:
(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, eventBus: EventBus) => StockMovementService

getStockMovementsByProductVariantId

method
type:
(ctx: RequestContext, productVariantId: ID, options: StockMovementListOptions) => Promise<PaginatedList<StockMovement>>
Returns a PaginatedList of all StockMovements associated with the specified ProductVariant.

adjustProductVariantStock

async method
type:
(ctx: RequestContext, productVariantId: ID, oldStockLevel: number, newStockLevel: number) => Promise<StockAdjustment | undefined>
Adjusts the stock level of the ProductVariant, creating a new StockAdjustment entity in the process.

createAllocationsForOrder

async method
type:
(ctx: RequestContext, order: Order) => Promise<Allocation[]>
Creates a new Allocation for each OrderLine in the Order. For ProductVariants which are configured to track stock levels, the ProductVariant.stockAllocated value is increased, indicating that this quantity of stock is allocated and cannot be sold.

createAllocationsForOrderLines

async method
type:
(ctx: RequestContext, lines: Array<{ orderLine: OrderLine; quantity: number }>) => Promise<Allocation[]>
Creates a new Allocation for each of the given OrderLines. For ProductVariants which are configured to track stock levels, the ProductVariant.stockAllocated value is increased, indicating that this quantity of stock is allocated and cannot be sold.

createSalesForOrder

async method
type:
(ctx: RequestContext, orderItems: OrderItem[]) => Promise<Sale[]>
Creates Sales for each OrderLine in the Order. For ProductVariants which are configured to track stock levels, the ProductVariant.stockAllocated value is reduced and the stockOnHand value is also reduced the the OrderLine quantity, indicating that the stock is no longer allocated, but is actually sold and no longer available.

createCancellationsForOrderItems

async method
type:
(ctx: RequestContext, items: OrderItem[]) => Promise<Cancellation[]>
Creates a Cancellation for each of the specified OrderItems. For ProductVariants which are configured to track stock levels, the ProductVariant.stockOnHand value is increased for each Cancellation, allowing that stock to be sold again.

createReleasesForOrderItems

async method
type:
(ctx: RequestContext, items: OrderItem[]) => Promise<Release[]>
Creates a Release for each of the specified OrderItems. For ProductVariants which are configured to track stock levels, the ProductVariant.stockAllocated value is reduced, indicating that this stock is once again available to buy.