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:
@@ -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 +1,2 @@
|
||||
export * from "./common"
|
||||
export * from "./service"
|
||||
|
||||
@@ -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[]>
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"target": "es2020",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"declarationMap": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
|
||||
Reference in New Issue
Block a user