feat(types,utils): add promotions create with application method (#5945)

What:

- Promotions can be created with its bare attributes
- Promotions one to one relationship with ApplicationMethod can be created with its attributes + validation

RESOLVES CORE-1592
RESOLVES CORE-1595
This commit is contained in:
Riqwan Thamir
2023-12-21 11:04:50 +00:00
committed by GitHub
parent c41f3002f3
commit 890e76a5c5
38 changed files with 1497 additions and 55 deletions
@@ -0,0 +1,31 @@
import { BaseFilterable } from "../../dal"
import { PromotionDTO } from "./promotion"
export type ApplicationMethodType = "fixed" | "percentage"
export type ApplicationMethodTargetType = "order" | "shipping" | "item"
export type ApplicationMethodAllocation = "each" | "across"
export interface ApplicationMethodDTO {
id: string
}
export interface CreateApplicationMethodDTO {
type: ApplicationMethodType
target_type: ApplicationMethodTargetType
allocation?: ApplicationMethodAllocation
value?: number
max_quantity?: number
promotion?: PromotionDTO | string
}
export interface UpdateApplicationMethodDTO {
id: string
}
export interface FilterableApplicationMethodProps
extends BaseFilterable<FilterableApplicationMethodProps> {
id?: string[]
type?: ApplicationMethodType[]
target_type?: ApplicationMethodTargetType[]
allocation?: ApplicationMethodAllocation[]
}
@@ -0,0 +1,2 @@
export * from "./application-method"
export * from "./promotion"
@@ -0,0 +1,27 @@
import { BaseFilterable } from "../../dal"
import { CreateApplicationMethodDTO } from "./application-method"
export type PromotionType = "standard" | "buyget"
export interface PromotionDTO {
id: string
}
export interface CreatePromotionDTO {
code: string
type: PromotionType
is_automatic?: boolean
application_method?: CreateApplicationMethodDTO
}
export interface UpdatePromotionDTO {
id: string
}
export interface FilterablePromotionProps
extends BaseFilterable<FilterablePromotionProps> {
id?: string[]
code?: string[]
is_automatic?: boolean
type?: PromotionType[]
}
+1
View File
@@ -1 +1,2 @@
export * from "./common"
export * from "./service"
+19 -1
View File
@@ -1,3 +1,21 @@
import { FindConfig } from "../common"
import { IModuleService } from "../modules-sdk"
import { Context } from "../shared-context"
import {
CreatePromotionDTO,
FilterablePromotionProps,
PromotionDTO,
} from "./common"
export interface IPromotionModuleService extends IModuleService {}
export interface IPromotionModuleService extends IModuleService {
create(
data: CreatePromotionDTO[],
sharedContext?: Context
): Promise<PromotionDTO[]>
list(
filters?: FilterablePromotionProps,
config?: FindConfig<PromotionDTO>,
sharedContext?: Context
): Promise<PromotionDTO[]>
}
+1
View File
@@ -4,6 +4,7 @@
"target": "es2020",
"outDir": "./dist",
"esModuleInterop": true,
"declarationMap": true,
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",