@devlider001/washlab-backend 1.0.4 → 1.0.6
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/convex/_generated/api.d.ts +2 -0
- package/convex/admin.d.ts +1 -1
- package/convex/audit.d.ts +39 -0
- package/convex/customers.d.ts +12 -5
- package/convex/lib/auth.d.ts +24 -1
- package/convex/notifications.d.ts +170 -0
- package/convex/schema.d.ts +53 -2
- package/dist/convex/admin.d.ts +377 -0
- package/dist/convex/admin.d.ts.map +1 -0
- package/dist/convex/admin.js +959 -0
- package/dist/convex/admin.js.map +1 -0
- package/dist/convex/analytics.d.ts +87 -0
- package/dist/convex/analytics.d.ts.map +1 -0
- package/dist/convex/analytics.js +361 -0
- package/dist/convex/analytics.js.map +1 -0
- package/dist/convex/attendants.d.ts +140 -0
- package/dist/convex/attendants.d.ts.map +1 -0
- package/dist/convex/attendants.js +337 -0
- package/dist/convex/attendants.js.map +1 -0
- package/dist/convex/audit.d.ts +158 -0
- package/dist/convex/audit.d.ts.map +1 -0
- package/dist/convex/audit.js +184 -0
- package/dist/convex/audit.js.map +1 -0
- package/dist/convex/clerk.d.ts +53 -0
- package/dist/convex/clerk.d.ts.map +1 -0
- package/dist/convex/clerk.js +316 -0
- package/dist/convex/clerk.js.map +1 -0
- package/dist/convex/customers.d.ts +224 -0
- package/dist/convex/customers.d.ts.map +1 -0
- package/dist/convex/customers.js +504 -0
- package/dist/convex/customers.js.map +1 -0
- package/dist/convex/http.d.ts +3 -0
- package/dist/convex/http.d.ts.map +1 -0
- package/dist/convex/http.js +115 -0
- package/dist/convex/http.js.map +1 -0
- package/dist/convex/lib/audit.d.ts +36 -0
- package/dist/convex/lib/audit.d.ts.map +1 -0
- package/dist/convex/lib/audit.js +59 -0
- package/dist/convex/lib/audit.js.map +1 -0
- package/dist/convex/lib/auth.d.ts +96 -0
- package/dist/convex/lib/auth.d.ts.map +1 -0
- package/dist/convex/lib/auth.js +94 -0
- package/dist/convex/lib/auth.js.map +1 -0
- package/dist/convex/lib/utils.d.ts +38 -0
- package/dist/convex/lib/utils.d.ts.map +1 -0
- package/dist/convex/lib/utils.js +71 -0
- package/dist/convex/lib/utils.js.map +1 -0
- package/dist/convex/loyalty.d.ts +82 -0
- package/dist/convex/loyalty.d.ts.map +1 -0
- package/dist/convex/loyalty.js +286 -0
- package/dist/convex/loyalty.js.map +1 -0
- package/dist/convex/orders.d.ts +326 -0
- package/dist/convex/orders.d.ts.map +1 -0
- package/dist/convex/orders.js +570 -0
- package/dist/convex/orders.js.map +1 -0
- package/dist/convex/payments.d.ts +134 -0
- package/dist/convex/payments.d.ts.map +1 -0
- package/dist/convex/payments.js +360 -0
- package/dist/convex/payments.js.map +1 -0
- package/dist/convex/resources.d.ts +119 -0
- package/dist/convex/resources.d.ts.map +1 -0
- package/dist/convex/resources.js +283 -0
- package/dist/convex/resources.js.map +1 -0
- package/dist/convex/schema.d.ts +450 -0
- package/dist/convex/schema.d.ts.map +1 -0
- package/dist/convex/schema.js +347 -0
- package/dist/convex/schema.js.map +1 -0
- package/dist/convex/vouchers.d.ts +187 -0
- package/dist/convex/vouchers.d.ts.map +1 -0
- package/dist/convex/vouchers.js +464 -0
- package/dist/convex/vouchers.js.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +5 -3
- package/convex/_generated/api.js +0 -23
- package/convex/_generated/server.js +0 -93
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { query, mutation, internalMutation } from "./_generated/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { getCurrentCustomer, getCurrentAdmin } from "./lib/auth";
|
|
4
|
+
import { createAuditLog } from "./lib/audit";
|
|
5
|
+
import { getCurrentTimestamp } from "./lib/utils";
|
|
6
|
+
/**
|
|
7
|
+
* Loyalty Functions
|
|
8
|
+
*
|
|
9
|
+
* Handles loyalty points earning, redemption, and balance management.
|
|
10
|
+
* Rules: 1 point per completed order, 10 points = 1 free wash.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Get customer loyalty points balance
|
|
14
|
+
*/
|
|
15
|
+
export const getBalance = query({
|
|
16
|
+
args: {},
|
|
17
|
+
handler: async (ctx) => {
|
|
18
|
+
const customer = await getCurrentCustomer(ctx);
|
|
19
|
+
const loyaltyPoints = await ctx.db
|
|
20
|
+
.query("loyaltyPoints")
|
|
21
|
+
.withIndex("by_customer", (q) => q.eq("customerId", customer._id))
|
|
22
|
+
.first();
|
|
23
|
+
if (!loyaltyPoints || loyaltyPoints.isDeleted) {
|
|
24
|
+
return {
|
|
25
|
+
points: 0,
|
|
26
|
+
totalEarned: 0,
|
|
27
|
+
totalRedeemed: 0,
|
|
28
|
+
lastEarnedAt: undefined,
|
|
29
|
+
lastRedeemedAt: undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
points: loyaltyPoints.points,
|
|
34
|
+
totalEarned: loyaltyPoints.totalEarned,
|
|
35
|
+
totalRedeemed: loyaltyPoints.totalRedeemed,
|
|
36
|
+
lastEarnedAt: loyaltyPoints.lastEarnedAt,
|
|
37
|
+
lastRedeemedAt: loyaltyPoints.lastRedeemedAt,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Get loyalty transaction history
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Get loyalty transactions - Paginated
|
|
46
|
+
* Supports usePaginatedQuery for infinite scroll
|
|
47
|
+
*/
|
|
48
|
+
export const getTransactions = query({
|
|
49
|
+
args: {
|
|
50
|
+
cursor: v.optional(v.string()),
|
|
51
|
+
numItems: v.optional(v.number()),
|
|
52
|
+
},
|
|
53
|
+
handler: async (ctx, args) => {
|
|
54
|
+
const customer = await getCurrentCustomer(ctx);
|
|
55
|
+
const numItems = args.numItems ?? 20;
|
|
56
|
+
const result = await ctx.db
|
|
57
|
+
.query("loyaltyTransactions")
|
|
58
|
+
.withIndex("by_customer", (q) => q.eq("customerId", customer._id))
|
|
59
|
+
.order("desc")
|
|
60
|
+
.filter((q) => q.eq(q.field("isDeleted"), false))
|
|
61
|
+
.paginate({
|
|
62
|
+
cursor: args.cursor ?? null,
|
|
63
|
+
numItems,
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
page: result.page,
|
|
67
|
+
isDone: result.isDone,
|
|
68
|
+
continueCursor: result.continueCursor,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Earn loyalty points (internal - called when order is completed)
|
|
74
|
+
*/
|
|
75
|
+
export const earnPoints = internalMutation({
|
|
76
|
+
args: {
|
|
77
|
+
customerId: v.id("users"),
|
|
78
|
+
orderId: v.id("orders"),
|
|
79
|
+
points: v.number(),
|
|
80
|
+
},
|
|
81
|
+
handler: async (ctx, args) => {
|
|
82
|
+
// Get or create loyalty points record
|
|
83
|
+
let loyaltyPoints = await ctx.db
|
|
84
|
+
.query("loyaltyPoints")
|
|
85
|
+
.withIndex("by_customer", (q) => q.eq("customerId", args.customerId))
|
|
86
|
+
.first();
|
|
87
|
+
const now = getCurrentTimestamp();
|
|
88
|
+
if (!loyaltyPoints || loyaltyPoints.isDeleted) {
|
|
89
|
+
// Create new loyalty points record
|
|
90
|
+
const loyaltyId = await ctx.db.insert("loyaltyPoints", {
|
|
91
|
+
customerId: args.customerId,
|
|
92
|
+
points: args.points,
|
|
93
|
+
totalEarned: args.points,
|
|
94
|
+
totalRedeemed: 0,
|
|
95
|
+
lastEarnedAt: now,
|
|
96
|
+
isDeleted: false,
|
|
97
|
+
});
|
|
98
|
+
loyaltyPoints = await ctx.db.get(loyaltyId);
|
|
99
|
+
if (!loyaltyPoints)
|
|
100
|
+
throw new Error("Failed to create loyalty points");
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Update existing record
|
|
104
|
+
await ctx.db.patch(loyaltyPoints._id, {
|
|
105
|
+
points: loyaltyPoints.points + args.points,
|
|
106
|
+
totalEarned: loyaltyPoints.totalEarned + args.points,
|
|
107
|
+
lastEarnedAt: now,
|
|
108
|
+
});
|
|
109
|
+
loyaltyPoints = await ctx.db.get(loyaltyPoints._id);
|
|
110
|
+
if (!loyaltyPoints)
|
|
111
|
+
throw new Error("Failed to update loyalty points");
|
|
112
|
+
}
|
|
113
|
+
// Create transaction record
|
|
114
|
+
await ctx.db.insert("loyaltyTransactions", {
|
|
115
|
+
customerId: args.customerId,
|
|
116
|
+
orderId: args.orderId,
|
|
117
|
+
type: "earned",
|
|
118
|
+
points: args.points,
|
|
119
|
+
balanceAfter: loyaltyPoints.points + args.points,
|
|
120
|
+
description: `Earned ${args.points} point(s) from order`,
|
|
121
|
+
createdAt: now,
|
|
122
|
+
isDeleted: false,
|
|
123
|
+
});
|
|
124
|
+
await createAuditLog({
|
|
125
|
+
ctx,
|
|
126
|
+
actorId: "system",
|
|
127
|
+
actorType: "admin",
|
|
128
|
+
actorRole: "system",
|
|
129
|
+
action: "loyalty.points_earned",
|
|
130
|
+
entityType: "loyaltyPoints",
|
|
131
|
+
entityId: loyaltyPoints._id,
|
|
132
|
+
details: JSON.stringify({
|
|
133
|
+
customerId: args.customerId,
|
|
134
|
+
orderId: args.orderId,
|
|
135
|
+
points: args.points,
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Redeem loyalty points for free wash
|
|
142
|
+
*/
|
|
143
|
+
export const redeemPoints = mutation({
|
|
144
|
+
args: {
|
|
145
|
+
orderId: v.id("orders"),
|
|
146
|
+
pointsToRedeem: v.number(), // Usually 10 points = 1 free wash
|
|
147
|
+
},
|
|
148
|
+
handler: async (ctx, args) => {
|
|
149
|
+
const customer = await getCurrentCustomer(ctx);
|
|
150
|
+
// Verify customer owns the order
|
|
151
|
+
const order = await ctx.db.get(args.orderId);
|
|
152
|
+
if (!order || order.isDeleted) {
|
|
153
|
+
throw new Error("Order not found");
|
|
154
|
+
}
|
|
155
|
+
if (order.customerId !== customer._id) {
|
|
156
|
+
throw new Error("Order does not belong to customer");
|
|
157
|
+
}
|
|
158
|
+
if (order.paymentStatus === "paid") {
|
|
159
|
+
throw new Error("Cannot redeem points for already paid order");
|
|
160
|
+
}
|
|
161
|
+
// Get loyalty points
|
|
162
|
+
const loyaltyPoints = await ctx.db
|
|
163
|
+
.query("loyaltyPoints")
|
|
164
|
+
.withIndex("by_customer", (q) => q.eq("customerId", customer._id))
|
|
165
|
+
.first();
|
|
166
|
+
if (!loyaltyPoints || loyaltyPoints.isDeleted) {
|
|
167
|
+
throw new Error("Insufficient loyalty points");
|
|
168
|
+
}
|
|
169
|
+
if (loyaltyPoints.points < args.pointsToRedeem) {
|
|
170
|
+
throw new Error(`Insufficient points. Available: ${loyaltyPoints.points}, Required: ${args.pointsToRedeem}`);
|
|
171
|
+
}
|
|
172
|
+
const now = getCurrentTimestamp();
|
|
173
|
+
const newBalance = loyaltyPoints.points - args.pointsToRedeem;
|
|
174
|
+
// Update loyalty points
|
|
175
|
+
await ctx.db.patch(loyaltyPoints._id, {
|
|
176
|
+
points: newBalance,
|
|
177
|
+
totalRedeemed: loyaltyPoints.totalRedeemed + args.pointsToRedeem,
|
|
178
|
+
lastRedeemedAt: now,
|
|
179
|
+
});
|
|
180
|
+
// Create transaction record
|
|
181
|
+
await ctx.db.insert("loyaltyTransactions", {
|
|
182
|
+
customerId: customer._id,
|
|
183
|
+
orderId: args.orderId,
|
|
184
|
+
type: "redeemed",
|
|
185
|
+
points: -args.pointsToRedeem,
|
|
186
|
+
balanceAfter: newBalance,
|
|
187
|
+
description: `Redeemed ${args.pointsToRedeem} point(s) for order discount`,
|
|
188
|
+
createdAt: now,
|
|
189
|
+
isDeleted: false,
|
|
190
|
+
});
|
|
191
|
+
// Calculate discount (10 points = 1 free wash = 100% discount)
|
|
192
|
+
const discountAmount = order.totalPrice; // Full discount for 10 points
|
|
193
|
+
const newFinalPrice = Math.max(0, order.totalPrice - discountAmount);
|
|
194
|
+
// Update order with discount
|
|
195
|
+
await ctx.db.patch(args.orderId, {
|
|
196
|
+
finalPrice: newFinalPrice,
|
|
197
|
+
});
|
|
198
|
+
await createAuditLog({
|
|
199
|
+
ctx,
|
|
200
|
+
actorId: customer._id,
|
|
201
|
+
actorType: "customer",
|
|
202
|
+
actorRole: "customer",
|
|
203
|
+
action: "loyalty.points_redeemed",
|
|
204
|
+
entityType: "loyaltyPoints",
|
|
205
|
+
entityId: loyaltyPoints._id,
|
|
206
|
+
details: JSON.stringify({
|
|
207
|
+
orderId: args.orderId,
|
|
208
|
+
pointsRedeemed: args.pointsToRedeem,
|
|
209
|
+
discountAmount,
|
|
210
|
+
}),
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
pointsRedeemed: args.pointsToRedeem,
|
|
214
|
+
newBalance,
|
|
215
|
+
discountAmount,
|
|
216
|
+
finalPrice: newFinalPrice,
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
/**
|
|
221
|
+
* Adjust loyalty points (admin only)
|
|
222
|
+
*/
|
|
223
|
+
export const adjustPoints = mutation({
|
|
224
|
+
args: {
|
|
225
|
+
customerId: v.id("users"),
|
|
226
|
+
points: v.number(), // Positive or negative adjustment
|
|
227
|
+
description: v.string(),
|
|
228
|
+
},
|
|
229
|
+
handler: async (ctx, args) => {
|
|
230
|
+
await getCurrentAdmin(ctx);
|
|
231
|
+
// Get or create loyalty points record
|
|
232
|
+
let loyaltyPoints = await ctx.db
|
|
233
|
+
.query("loyaltyPoints")
|
|
234
|
+
.withIndex("by_customer", (q) => q.eq("customerId", args.customerId))
|
|
235
|
+
.first();
|
|
236
|
+
const now = getCurrentTimestamp();
|
|
237
|
+
if (!loyaltyPoints || loyaltyPoints.isDeleted) {
|
|
238
|
+
if (args.points < 0) {
|
|
239
|
+
throw new Error("Cannot deduct points from customer with zero balance");
|
|
240
|
+
}
|
|
241
|
+
// Create new record
|
|
242
|
+
const loyaltyId = await ctx.db.insert("loyaltyPoints", {
|
|
243
|
+
customerId: args.customerId,
|
|
244
|
+
points: args.points,
|
|
245
|
+
totalEarned: args.points > 0 ? args.points : 0,
|
|
246
|
+
totalRedeemed: args.points < 0 ? Math.abs(args.points) : 0,
|
|
247
|
+
lastEarnedAt: args.points > 0 ? now : undefined,
|
|
248
|
+
lastRedeemedAt: args.points < 0 ? now : undefined,
|
|
249
|
+
isDeleted: false,
|
|
250
|
+
});
|
|
251
|
+
loyaltyPoints = await ctx.db.get(loyaltyId);
|
|
252
|
+
if (!loyaltyPoints)
|
|
253
|
+
throw new Error("Failed to create loyalty points");
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
const newBalance = loyaltyPoints.points + args.points;
|
|
257
|
+
if (newBalance < 0) {
|
|
258
|
+
throw new Error("Cannot adjust points below zero");
|
|
259
|
+
}
|
|
260
|
+
// Update record
|
|
261
|
+
await ctx.db.patch(loyaltyPoints._id, {
|
|
262
|
+
points: newBalance,
|
|
263
|
+
totalEarned: args.points > 0 ? loyaltyPoints.totalEarned + args.points : loyaltyPoints.totalEarned,
|
|
264
|
+
totalRedeemed: args.points < 0 ? loyaltyPoints.totalRedeemed + Math.abs(args.points) : loyaltyPoints.totalRedeemed,
|
|
265
|
+
lastEarnedAt: args.points > 0 ? now : loyaltyPoints.lastEarnedAt,
|
|
266
|
+
lastRedeemedAt: args.points < 0 ? now : loyaltyPoints.lastRedeemedAt,
|
|
267
|
+
});
|
|
268
|
+
loyaltyPoints = await ctx.db.get(loyaltyPoints._id);
|
|
269
|
+
if (!loyaltyPoints)
|
|
270
|
+
throw new Error("Failed to update loyalty points");
|
|
271
|
+
}
|
|
272
|
+
// Create transaction record
|
|
273
|
+
await ctx.db.insert("loyaltyTransactions", {
|
|
274
|
+
customerId: args.customerId,
|
|
275
|
+
type: "adjusted",
|
|
276
|
+
points: args.points,
|
|
277
|
+
balanceAfter: loyaltyPoints.points,
|
|
278
|
+
description: args.description,
|
|
279
|
+
createdAt: now,
|
|
280
|
+
createdBy: (await getCurrentAdmin(ctx))._id,
|
|
281
|
+
isDeleted: false,
|
|
282
|
+
});
|
|
283
|
+
return loyaltyPoints;
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
//# sourceMappingURL=loyalty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loyalty.js","sourceRoot":"","sources":["../../convex/loyalty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;IAC9B,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE/C,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,EAAE;aAC/B,KAAK,CAAC,eAAe,CAAC;aACtB,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;aACjE,KAAK,EAAE,CAAC;QAEX,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;YAC9C,OAAO;gBACL,MAAM,EAAE,CAAC;gBACT,WAAW,EAAE,CAAC;gBACd,aAAa,EAAE,CAAC;gBAChB,YAAY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C,CAAC,aAAa,CAAC,WAAW;gBAClG,aAAa,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,aAAa;gBAClH,YAAY,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY;gBAChE,cAAc,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,cAAc;aACrE,CAAC,CAAC;YACH,aAAa,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACpD,IAAI,CAAC,aAAa;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzE,CAAC;QAED,4BAA4B;QAC5B,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACzC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,aAAa,CAAC,MAAM;YAClC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;YAC3C,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Functions
|
|
3
|
+
*
|
|
4
|
+
* Handles order creation (walk-in and online), status updates, and queries.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get order by order number
|
|
8
|
+
*/
|
|
9
|
+
export declare const getByOrderNumber: import("convex/server").RegisteredQuery<"public", {
|
|
10
|
+
orderNumber: string;
|
|
11
|
+
}, Promise<{
|
|
12
|
+
_id: import("convex/values").GenericId<"orders">;
|
|
13
|
+
_creationTime: number;
|
|
14
|
+
createdBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
15
|
+
estimatedWeight?: number | undefined;
|
|
16
|
+
actualWeight?: number | undefined;
|
|
17
|
+
itemCount?: number | undefined;
|
|
18
|
+
estimatedLoads?: number | undefined;
|
|
19
|
+
whitesSeparate?: boolean | undefined;
|
|
20
|
+
bagCardNumber?: string | undefined;
|
|
21
|
+
notes?: string | undefined;
|
|
22
|
+
deliveryAddress?: string | undefined;
|
|
23
|
+
deliveryPhoneNumber?: string | undefined;
|
|
24
|
+
deliveryHall?: string | undefined;
|
|
25
|
+
deliveryRoom?: string | undefined;
|
|
26
|
+
paymentMethod?: "mobile_money" | "card" | "cash" | undefined;
|
|
27
|
+
paymentId?: import("convex/values").GenericId<"payments"> | undefined;
|
|
28
|
+
fulfilledBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
29
|
+
status: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
30
|
+
createdAt: number;
|
|
31
|
+
isDeleted: boolean;
|
|
32
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
33
|
+
deliveryFee: number;
|
|
34
|
+
customerId: import("convex/values").GenericId<"users">;
|
|
35
|
+
customerPhoneNumber: string;
|
|
36
|
+
orderNumber: string;
|
|
37
|
+
orderType: "walk_in" | "online";
|
|
38
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
39
|
+
isDelivery: boolean;
|
|
40
|
+
basePrice: number;
|
|
41
|
+
totalPrice: number;
|
|
42
|
+
finalPrice: number;
|
|
43
|
+
paymentStatus: "pending" | "paid" | "failed" | "refunded";
|
|
44
|
+
updatedAt: number;
|
|
45
|
+
statusHistory: {
|
|
46
|
+
notes?: string | undefined;
|
|
47
|
+
status: string;
|
|
48
|
+
changedAt: number;
|
|
49
|
+
changedBy: import("convex/values").GenericId<"attendants">;
|
|
50
|
+
}[];
|
|
51
|
+
} | null>>;
|
|
52
|
+
/**
|
|
53
|
+
* Get orders by customer (from authenticated session)
|
|
54
|
+
*/
|
|
55
|
+
export declare const getByCustomer: import("convex/server").RegisteredQuery<"public", {
|
|
56
|
+
status?: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled" | undefined;
|
|
57
|
+
limit?: number | undefined;
|
|
58
|
+
}, Promise<{
|
|
59
|
+
_id: import("convex/values").GenericId<"orders">;
|
|
60
|
+
_creationTime: number;
|
|
61
|
+
createdBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
62
|
+
estimatedWeight?: number | undefined;
|
|
63
|
+
actualWeight?: number | undefined;
|
|
64
|
+
itemCount?: number | undefined;
|
|
65
|
+
estimatedLoads?: number | undefined;
|
|
66
|
+
whitesSeparate?: boolean | undefined;
|
|
67
|
+
bagCardNumber?: string | undefined;
|
|
68
|
+
notes?: string | undefined;
|
|
69
|
+
deliveryAddress?: string | undefined;
|
|
70
|
+
deliveryPhoneNumber?: string | undefined;
|
|
71
|
+
deliveryHall?: string | undefined;
|
|
72
|
+
deliveryRoom?: string | undefined;
|
|
73
|
+
paymentMethod?: "mobile_money" | "card" | "cash" | undefined;
|
|
74
|
+
paymentId?: import("convex/values").GenericId<"payments"> | undefined;
|
|
75
|
+
fulfilledBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
76
|
+
status: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
77
|
+
createdAt: number;
|
|
78
|
+
isDeleted: boolean;
|
|
79
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
80
|
+
deliveryFee: number;
|
|
81
|
+
customerId: import("convex/values").GenericId<"users">;
|
|
82
|
+
customerPhoneNumber: string;
|
|
83
|
+
orderNumber: string;
|
|
84
|
+
orderType: "walk_in" | "online";
|
|
85
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
86
|
+
isDelivery: boolean;
|
|
87
|
+
basePrice: number;
|
|
88
|
+
totalPrice: number;
|
|
89
|
+
finalPrice: number;
|
|
90
|
+
paymentStatus: "pending" | "paid" | "failed" | "refunded";
|
|
91
|
+
updatedAt: number;
|
|
92
|
+
statusHistory: {
|
|
93
|
+
notes?: string | undefined;
|
|
94
|
+
status: string;
|
|
95
|
+
changedAt: number;
|
|
96
|
+
changedBy: import("convex/values").GenericId<"attendants">;
|
|
97
|
+
}[];
|
|
98
|
+
}[]>>;
|
|
99
|
+
/**
|
|
100
|
+
* Get orders by branch (for POS)
|
|
101
|
+
*/
|
|
102
|
+
export declare const getByBranch: import("convex/server").RegisteredQuery<"public", {
|
|
103
|
+
status?: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled" | undefined;
|
|
104
|
+
limit?: number | undefined;
|
|
105
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
106
|
+
}, Promise<{
|
|
107
|
+
_id: import("convex/values").GenericId<"orders">;
|
|
108
|
+
_creationTime: number;
|
|
109
|
+
createdBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
110
|
+
estimatedWeight?: number | undefined;
|
|
111
|
+
actualWeight?: number | undefined;
|
|
112
|
+
itemCount?: number | undefined;
|
|
113
|
+
estimatedLoads?: number | undefined;
|
|
114
|
+
whitesSeparate?: boolean | undefined;
|
|
115
|
+
bagCardNumber?: string | undefined;
|
|
116
|
+
notes?: string | undefined;
|
|
117
|
+
deliveryAddress?: string | undefined;
|
|
118
|
+
deliveryPhoneNumber?: string | undefined;
|
|
119
|
+
deliveryHall?: string | undefined;
|
|
120
|
+
deliveryRoom?: string | undefined;
|
|
121
|
+
paymentMethod?: "mobile_money" | "card" | "cash" | undefined;
|
|
122
|
+
paymentId?: import("convex/values").GenericId<"payments"> | undefined;
|
|
123
|
+
fulfilledBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
124
|
+
status: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
125
|
+
createdAt: number;
|
|
126
|
+
isDeleted: boolean;
|
|
127
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
128
|
+
deliveryFee: number;
|
|
129
|
+
customerId: import("convex/values").GenericId<"users">;
|
|
130
|
+
customerPhoneNumber: string;
|
|
131
|
+
orderNumber: string;
|
|
132
|
+
orderType: "walk_in" | "online";
|
|
133
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
134
|
+
isDelivery: boolean;
|
|
135
|
+
basePrice: number;
|
|
136
|
+
totalPrice: number;
|
|
137
|
+
finalPrice: number;
|
|
138
|
+
paymentStatus: "pending" | "paid" | "failed" | "refunded";
|
|
139
|
+
updatedAt: number;
|
|
140
|
+
statusHistory: {
|
|
141
|
+
notes?: string | undefined;
|
|
142
|
+
status: string;
|
|
143
|
+
changedAt: number;
|
|
144
|
+
changedBy: import("convex/values").GenericId<"attendants">;
|
|
145
|
+
}[];
|
|
146
|
+
}[]>>;
|
|
147
|
+
/**
|
|
148
|
+
* Get pending online orders (awaiting drop-off at POS)
|
|
149
|
+
*/
|
|
150
|
+
export declare const getPending: import("convex/server").RegisteredQuery<"public", {
|
|
151
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
152
|
+
}, Promise<{
|
|
153
|
+
_id: import("convex/values").GenericId<"orders">;
|
|
154
|
+
_creationTime: number;
|
|
155
|
+
createdBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
156
|
+
estimatedWeight?: number | undefined;
|
|
157
|
+
actualWeight?: number | undefined;
|
|
158
|
+
itemCount?: number | undefined;
|
|
159
|
+
estimatedLoads?: number | undefined;
|
|
160
|
+
whitesSeparate?: boolean | undefined;
|
|
161
|
+
bagCardNumber?: string | undefined;
|
|
162
|
+
notes?: string | undefined;
|
|
163
|
+
deliveryAddress?: string | undefined;
|
|
164
|
+
deliveryPhoneNumber?: string | undefined;
|
|
165
|
+
deliveryHall?: string | undefined;
|
|
166
|
+
deliveryRoom?: string | undefined;
|
|
167
|
+
paymentMethod?: "mobile_money" | "card" | "cash" | undefined;
|
|
168
|
+
paymentId?: import("convex/values").GenericId<"payments"> | undefined;
|
|
169
|
+
fulfilledBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
170
|
+
status: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
171
|
+
createdAt: number;
|
|
172
|
+
isDeleted: boolean;
|
|
173
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
174
|
+
deliveryFee: number;
|
|
175
|
+
customerId: import("convex/values").GenericId<"users">;
|
|
176
|
+
customerPhoneNumber: string;
|
|
177
|
+
orderNumber: string;
|
|
178
|
+
orderType: "walk_in" | "online";
|
|
179
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
180
|
+
isDelivery: boolean;
|
|
181
|
+
basePrice: number;
|
|
182
|
+
totalPrice: number;
|
|
183
|
+
finalPrice: number;
|
|
184
|
+
paymentStatus: "pending" | "paid" | "failed" | "refunded";
|
|
185
|
+
updatedAt: number;
|
|
186
|
+
statusHistory: {
|
|
187
|
+
notes?: string | undefined;
|
|
188
|
+
status: string;
|
|
189
|
+
changedAt: number;
|
|
190
|
+
changedBy: import("convex/values").GenericId<"attendants">;
|
|
191
|
+
}[];
|
|
192
|
+
}[]>>;
|
|
193
|
+
/**
|
|
194
|
+
* Create walk-in order (attendant creates at POS)
|
|
195
|
+
*/
|
|
196
|
+
export declare const createWalkIn: import("convex/server").RegisteredMutation<"public", {
|
|
197
|
+
bagCardNumber?: string | undefined;
|
|
198
|
+
notes?: string | undefined;
|
|
199
|
+
deliveryAddress?: string | undefined;
|
|
200
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
201
|
+
customerPhoneNumber: string;
|
|
202
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
203
|
+
actualWeight: number;
|
|
204
|
+
itemCount: number;
|
|
205
|
+
isDelivery: boolean;
|
|
206
|
+
customerName: string;
|
|
207
|
+
}, Promise<import("convex/values").GenericId<"orders">>>;
|
|
208
|
+
/**
|
|
209
|
+
* Create online order (customer creates from website)
|
|
210
|
+
* Supports both guest checkout and authenticated users
|
|
211
|
+
*/
|
|
212
|
+
export declare const createOnline: import("convex/server").RegisteredMutation<"public", {
|
|
213
|
+
estimatedLoads?: number | undefined;
|
|
214
|
+
whitesSeparate?: boolean | undefined;
|
|
215
|
+
bagCardNumber?: string | undefined;
|
|
216
|
+
notes?: string | undefined;
|
|
217
|
+
deliveryAddress?: string | undefined;
|
|
218
|
+
deliveryPhoneNumber?: string | undefined;
|
|
219
|
+
deliveryHall?: string | undefined;
|
|
220
|
+
deliveryRoom?: string | undefined;
|
|
221
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
222
|
+
customerPhoneNumber: string;
|
|
223
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
224
|
+
estimatedWeight: number;
|
|
225
|
+
itemCount: number;
|
|
226
|
+
isDelivery: boolean;
|
|
227
|
+
customerName: string;
|
|
228
|
+
}, Promise<{
|
|
229
|
+
orderId: import("convex/values").GenericId<"orders">;
|
|
230
|
+
orderNumber: string;
|
|
231
|
+
isGuest: boolean;
|
|
232
|
+
}>>;
|
|
233
|
+
/**
|
|
234
|
+
* Update order weight (when customer drops off online order)
|
|
235
|
+
*/
|
|
236
|
+
export declare const updateWeight: import("convex/server").RegisteredMutation<"public", {
|
|
237
|
+
bagCardNumber?: string | undefined;
|
|
238
|
+
actualWeight: number;
|
|
239
|
+
itemCount: number;
|
|
240
|
+
orderId: import("convex/values").GenericId<"orders">;
|
|
241
|
+
}, Promise<void>>;
|
|
242
|
+
/**
|
|
243
|
+
* Update order status (attendant operation)
|
|
244
|
+
*/
|
|
245
|
+
export declare const updateStatus: import("convex/server").RegisteredMutation<"public", {
|
|
246
|
+
notes?: string | undefined;
|
|
247
|
+
orderId: import("convex/values").GenericId<"orders">;
|
|
248
|
+
newStatus: "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
249
|
+
}, Promise<void>>;
|
|
250
|
+
/**
|
|
251
|
+
* Cancel order
|
|
252
|
+
*/
|
|
253
|
+
export declare const cancel: import("convex/server").RegisteredMutation<"public", {
|
|
254
|
+
reason?: string | undefined;
|
|
255
|
+
orderId: import("convex/values").GenericId<"orders">;
|
|
256
|
+
}, Promise<import("convex/values").GenericId<"orders">>>;
|
|
257
|
+
/**
|
|
258
|
+
* Get order statistics summary
|
|
259
|
+
*/
|
|
260
|
+
export declare const getStats: import("convex/server").RegisteredQuery<"public", {
|
|
261
|
+
branchId?: import("convex/values").GenericId<"branches"> | undefined;
|
|
262
|
+
startDate?: number | undefined;
|
|
263
|
+
endDate?: number | undefined;
|
|
264
|
+
}, Promise<{
|
|
265
|
+
total: number;
|
|
266
|
+
byStatus: Record<string, number>;
|
|
267
|
+
byType: Record<string, number>;
|
|
268
|
+
byServiceType: Record<string, number>;
|
|
269
|
+
totalRevenue: number;
|
|
270
|
+
averageOrderValue: number;
|
|
271
|
+
totalWeight: number;
|
|
272
|
+
averageWeight: number;
|
|
273
|
+
}>>;
|
|
274
|
+
/**
|
|
275
|
+
* Get orders by date range with detailed filtering
|
|
276
|
+
*/
|
|
277
|
+
export declare const getByDateRange: import("convex/server").RegisteredQuery<"public", {
|
|
278
|
+
status?: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled" | undefined;
|
|
279
|
+
branchId?: import("convex/values").GenericId<"branches"> | undefined;
|
|
280
|
+
orderType?: "walk_in" | "online" | undefined;
|
|
281
|
+
serviceType?: "wash_only" | "wash_and_dry" | "dry_only" | undefined;
|
|
282
|
+
limit?: number | undefined;
|
|
283
|
+
startDate: number;
|
|
284
|
+
endDate: number;
|
|
285
|
+
}, Promise<{
|
|
286
|
+
_id: import("convex/values").GenericId<"orders">;
|
|
287
|
+
_creationTime: number;
|
|
288
|
+
createdBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
289
|
+
estimatedWeight?: number | undefined;
|
|
290
|
+
actualWeight?: number | undefined;
|
|
291
|
+
itemCount?: number | undefined;
|
|
292
|
+
estimatedLoads?: number | undefined;
|
|
293
|
+
whitesSeparate?: boolean | undefined;
|
|
294
|
+
bagCardNumber?: string | undefined;
|
|
295
|
+
notes?: string | undefined;
|
|
296
|
+
deliveryAddress?: string | undefined;
|
|
297
|
+
deliveryPhoneNumber?: string | undefined;
|
|
298
|
+
deliveryHall?: string | undefined;
|
|
299
|
+
deliveryRoom?: string | undefined;
|
|
300
|
+
paymentMethod?: "mobile_money" | "card" | "cash" | undefined;
|
|
301
|
+
paymentId?: import("convex/values").GenericId<"payments"> | undefined;
|
|
302
|
+
fulfilledBy?: import("convex/values").GenericId<"attendants"> | undefined;
|
|
303
|
+
status: "pending" | "in_progress" | "ready_for_pickup" | "delivered" | "completed" | "cancelled";
|
|
304
|
+
createdAt: number;
|
|
305
|
+
isDeleted: boolean;
|
|
306
|
+
branchId: import("convex/values").GenericId<"branches">;
|
|
307
|
+
deliveryFee: number;
|
|
308
|
+
customerId: import("convex/values").GenericId<"users">;
|
|
309
|
+
customerPhoneNumber: string;
|
|
310
|
+
orderNumber: string;
|
|
311
|
+
orderType: "walk_in" | "online";
|
|
312
|
+
serviceType: "wash_only" | "wash_and_dry" | "dry_only";
|
|
313
|
+
isDelivery: boolean;
|
|
314
|
+
basePrice: number;
|
|
315
|
+
totalPrice: number;
|
|
316
|
+
finalPrice: number;
|
|
317
|
+
paymentStatus: "pending" | "paid" | "failed" | "refunded";
|
|
318
|
+
updatedAt: number;
|
|
319
|
+
statusHistory: {
|
|
320
|
+
notes?: string | undefined;
|
|
321
|
+
status: string;
|
|
322
|
+
changedAt: number;
|
|
323
|
+
changedBy: import("convex/values").GenericId<"attendants">;
|
|
324
|
+
}[];
|
|
325
|
+
}[]>>;
|
|
326
|
+
//# sourceMappingURL=orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../convex/orders.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgB3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoCtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;wDAqHvB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;GAgIvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;iBA6DvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;iBAyEvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM;;;wDAgEjB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;GAoEnB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuEzB,CAAC"}
|