@voyantjs/pricing 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes-core.d.ts +981 -0
- package/dist/routes-core.d.ts.map +1 -0
- package/dist/routes-core.js +101 -0
- package/dist/routes-rules.d.ts +1176 -0
- package/dist/routes-rules.d.ts.map +1 -0
- package/dist/routes-rules.js +117 -0
- package/dist/routes-shared.d.ts +12 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +3 -0
- package/dist/routes.d.ts +3 -2160
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +5 -354
- package/dist/schema-catalogs.d.ts +467 -0
- package/dist/schema-catalogs.d.ts.map +1 -0
- package/dist/schema-catalogs.js +44 -0
- package/dist/schema-categories.d.ts +497 -0
- package/dist/schema-categories.d.ts.map +1 -0
- package/dist/schema-categories.js +50 -0
- package/dist/schema-option-rules.d.ts +1770 -0
- package/dist/schema-option-rules.d.ts.map +1 -0
- package/dist/schema-option-rules.js +174 -0
- package/dist/schema-policies.d.ts +395 -0
- package/dist/schema-policies.d.ts.map +1 -0
- package/dist/schema-policies.js +38 -0
- package/dist/schema-relations.d.ts +55 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +103 -0
- package/dist/schema-shared.d.ts +11 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +67 -0
- package/dist/schema.d.ts +6 -3189
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -458
- package/dist/service-catalogs.d.ts +139 -0
- package/dist/service-catalogs.d.ts.map +1 -0
- package/dist/service-catalogs.js +89 -0
- package/dist/service-categories.d.ts +147 -0
- package/dist/service-categories.d.ts.map +1 -0
- package/dist/service-categories.js +105 -0
- package/dist/service-option-rules.d.ts +307 -0
- package/dist/service-option-rules.d.ts.map +1 -0
- package/dist/service-option-rules.js +188 -0
- package/dist/service-policies.d.ts +123 -0
- package/dist/service-policies.d.ts.map +1 -0
- package/dist/service-policies.js +95 -0
- package/dist/service-shared.d.ts +50 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +4 -0
- package/dist/service-transfer-rules.d.ts +211 -0
- package/dist/service-transfer-rules.d.ts.map +1 -0
- package/dist/service-transfer-rules.js +139 -0
- package/dist/service.d.ts +70 -955
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +70 -595
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -0
- package/package.json +8 -8
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { and, asc, desc, eq, ilike, or, sql } from "drizzle-orm";
|
|
2
|
+
import { priceCatalogs, priceSchedules } from "./schema.js";
|
|
3
|
+
import { paginate } from "./service-shared.js";
|
|
4
|
+
export async function listPriceCatalogs(db, query) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (query.currencyCode)
|
|
7
|
+
conditions.push(eq(priceCatalogs.currencyCode, query.currencyCode));
|
|
8
|
+
if (query.catalogType)
|
|
9
|
+
conditions.push(eq(priceCatalogs.catalogType, query.catalogType));
|
|
10
|
+
if (query.active !== undefined)
|
|
11
|
+
conditions.push(eq(priceCatalogs.active, query.active));
|
|
12
|
+
if (query.search) {
|
|
13
|
+
const term = `%${query.search}%`;
|
|
14
|
+
conditions.push(or(ilike(priceCatalogs.name, term), ilike(priceCatalogs.code, term)));
|
|
15
|
+
}
|
|
16
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
17
|
+
return paginate(db
|
|
18
|
+
.select()
|
|
19
|
+
.from(priceCatalogs)
|
|
20
|
+
.where(where)
|
|
21
|
+
.limit(query.limit)
|
|
22
|
+
.offset(query.offset)
|
|
23
|
+
.orderBy(asc(priceCatalogs.name)), db.select({ count: sql `count(*)::int` }).from(priceCatalogs).where(where), query.limit, query.offset);
|
|
24
|
+
}
|
|
25
|
+
export async function getPriceCatalogById(db, id) {
|
|
26
|
+
const [row] = await db.select().from(priceCatalogs).where(eq(priceCatalogs.id, id)).limit(1);
|
|
27
|
+
return row ?? null;
|
|
28
|
+
}
|
|
29
|
+
export async function createPriceCatalog(db, data) {
|
|
30
|
+
const [row] = await db.insert(priceCatalogs).values(data).returning();
|
|
31
|
+
return row ?? null;
|
|
32
|
+
}
|
|
33
|
+
export async function updatePriceCatalog(db, id, data) {
|
|
34
|
+
const [row] = await db
|
|
35
|
+
.update(priceCatalogs)
|
|
36
|
+
.set({ ...data, updatedAt: new Date() })
|
|
37
|
+
.where(eq(priceCatalogs.id, id))
|
|
38
|
+
.returning();
|
|
39
|
+
return row ?? null;
|
|
40
|
+
}
|
|
41
|
+
export async function deletePriceCatalog(db, id) {
|
|
42
|
+
const [row] = await db
|
|
43
|
+
.delete(priceCatalogs)
|
|
44
|
+
.where(eq(priceCatalogs.id, id))
|
|
45
|
+
.returning({ id: priceCatalogs.id });
|
|
46
|
+
return row ?? null;
|
|
47
|
+
}
|
|
48
|
+
export async function listPriceSchedules(db, query) {
|
|
49
|
+
const conditions = [];
|
|
50
|
+
if (query.priceCatalogId)
|
|
51
|
+
conditions.push(eq(priceSchedules.priceCatalogId, query.priceCatalogId));
|
|
52
|
+
if (query.active !== undefined)
|
|
53
|
+
conditions.push(eq(priceSchedules.active, query.active));
|
|
54
|
+
if (query.search) {
|
|
55
|
+
const term = `%${query.search}%`;
|
|
56
|
+
conditions.push(or(ilike(priceSchedules.name, term), ilike(priceSchedules.code, term)));
|
|
57
|
+
}
|
|
58
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
59
|
+
return paginate(db
|
|
60
|
+
.select()
|
|
61
|
+
.from(priceSchedules)
|
|
62
|
+
.where(where)
|
|
63
|
+
.limit(query.limit)
|
|
64
|
+
.offset(query.offset)
|
|
65
|
+
.orderBy(desc(priceSchedules.priority), asc(priceSchedules.name)), db.select({ count: sql `count(*)::int` }).from(priceSchedules).where(where), query.limit, query.offset);
|
|
66
|
+
}
|
|
67
|
+
export async function getPriceScheduleById(db, id) {
|
|
68
|
+
const [row] = await db.select().from(priceSchedules).where(eq(priceSchedules.id, id)).limit(1);
|
|
69
|
+
return row ?? null;
|
|
70
|
+
}
|
|
71
|
+
export async function createPriceSchedule(db, data) {
|
|
72
|
+
const [row] = await db.insert(priceSchedules).values(data).returning();
|
|
73
|
+
return row ?? null;
|
|
74
|
+
}
|
|
75
|
+
export async function updatePriceSchedule(db, id, data) {
|
|
76
|
+
const [row] = await db
|
|
77
|
+
.update(priceSchedules)
|
|
78
|
+
.set({ ...data, updatedAt: new Date() })
|
|
79
|
+
.where(eq(priceSchedules.id, id))
|
|
80
|
+
.returning();
|
|
81
|
+
return row ?? null;
|
|
82
|
+
}
|
|
83
|
+
export async function deletePriceSchedule(db, id) {
|
|
84
|
+
const [row] = await db
|
|
85
|
+
.delete(priceSchedules)
|
|
86
|
+
.where(eq(priceSchedules.id, id))
|
|
87
|
+
.returning({ id: priceSchedules.id });
|
|
88
|
+
return row ?? null;
|
|
89
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CreatePricingCategoryDependencyInput, CreatePricingCategoryInput, PricingCategoryDependencyListQuery, PricingCategoryListQuery, UpdatePricingCategoryDependencyInput, UpdatePricingCategoryInput } from "./service-shared.js";
|
|
3
|
+
export declare function listPricingCategories(db: PostgresJsDatabase, query: PricingCategoryListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
productId: string | null;
|
|
7
|
+
optionId: string | null;
|
|
8
|
+
unitId: string | null;
|
|
9
|
+
code: string | null;
|
|
10
|
+
name: string;
|
|
11
|
+
categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
|
|
12
|
+
seatOccupancy: number;
|
|
13
|
+
groupSize: number | null;
|
|
14
|
+
isAgeQualified: boolean;
|
|
15
|
+
minAge: number | null;
|
|
16
|
+
maxAge: number | null;
|
|
17
|
+
internalUseOnly: boolean;
|
|
18
|
+
active: boolean;
|
|
19
|
+
sortOrder: number;
|
|
20
|
+
metadata: Record<string, unknown> | null;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
}[];
|
|
24
|
+
total: number;
|
|
25
|
+
limit: number;
|
|
26
|
+
offset: number;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function getPricingCategoryById(db: PostgresJsDatabase, id: string): Promise<{
|
|
29
|
+
id: string;
|
|
30
|
+
productId: string | null;
|
|
31
|
+
optionId: string | null;
|
|
32
|
+
unitId: string | null;
|
|
33
|
+
code: string | null;
|
|
34
|
+
name: string;
|
|
35
|
+
categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
|
|
36
|
+
seatOccupancy: number;
|
|
37
|
+
groupSize: number | null;
|
|
38
|
+
isAgeQualified: boolean;
|
|
39
|
+
minAge: number | null;
|
|
40
|
+
maxAge: number | null;
|
|
41
|
+
internalUseOnly: boolean;
|
|
42
|
+
active: boolean;
|
|
43
|
+
sortOrder: number;
|
|
44
|
+
metadata: Record<string, unknown> | null;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
} | null>;
|
|
48
|
+
export declare function createPricingCategory(db: PostgresJsDatabase, data: CreatePricingCategoryInput): Promise<{
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
code: string | null;
|
|
52
|
+
active: boolean;
|
|
53
|
+
metadata: Record<string, unknown> | null;
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
updatedAt: Date;
|
|
56
|
+
productId: string | null;
|
|
57
|
+
optionId: string | null;
|
|
58
|
+
unitId: string | null;
|
|
59
|
+
categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
|
|
60
|
+
seatOccupancy: number;
|
|
61
|
+
groupSize: number | null;
|
|
62
|
+
isAgeQualified: boolean;
|
|
63
|
+
minAge: number | null;
|
|
64
|
+
maxAge: number | null;
|
|
65
|
+
internalUseOnly: boolean;
|
|
66
|
+
sortOrder: number;
|
|
67
|
+
} | null>;
|
|
68
|
+
export declare function updatePricingCategory(db: PostgresJsDatabase, id: string, data: UpdatePricingCategoryInput): Promise<{
|
|
69
|
+
id: string;
|
|
70
|
+
productId: string | null;
|
|
71
|
+
optionId: string | null;
|
|
72
|
+
unitId: string | null;
|
|
73
|
+
code: string | null;
|
|
74
|
+
name: string;
|
|
75
|
+
categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
|
|
76
|
+
seatOccupancy: number;
|
|
77
|
+
groupSize: number | null;
|
|
78
|
+
isAgeQualified: boolean;
|
|
79
|
+
minAge: number | null;
|
|
80
|
+
maxAge: number | null;
|
|
81
|
+
internalUseOnly: boolean;
|
|
82
|
+
active: boolean;
|
|
83
|
+
sortOrder: number;
|
|
84
|
+
metadata: Record<string, unknown> | null;
|
|
85
|
+
createdAt: Date;
|
|
86
|
+
updatedAt: Date;
|
|
87
|
+
} | null>;
|
|
88
|
+
export declare function deletePricingCategory(db: PostgresJsDatabase, id: string): Promise<{
|
|
89
|
+
id: string;
|
|
90
|
+
} | null>;
|
|
91
|
+
export declare function listPricingCategoryDependencies(db: PostgresJsDatabase, query: PricingCategoryDependencyListQuery): Promise<{
|
|
92
|
+
data: {
|
|
93
|
+
id: string;
|
|
94
|
+
pricingCategoryId: string;
|
|
95
|
+
masterPricingCategoryId: string;
|
|
96
|
+
dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
|
|
97
|
+
maxPerMaster: number | null;
|
|
98
|
+
maxDependentSum: number | null;
|
|
99
|
+
active: boolean;
|
|
100
|
+
notes: string | null;
|
|
101
|
+
createdAt: Date;
|
|
102
|
+
updatedAt: Date;
|
|
103
|
+
}[];
|
|
104
|
+
total: number;
|
|
105
|
+
limit: number;
|
|
106
|
+
offset: number;
|
|
107
|
+
}>;
|
|
108
|
+
export declare function getPricingCategoryDependencyById(db: PostgresJsDatabase, id: string): Promise<{
|
|
109
|
+
id: string;
|
|
110
|
+
pricingCategoryId: string;
|
|
111
|
+
masterPricingCategoryId: string;
|
|
112
|
+
dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
|
|
113
|
+
maxPerMaster: number | null;
|
|
114
|
+
maxDependentSum: number | null;
|
|
115
|
+
active: boolean;
|
|
116
|
+
notes: string | null;
|
|
117
|
+
createdAt: Date;
|
|
118
|
+
updatedAt: Date;
|
|
119
|
+
} | null>;
|
|
120
|
+
export declare function createPricingCategoryDependency(db: PostgresJsDatabase, data: CreatePricingCategoryDependencyInput): Promise<{
|
|
121
|
+
id: string;
|
|
122
|
+
active: boolean;
|
|
123
|
+
notes: string | null;
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
updatedAt: Date;
|
|
126
|
+
pricingCategoryId: string;
|
|
127
|
+
masterPricingCategoryId: string;
|
|
128
|
+
dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
|
|
129
|
+
maxPerMaster: number | null;
|
|
130
|
+
maxDependentSum: number | null;
|
|
131
|
+
} | null>;
|
|
132
|
+
export declare function updatePricingCategoryDependency(db: PostgresJsDatabase, id: string, data: UpdatePricingCategoryDependencyInput): Promise<{
|
|
133
|
+
id: string;
|
|
134
|
+
pricingCategoryId: string;
|
|
135
|
+
masterPricingCategoryId: string;
|
|
136
|
+
dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
|
|
137
|
+
maxPerMaster: number | null;
|
|
138
|
+
maxDependentSum: number | null;
|
|
139
|
+
active: boolean;
|
|
140
|
+
notes: string | null;
|
|
141
|
+
createdAt: Date;
|
|
142
|
+
updatedAt: Date;
|
|
143
|
+
} | null>;
|
|
144
|
+
export declare function deletePricingCategoryDependency(db: PostgresJsDatabase, id: string): Promise<{
|
|
145
|
+
id: string;
|
|
146
|
+
} | null>;
|
|
147
|
+
//# sourceMappingURL=service-categories.d.ts.map
|
|
@@ -0,0 +1 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,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMvF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { and, asc, eq, ilike, or, sql } from "drizzle-orm";
|
|
2
|
+
import { pricingCategories, pricingCategoryDependencies } from "./schema.js";
|
|
3
|
+
import { paginate } from "./service-shared.js";
|
|
4
|
+
export async function listPricingCategories(db, query) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (query.productId)
|
|
7
|
+
conditions.push(eq(pricingCategories.productId, query.productId));
|
|
8
|
+
if (query.optionId)
|
|
9
|
+
conditions.push(eq(pricingCategories.optionId, query.optionId));
|
|
10
|
+
if (query.unitId)
|
|
11
|
+
conditions.push(eq(pricingCategories.unitId, query.unitId));
|
|
12
|
+
if (query.categoryType)
|
|
13
|
+
conditions.push(eq(pricingCategories.categoryType, query.categoryType));
|
|
14
|
+
if (query.active !== undefined)
|
|
15
|
+
conditions.push(eq(pricingCategories.active, query.active));
|
|
16
|
+
if (query.search) {
|
|
17
|
+
const term = `%${query.search}%`;
|
|
18
|
+
conditions.push(or(ilike(pricingCategories.name, term), ilike(pricingCategories.code, term)));
|
|
19
|
+
}
|
|
20
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
21
|
+
return paginate(db
|
|
22
|
+
.select()
|
|
23
|
+
.from(pricingCategories)
|
|
24
|
+
.where(where)
|
|
25
|
+
.limit(query.limit)
|
|
26
|
+
.offset(query.offset)
|
|
27
|
+
.orderBy(asc(pricingCategories.sortOrder), asc(pricingCategories.name)), db.select({ count: sql `count(*)::int` }).from(pricingCategories).where(where), query.limit, query.offset);
|
|
28
|
+
}
|
|
29
|
+
export async function getPricingCategoryById(db, id) {
|
|
30
|
+
const [row] = await db
|
|
31
|
+
.select()
|
|
32
|
+
.from(pricingCategories)
|
|
33
|
+
.where(eq(pricingCategories.id, id))
|
|
34
|
+
.limit(1);
|
|
35
|
+
return row ?? null;
|
|
36
|
+
}
|
|
37
|
+
export async function createPricingCategory(db, data) {
|
|
38
|
+
const [row] = await db.insert(pricingCategories).values(data).returning();
|
|
39
|
+
return row ?? null;
|
|
40
|
+
}
|
|
41
|
+
export async function updatePricingCategory(db, id, data) {
|
|
42
|
+
const [row] = await db
|
|
43
|
+
.update(pricingCategories)
|
|
44
|
+
.set({ ...data, updatedAt: new Date() })
|
|
45
|
+
.where(eq(pricingCategories.id, id))
|
|
46
|
+
.returning();
|
|
47
|
+
return row ?? null;
|
|
48
|
+
}
|
|
49
|
+
export async function deletePricingCategory(db, id) {
|
|
50
|
+
const [row] = await db
|
|
51
|
+
.delete(pricingCategories)
|
|
52
|
+
.where(eq(pricingCategories.id, id))
|
|
53
|
+
.returning({ id: pricingCategories.id });
|
|
54
|
+
return row ?? null;
|
|
55
|
+
}
|
|
56
|
+
export async function listPricingCategoryDependencies(db, query) {
|
|
57
|
+
const conditions = [];
|
|
58
|
+
if (query.pricingCategoryId) {
|
|
59
|
+
conditions.push(eq(pricingCategoryDependencies.pricingCategoryId, query.pricingCategoryId));
|
|
60
|
+
}
|
|
61
|
+
if (query.masterPricingCategoryId) {
|
|
62
|
+
conditions.push(eq(pricingCategoryDependencies.masterPricingCategoryId, query.masterPricingCategoryId));
|
|
63
|
+
}
|
|
64
|
+
if (query.dependencyType) {
|
|
65
|
+
conditions.push(eq(pricingCategoryDependencies.dependencyType, query.dependencyType));
|
|
66
|
+
}
|
|
67
|
+
if (query.active !== undefined) {
|
|
68
|
+
conditions.push(eq(pricingCategoryDependencies.active, query.active));
|
|
69
|
+
}
|
|
70
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
71
|
+
return paginate(db
|
|
72
|
+
.select()
|
|
73
|
+
.from(pricingCategoryDependencies)
|
|
74
|
+
.where(where)
|
|
75
|
+
.limit(query.limit)
|
|
76
|
+
.offset(query.offset)
|
|
77
|
+
.orderBy(asc(pricingCategoryDependencies.createdAt)), db.select({ count: sql `count(*)::int` }).from(pricingCategoryDependencies).where(where), query.limit, query.offset);
|
|
78
|
+
}
|
|
79
|
+
export async function getPricingCategoryDependencyById(db, id) {
|
|
80
|
+
const [row] = await db
|
|
81
|
+
.select()
|
|
82
|
+
.from(pricingCategoryDependencies)
|
|
83
|
+
.where(eq(pricingCategoryDependencies.id, id))
|
|
84
|
+
.limit(1);
|
|
85
|
+
return row ?? null;
|
|
86
|
+
}
|
|
87
|
+
export async function createPricingCategoryDependency(db, data) {
|
|
88
|
+
const [row] = await db.insert(pricingCategoryDependencies).values(data).returning();
|
|
89
|
+
return row ?? null;
|
|
90
|
+
}
|
|
91
|
+
export async function updatePricingCategoryDependency(db, id, data) {
|
|
92
|
+
const [row] = await db
|
|
93
|
+
.update(pricingCategoryDependencies)
|
|
94
|
+
.set({ ...data, updatedAt: new Date() })
|
|
95
|
+
.where(eq(pricingCategoryDependencies.id, id))
|
|
96
|
+
.returning();
|
|
97
|
+
return row ?? null;
|
|
98
|
+
}
|
|
99
|
+
export async function deletePricingCategoryDependency(db, id) {
|
|
100
|
+
const [row] = await db
|
|
101
|
+
.delete(pricingCategoryDependencies)
|
|
102
|
+
.where(eq(pricingCategoryDependencies.id, id))
|
|
103
|
+
.returning({ id: pricingCategoryDependencies.id });
|
|
104
|
+
return row ?? null;
|
|
105
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CreateOptionPriceRuleInput, CreateOptionStartTimeRuleInput, CreateOptionUnitPriceRuleInput, CreateOptionUnitTierInput, OptionPriceRuleListQuery, OptionStartTimeRuleListQuery, OptionUnitPriceRuleListQuery, OptionUnitTierListQuery, UpdateOptionPriceRuleInput, UpdateOptionStartTimeRuleInput, UpdateOptionUnitPriceRuleInput, UpdateOptionUnitTierInput } from "./service-shared.js";
|
|
3
|
+
export declare function listOptionPriceRules(db: PostgresJsDatabase, query: OptionPriceRuleListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
productId: string;
|
|
7
|
+
optionId: string;
|
|
8
|
+
priceCatalogId: string;
|
|
9
|
+
priceScheduleId: string | null;
|
|
10
|
+
cancellationPolicyId: string | null;
|
|
11
|
+
code: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
|
|
15
|
+
baseSellAmountCents: number | null;
|
|
16
|
+
baseCostAmountCents: number | null;
|
|
17
|
+
minPerBooking: number | null;
|
|
18
|
+
maxPerBooking: number | null;
|
|
19
|
+
allPricingCategories: boolean;
|
|
20
|
+
isDefault: boolean;
|
|
21
|
+
active: boolean;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
metadata: Record<string, unknown> | null;
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
updatedAt: Date;
|
|
26
|
+
}[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function getOptionPriceRuleById(db: PostgresJsDatabase, id: string): Promise<{
|
|
32
|
+
id: string;
|
|
33
|
+
productId: string;
|
|
34
|
+
optionId: string;
|
|
35
|
+
priceCatalogId: string;
|
|
36
|
+
priceScheduleId: string | null;
|
|
37
|
+
cancellationPolicyId: string | null;
|
|
38
|
+
code: string | null;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
|
|
42
|
+
baseSellAmountCents: number | null;
|
|
43
|
+
baseCostAmountCents: number | null;
|
|
44
|
+
minPerBooking: number | null;
|
|
45
|
+
maxPerBooking: number | null;
|
|
46
|
+
allPricingCategories: boolean;
|
|
47
|
+
isDefault: boolean;
|
|
48
|
+
active: boolean;
|
|
49
|
+
notes: string | null;
|
|
50
|
+
metadata: Record<string, unknown> | null;
|
|
51
|
+
createdAt: Date;
|
|
52
|
+
updatedAt: Date;
|
|
53
|
+
} | null>;
|
|
54
|
+
export declare function createOptionPriceRule(db: PostgresJsDatabase, data: CreateOptionPriceRuleInput): Promise<{
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
code: string | null;
|
|
58
|
+
isDefault: boolean;
|
|
59
|
+
active: boolean;
|
|
60
|
+
notes: string | null;
|
|
61
|
+
metadata: Record<string, unknown> | null;
|
|
62
|
+
createdAt: Date;
|
|
63
|
+
updatedAt: Date;
|
|
64
|
+
priceCatalogId: string;
|
|
65
|
+
productId: string;
|
|
66
|
+
optionId: string;
|
|
67
|
+
cancellationPolicyId: string | null;
|
|
68
|
+
priceScheduleId: string | null;
|
|
69
|
+
description: string | null;
|
|
70
|
+
pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
|
|
71
|
+
baseSellAmountCents: number | null;
|
|
72
|
+
baseCostAmountCents: number | null;
|
|
73
|
+
minPerBooking: number | null;
|
|
74
|
+
maxPerBooking: number | null;
|
|
75
|
+
allPricingCategories: boolean;
|
|
76
|
+
} | null>;
|
|
77
|
+
export declare function updateOptionPriceRule(db: PostgresJsDatabase, id: string, data: UpdateOptionPriceRuleInput): Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
productId: string;
|
|
80
|
+
optionId: string;
|
|
81
|
+
priceCatalogId: string;
|
|
82
|
+
priceScheduleId: string | null;
|
|
83
|
+
cancellationPolicyId: string | null;
|
|
84
|
+
code: string | null;
|
|
85
|
+
name: string;
|
|
86
|
+
description: string | null;
|
|
87
|
+
pricingMode: "per_person" | "per_booking" | "starting_from" | "free" | "on_request";
|
|
88
|
+
baseSellAmountCents: number | null;
|
|
89
|
+
baseCostAmountCents: number | null;
|
|
90
|
+
minPerBooking: number | null;
|
|
91
|
+
maxPerBooking: number | null;
|
|
92
|
+
allPricingCategories: boolean;
|
|
93
|
+
isDefault: boolean;
|
|
94
|
+
active: boolean;
|
|
95
|
+
notes: string | null;
|
|
96
|
+
metadata: Record<string, unknown> | null;
|
|
97
|
+
createdAt: Date;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
} | null>;
|
|
100
|
+
export declare function deleteOptionPriceRule(db: PostgresJsDatabase, id: string): Promise<{
|
|
101
|
+
id: string;
|
|
102
|
+
} | null>;
|
|
103
|
+
export declare function listOptionUnitPriceRules(db: PostgresJsDatabase, query: OptionUnitPriceRuleListQuery): Promise<{
|
|
104
|
+
data: {
|
|
105
|
+
id: string;
|
|
106
|
+
optionPriceRuleId: string;
|
|
107
|
+
optionId: string;
|
|
108
|
+
unitId: string;
|
|
109
|
+
pricingCategoryId: string | null;
|
|
110
|
+
pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "per_unit" | "included";
|
|
111
|
+
sellAmountCents: number | null;
|
|
112
|
+
costAmountCents: number | null;
|
|
113
|
+
minQuantity: number | null;
|
|
114
|
+
maxQuantity: number | null;
|
|
115
|
+
active: boolean;
|
|
116
|
+
sortOrder: number;
|
|
117
|
+
notes: string | null;
|
|
118
|
+
metadata: Record<string, unknown> | null;
|
|
119
|
+
createdAt: Date;
|
|
120
|
+
updatedAt: Date;
|
|
121
|
+
}[];
|
|
122
|
+
total: number;
|
|
123
|
+
limit: number;
|
|
124
|
+
offset: number;
|
|
125
|
+
}>;
|
|
126
|
+
export declare function getOptionUnitPriceRuleById(db: PostgresJsDatabase, id: string): Promise<{
|
|
127
|
+
id: string;
|
|
128
|
+
optionPriceRuleId: string;
|
|
129
|
+
optionId: string;
|
|
130
|
+
unitId: string;
|
|
131
|
+
pricingCategoryId: string | null;
|
|
132
|
+
pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "per_unit" | "included";
|
|
133
|
+
sellAmountCents: number | null;
|
|
134
|
+
costAmountCents: number | null;
|
|
135
|
+
minQuantity: number | null;
|
|
136
|
+
maxQuantity: number | null;
|
|
137
|
+
active: boolean;
|
|
138
|
+
sortOrder: number;
|
|
139
|
+
notes: string | null;
|
|
140
|
+
metadata: Record<string, unknown> | null;
|
|
141
|
+
createdAt: Date;
|
|
142
|
+
updatedAt: Date;
|
|
143
|
+
} | null>;
|
|
144
|
+
export declare function createOptionUnitPriceRule(db: PostgresJsDatabase, data: CreateOptionUnitPriceRuleInput): Promise<{
|
|
145
|
+
id: string;
|
|
146
|
+
active: boolean;
|
|
147
|
+
notes: string | null;
|
|
148
|
+
metadata: Record<string, unknown> | null;
|
|
149
|
+
createdAt: Date;
|
|
150
|
+
updatedAt: Date;
|
|
151
|
+
optionId: string;
|
|
152
|
+
unitId: string;
|
|
153
|
+
sortOrder: number;
|
|
154
|
+
pricingCategoryId: string | null;
|
|
155
|
+
pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "per_unit" | "included";
|
|
156
|
+
optionPriceRuleId: string;
|
|
157
|
+
sellAmountCents: number | null;
|
|
158
|
+
costAmountCents: number | null;
|
|
159
|
+
minQuantity: number | null;
|
|
160
|
+
maxQuantity: number | null;
|
|
161
|
+
} | null>;
|
|
162
|
+
export declare function updateOptionUnitPriceRule(db: PostgresJsDatabase, id: string, data: UpdateOptionUnitPriceRuleInput): Promise<{
|
|
163
|
+
id: string;
|
|
164
|
+
optionPriceRuleId: string;
|
|
165
|
+
optionId: string;
|
|
166
|
+
unitId: string;
|
|
167
|
+
pricingCategoryId: string | null;
|
|
168
|
+
pricingMode: "per_person" | "per_booking" | "free" | "on_request" | "per_unit" | "included";
|
|
169
|
+
sellAmountCents: number | null;
|
|
170
|
+
costAmountCents: number | null;
|
|
171
|
+
minQuantity: number | null;
|
|
172
|
+
maxQuantity: number | null;
|
|
173
|
+
active: boolean;
|
|
174
|
+
sortOrder: number;
|
|
175
|
+
notes: string | null;
|
|
176
|
+
metadata: Record<string, unknown> | null;
|
|
177
|
+
createdAt: Date;
|
|
178
|
+
updatedAt: Date;
|
|
179
|
+
} | null>;
|
|
180
|
+
export declare function deleteOptionUnitPriceRule(db: PostgresJsDatabase, id: string): Promise<{
|
|
181
|
+
id: string;
|
|
182
|
+
} | null>;
|
|
183
|
+
export declare function listOptionStartTimeRules(db: PostgresJsDatabase, query: OptionStartTimeRuleListQuery): Promise<{
|
|
184
|
+
data: {
|
|
185
|
+
id: string;
|
|
186
|
+
optionPriceRuleId: string;
|
|
187
|
+
optionId: string;
|
|
188
|
+
startTimeId: string;
|
|
189
|
+
ruleMode: "included" | "excluded" | "override" | "adjustment";
|
|
190
|
+
adjustmentType: "fixed" | "percentage" | null;
|
|
191
|
+
sellAdjustmentCents: number | null;
|
|
192
|
+
costAdjustmentCents: number | null;
|
|
193
|
+
adjustmentBasisPoints: number | null;
|
|
194
|
+
active: boolean;
|
|
195
|
+
notes: string | null;
|
|
196
|
+
createdAt: Date;
|
|
197
|
+
updatedAt: Date;
|
|
198
|
+
}[];
|
|
199
|
+
total: number;
|
|
200
|
+
limit: number;
|
|
201
|
+
offset: number;
|
|
202
|
+
}>;
|
|
203
|
+
export declare function getOptionStartTimeRuleById(db: PostgresJsDatabase, id: string): Promise<{
|
|
204
|
+
id: string;
|
|
205
|
+
optionPriceRuleId: string;
|
|
206
|
+
optionId: string;
|
|
207
|
+
startTimeId: string;
|
|
208
|
+
ruleMode: "included" | "excluded" | "override" | "adjustment";
|
|
209
|
+
adjustmentType: "fixed" | "percentage" | null;
|
|
210
|
+
sellAdjustmentCents: number | null;
|
|
211
|
+
costAdjustmentCents: number | null;
|
|
212
|
+
adjustmentBasisPoints: number | null;
|
|
213
|
+
active: boolean;
|
|
214
|
+
notes: string | null;
|
|
215
|
+
createdAt: Date;
|
|
216
|
+
updatedAt: Date;
|
|
217
|
+
} | null>;
|
|
218
|
+
export declare function createOptionStartTimeRule(db: PostgresJsDatabase, data: CreateOptionStartTimeRuleInput): Promise<{
|
|
219
|
+
id: string;
|
|
220
|
+
active: boolean;
|
|
221
|
+
notes: string | null;
|
|
222
|
+
createdAt: Date;
|
|
223
|
+
updatedAt: Date;
|
|
224
|
+
optionId: string;
|
|
225
|
+
optionPriceRuleId: string;
|
|
226
|
+
startTimeId: string;
|
|
227
|
+
ruleMode: "included" | "excluded" | "override" | "adjustment";
|
|
228
|
+
adjustmentType: "fixed" | "percentage" | null;
|
|
229
|
+
sellAdjustmentCents: number | null;
|
|
230
|
+
costAdjustmentCents: number | null;
|
|
231
|
+
adjustmentBasisPoints: number | null;
|
|
232
|
+
} | null>;
|
|
233
|
+
export declare function updateOptionStartTimeRule(db: PostgresJsDatabase, id: string, data: UpdateOptionStartTimeRuleInput): Promise<{
|
|
234
|
+
id: string;
|
|
235
|
+
optionPriceRuleId: string;
|
|
236
|
+
optionId: string;
|
|
237
|
+
startTimeId: string;
|
|
238
|
+
ruleMode: "included" | "excluded" | "override" | "adjustment";
|
|
239
|
+
adjustmentType: "fixed" | "percentage" | null;
|
|
240
|
+
sellAdjustmentCents: number | null;
|
|
241
|
+
costAdjustmentCents: number | null;
|
|
242
|
+
adjustmentBasisPoints: number | null;
|
|
243
|
+
active: boolean;
|
|
244
|
+
notes: string | null;
|
|
245
|
+
createdAt: Date;
|
|
246
|
+
updatedAt: Date;
|
|
247
|
+
} | null>;
|
|
248
|
+
export declare function deleteOptionStartTimeRule(db: PostgresJsDatabase, id: string): Promise<{
|
|
249
|
+
id: string;
|
|
250
|
+
} | null>;
|
|
251
|
+
export declare function listOptionUnitTiers(db: PostgresJsDatabase, query: OptionUnitTierListQuery): Promise<{
|
|
252
|
+
data: {
|
|
253
|
+
id: string;
|
|
254
|
+
optionUnitPriceRuleId: string;
|
|
255
|
+
minQuantity: number;
|
|
256
|
+
maxQuantity: number | null;
|
|
257
|
+
sellAmountCents: number | null;
|
|
258
|
+
costAmountCents: number | null;
|
|
259
|
+
active: boolean;
|
|
260
|
+
sortOrder: number;
|
|
261
|
+
createdAt: Date;
|
|
262
|
+
updatedAt: Date;
|
|
263
|
+
}[];
|
|
264
|
+
total: number;
|
|
265
|
+
limit: number;
|
|
266
|
+
offset: number;
|
|
267
|
+
}>;
|
|
268
|
+
export declare function getOptionUnitTierById(db: PostgresJsDatabase, id: string): Promise<{
|
|
269
|
+
id: string;
|
|
270
|
+
optionUnitPriceRuleId: string;
|
|
271
|
+
minQuantity: number;
|
|
272
|
+
maxQuantity: number | null;
|
|
273
|
+
sellAmountCents: number | null;
|
|
274
|
+
costAmountCents: number | null;
|
|
275
|
+
active: boolean;
|
|
276
|
+
sortOrder: number;
|
|
277
|
+
createdAt: Date;
|
|
278
|
+
updatedAt: Date;
|
|
279
|
+
} | null>;
|
|
280
|
+
export declare function createOptionUnitTier(db: PostgresJsDatabase, data: CreateOptionUnitTierInput): Promise<{
|
|
281
|
+
id: string;
|
|
282
|
+
active: boolean;
|
|
283
|
+
createdAt: Date;
|
|
284
|
+
updatedAt: Date;
|
|
285
|
+
sortOrder: number;
|
|
286
|
+
sellAmountCents: number | null;
|
|
287
|
+
costAmountCents: number | null;
|
|
288
|
+
minQuantity: number;
|
|
289
|
+
maxQuantity: number | null;
|
|
290
|
+
optionUnitPriceRuleId: string;
|
|
291
|
+
} | null>;
|
|
292
|
+
export declare function updateOptionUnitTier(db: PostgresJsDatabase, id: string, data: UpdateOptionUnitTierInput): Promise<{
|
|
293
|
+
id: string;
|
|
294
|
+
optionUnitPriceRuleId: string;
|
|
295
|
+
minQuantity: number;
|
|
296
|
+
maxQuantity: number | null;
|
|
297
|
+
sellAmountCents: number | null;
|
|
298
|
+
costAmountCents: number | null;
|
|
299
|
+
active: boolean;
|
|
300
|
+
sortOrder: number;
|
|
301
|
+
createdAt: Date;
|
|
302
|
+
updatedAt: Date;
|
|
303
|
+
} | null>;
|
|
304
|
+
export declare function deleteOptionUnitTier(db: PostgresJsDatabase, id: string): Promise<{
|
|
305
|
+
id: string;
|
|
306
|
+
} | null>;
|
|
307
|
+
//# sourceMappingURL=service-option-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-option-rules.d.ts","sourceRoot":"","sources":["../src/service-option-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAQjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B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