StockMovementService
StockMovementService
Contains methods relating to StockMovement entities.
Signature
class StockMovementService {
shippingEligibilityCheckers: ShippingEligibilityChecker[];
shippingCalculators: ShippingCalculator[];
constructor(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, stockLevelService: StockLevelService, eventBus: EventBus, stockLocationService: StockLocationService, configService: ConfigService)
getStockMovementsByProductVariantId(ctx: RequestContext, productVariantId: ID, options: StockMovementListOptions) => Promise<PaginatedList<StockMovement>>;
async adjustProductVariantStock(ctx: RequestContext, productVariantId: ID, stockOnHandNumberOrInput: number | StockLevelInput[]) => Promise<StockAdjustment[]>;
async createAllocationsForOrder(ctx: RequestContext, order: Order) => Promise<Allocation[]>;
async createAllocationsForOrderLines(ctx: RequestContext, lines: OrderLineInput[]) => Promise<Allocation[]>;
async createSalesForOrder(ctx: RequestContext, lines: OrderLineInput[]) => Promise<Sale[]>;
async createCancellationsForOrderLines(ctx: RequestContext, lineInputs: OrderLineInput[]) => Promise<Cancellation[]>;
async createReleasesForOrderLines(ctx: RequestContext, lineInputs: OrderLineInput[]) => Promise<Release[]>;
}
Members
shippingEligibilityCheckers
property
type:
ShippingEligibilityChecker[]
shippingCalculators
property
type:
ShippingCalculator[]
constructor
method
type:
(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, globalSettingsService: GlobalSettingsService, stockLevelService: StockLevelService, eventBus: EventBus, stockLocationService: StockLocationService, configService: ConfigService) => 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
method
type:
(ctx: RequestContext, productVariantId: ID, stockOnHandNumberOrInput: number | StockLevelInput[]) => Promise<StockAdjustment[]>
Adjusts the stock level of the ProductVariant, creating a new StockAdjustment entity
in the process.
createAllocationsForOrder
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
method
type:
(ctx: RequestContext, lines: OrderLineInput[]) => 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
method
type:
(ctx: RequestContext, lines: OrderLineInput[]) => 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 by the OrderLine quantity, indicating
that the stock is no longer allocated, but is actually sold and no longer available.
createCancellationsForOrderLines
method
type:
(ctx: RequestContext, lineInputs: OrderLineInput[]) => 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.
createReleasesForOrderLines
method
type:
(ctx: RequestContext, lineInputs: OrderLineInput[]) => 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.