feat(utils,types): add registerUsages for promotions + computeActions consider usage (#6094)

RESOLVES CORE-1639
RESOLVES CORE-1640
RESOLVES CORE-1634
This commit is contained in:
Riqwan Thamir
2024-01-16 20:06:06 +00:00
committed by GitHub
parent 90328ca02b
commit 68ddd866a5
15 changed files with 943 additions and 54 deletions
@@ -5,8 +5,8 @@ export type CampaignBudgetTypeValues = "spend" | "usage"
export interface CampaignBudgetDTO {
id: string
type?: CampaignBudgetTypeValues
limit?: string | null
used?: string
limit?: number | null
used?: number
}
export interface FilterableCampaignBudgetProps
@@ -3,6 +3,16 @@ export type ComputeActions =
| RemoveItemAdjustmentAction
| AddShippingMethodAdjustment
| RemoveShippingMethodAdjustment
| CampaignBudgetExceededAction
export type UsageComputedActions =
| AddShippingMethodAdjustment
| AddItemAdjustmentAction
export interface CampaignBudgetExceededAction {
action: "campaignBudgetExceeded"
code: string
}
export interface AddItemAdjustmentAction {
action: "addItemAdjustment"
@@ -16,6 +26,7 @@ export interface RemoveItemAdjustmentAction {
action: "removeItemAdjustment"
adjustment_id: string
description?: string
code: string
}
export interface AddShippingMethodAdjustment {
@@ -29,6 +40,7 @@ export interface AddShippingMethodAdjustment {
export interface RemoveShippingMethodAdjustment {
action: "removeShippingMethodAdjustment"
adjustment_id: string
code: string
}
export interface ComputeActionAdjustmentLine extends Record<string, unknown> {
@@ -5,6 +5,7 @@ import {
CreateApplicationMethodDTO,
UpdateApplicationMethodDTO,
} from "./application-method"
import { CampaignDTO } from "./campaign"
import { CreatePromotionRuleDTO, PromotionRuleDTO } from "./promotion-rule"
export type PromotionType = "standard" | "buyget"
@@ -16,6 +17,7 @@ export interface PromotionDTO {
is_automatic?: boolean
application_method?: ApplicationMethodDTO
rules?: PromotionRuleDTO[]
campaign?: CampaignDTO
}
export interface CreatePromotionDTO {
+2
View File
@@ -17,6 +17,8 @@ import {
import { CreateCampaignDTO, UpdateCampaignDTO } from "./mutations"
export interface IPromotionModuleService extends IModuleService {
registerUsage(computedActions: ComputeActions[]): Promise<void>
computeActions(
promotionCodesToApply: string[],
applicationContext: ComputeActionContext,