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
ShippingEligibilityChecker[]
shippingCalculators
ShippingCalculator[]
constructor
(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, eventBus: EventBus) => StockMovementService
getStockMovementsByProductVariantId
(ctx: RequestContext, productVariantId: ID, options: StockMovementListOptions) => Promise<PaginatedList<StockMovement>>
adjustProductVariantStock
(ctx: RequestContext, productVariantId: ID, oldStockLevel: number, newStockLevel: number) => Promise<StockAdjustment | undefined>
createAllocationsForOrder
(ctx: RequestContext, order: Order) => Promise<Allocation[]>
ProductVariant.stockAllocated
value is
increased, indicating that this quantity of stock is allocated and cannot be sold.
createAllocationsForOrderLines
(ctx: RequestContext, lines: Array<{ orderLine: OrderLine; quantity: number }>) => Promise<Allocation[]>
ProductVariant.stockAllocated
value is
increased, indicating that this quantity of stock is allocated and cannot be sold.
createSalesForOrder
(ctx: RequestContext, orderItems: OrderItem[]) => Promise<Sale[]>
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
(ctx: RequestContext, items: OrderItem[]) => Promise<Cancellation[]>
ProductVariant.stockOnHand
value is
increased for each Cancellation, allowing that stock to be sold again.
createReleasesForOrderItems
(ctx: RequestContext, items: OrderItem[]) => Promise<Release[]>
ProductVariant.stockAllocated
value is
reduced, indicating that this stock is once again available to buy.