feat(types,utils): added promotion create with rules and application target rules (#5957)

* feat(types,utils): added promotion create with rules

* chore: add rules to promotion and application method

* chore: use common code for rule and values

* chore: address pr reviews

* chore: fix test
This commit is contained in:
Riqwan Thamir
2024-01-03 09:54:48 +01:00
committed by GitHub
parent d16d10619d
commit 42cc8ae3f8
33 changed files with 1560 additions and 122 deletions
@@ -1,5 +1,6 @@
import { BaseFilterable } from "../../dal"
import { PromotionDTO } from "./promotion"
import { CreatePromotionRuleDTO } from "./promotion-rule"
export type ApplicationMethodType = "fixed" | "percentage"
export type ApplicationMethodTargetType = "order" | "shipping" | "item"
@@ -16,6 +17,7 @@ export interface CreateApplicationMethodDTO {
value?: number
max_quantity?: number
promotion?: PromotionDTO | string
target_rules?: CreatePromotionRuleDTO[]
}
export interface UpdateApplicationMethodDTO {
@@ -1,2 +1,4 @@
export * from "./application-method"
export * from "./promotion"
export * from "./promotion-rule"
export * from "./promotion-rule-value"
@@ -0,0 +1,20 @@
import { BaseFilterable } from "../../dal"
import { PromotionRuleDTO } from "./promotion-rule"
export interface PromotionRuleValueDTO {
id: string
}
export interface CreatePromotionRuleValueDTO {
value: any
promotion_rule: PromotionRuleDTO
}
export interface UpdatePromotionRuleValueDTO {
id: string
}
export interface FilterablePromotionRuleValueProps
extends BaseFilterable<FilterablePromotionRuleValueProps> {
id?: string[]
}
@@ -0,0 +1,30 @@
import { BaseFilterable } from "../../dal"
export type PromotionRuleOperatorValues =
| "gt"
| "lt"
| "eq"
| "ne"
| "in"
| "lte"
| "gte"
export interface PromotionRuleDTO {
id: string
}
export interface CreatePromotionRuleDTO {
description?: string
attribute: string
operator: PromotionRuleOperatorValues
values: string[] | string
}
export interface UpdatePromotionRuleDTO {
id: string
}
export interface FilterablePromotionRuleProps
extends BaseFilterable<FilterablePromotionRuleProps> {
id?: string[]
}
@@ -1,5 +1,6 @@
import { BaseFilterable } from "../../dal"
import { CreateApplicationMethodDTO } from "./application-method"
import { CreatePromotionRuleDTO } from "./promotion-rule"
export type PromotionType = "standard" | "buyget"
@@ -12,6 +13,7 @@ export interface CreatePromotionDTO {
type: PromotionType
is_automatic?: boolean
application_method?: CreateApplicationMethodDTO
rules?: CreatePromotionRuleDTO[]
}
export interface UpdatePromotionDTO {