feat(utils,types): added item/shipping adjustments for order/items/shipping_methods (#6050)
what: - adds compute actions for the following cases: - items => each & across - shipping_method => each & across - order - adds a remove compute actions when code is no longer present in adjustments array RESOLVES CORE-1625 RESOLVES CORE-1626 RESOLVES CORE-1627 RESOLVES CORE-1628 RESOLVES CORE-1585
This commit is contained in:
1 parent
192bc336cc
commit
b782d3bcb7
24 files changed
+2638
-81
No files matched your search
@@ -3,7 +3,10 @@ import { PromotionDTO } from "./promotion"
|
||||
import { CreatePromotionRuleDTO, PromotionRuleDTO } from "./promotion-rule"
|
||||
|
||||
export type ApplicationMethodTypeValues = "fixed" | "percentage"
|
||||
export type ApplicationMethodTargetTypeValues = "order" | "shipping" | "item"
|
||||
export type ApplicationMethodTargetTypeValues =
|
||||
| "order"
|
||||
| "shipping_methods"
|
||||
| "items"
|
||||
export type ApplicationMethodAllocationValues = "each" | "across"
|
||||
|
||||
export interface ApplicationMethodDTO {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
export type ComputeActions =
|
||||
| AddItemAdjustmentAction
|
||||
| RemoveItemAdjustmentAction
|
||||
| AddShippingMethodAdjustment
|
||||
| RemoveShippingMethodAdjustment
|
||||
|
||||
export interface AddItemAdjustmentAction {
|
||||
action: "addItemAdjustment"
|
||||
item_id: string
|
||||
amount: number
|
||||
code: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface RemoveItemAdjustmentAction {
|
||||
action: "removeItemAdjustment"
|
||||
adjustment_id: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface AddShippingMethodAdjustment {
|
||||
action: "addShippingMethodAdjustment"
|
||||
shipping_method_id: string
|
||||
amount: number
|
||||
code: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface RemoveShippingMethodAdjustment {
|
||||
action: "removeShippingMethodAdjustment"
|
||||
adjustment_id: string
|
||||
}
|
||||
|
||||
export interface ComputeActionAdjustmentLine {
|
||||
id: string
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface ComputeActionItemLine {
|
||||
id: string
|
||||
quantity: number
|
||||
unit_price: number
|
||||
adjustments?: ComputeActionAdjustmentLine[]
|
||||
}
|
||||
|
||||
export interface ComputeActionShippingLine {
|
||||
id: string
|
||||
unit_price: number
|
||||
adjustments?: ComputeActionAdjustmentLine[]
|
||||
}
|
||||
|
||||
export interface ComputeActionContext {
|
||||
items?: ComputeActionItemLine[]
|
||||
shipping_methods?: ComputeActionShippingLine[]
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./application-method"
|
||||
export * from "./compute-actions"
|
||||
export * from "./promotion"
|
||||
export * from "./promotion-rule"
|
||||
export * from "./promotion-rule-value"
|
||||
@@ -3,10 +3,11 @@ import { PromotionRuleDTO } from "./promotion-rule"
|
||||
|
||||
export interface PromotionRuleValueDTO {
|
||||
id: string
|
||||
value?: string
|
||||
}
|
||||
|
||||
export interface CreatePromotionRuleValueDTO {
|
||||
value: any
|
||||
value: string
|
||||
promotion_rule: PromotionRuleDTO
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { PromotionRuleValueDTO } from "./promotion-rule-value"
|
||||
|
||||
export type PromotionRuleOperatorValues =
|
||||
| "gt"
|
||||
@@ -11,10 +12,14 @@ export type PromotionRuleOperatorValues =
|
||||
|
||||
export interface PromotionRuleDTO {
|
||||
id: string
|
||||
description?: string | null
|
||||
attribute?: string
|
||||
operator?: PromotionRuleOperatorValues
|
||||
values: PromotionRuleValueDTO[]
|
||||
}
|
||||
|
||||
export interface CreatePromotionRuleDTO {
|
||||
description?: string
|
||||
description?: string | null
|
||||
attribute: string
|
||||
operator: PromotionRuleOperatorValues
|
||||
values: string[] | string
|
||||
@@ -31,4 +36,5 @@ export interface RemovePromotionRuleDTO {
|
||||
export interface FilterablePromotionRuleProps
|
||||
extends BaseFilterable<FilterablePromotionRuleProps> {
|
||||
id?: string[]
|
||||
code?: string[]
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
CreateApplicationMethodDTO,
|
||||
UpdateApplicationMethodDTO,
|
||||
} from "./application-method"
|
||||
import { CreatePromotionRuleDTO } from "./promotion-rule"
|
||||
import { CreatePromotionRuleDTO, PromotionRuleDTO } from "./promotion-rule"
|
||||
|
||||
export type PromotionType = "standard" | "buyget"
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface PromotionDTO {
|
||||
type?: PromotionType
|
||||
is_automatic?: boolean
|
||||
application_method?: ApplicationMethodDTO
|
||||
rules?: PromotionRuleDTO[]
|
||||
}
|
||||
|
||||
export interface CreatePromotionDTO {
|
||||
|
||||
@@ -2,6 +2,8 @@ import { FindConfig } from "../common"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import {
|
||||
ComputeActionContext,
|
||||
ComputeActions,
|
||||
CreatePromotionDTO,
|
||||
CreatePromotionRuleDTO,
|
||||
FilterablePromotionProps,
|
||||
@@ -11,6 +13,12 @@ import {
|
||||
} from "./common"
|
||||
|
||||
export interface IPromotionModuleService extends IModuleService {
|
||||
computeActions(
|
||||
promotionCodesToApply: string[],
|
||||
applicationContext: ComputeActionContext,
|
||||
options?: Record<string, any>
|
||||
): Promise<ComputeActions[]>
|
||||
|
||||
create(
|
||||
data: CreatePromotionDTO[],
|
||||
sharedContext?: Context
|
||||
|
||||
Reference in new issue
Block a user