autosync_backend2 1.2.14 → 1.2.16
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/index.d.ts +54 -1
- package/dist/index.js +57 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1326,6 +1326,7 @@ export declare const app: Elysia<"", {
|
|
|
1326
1326
|
":id": {
|
|
1327
1327
|
put: {
|
|
1328
1328
|
body: {
|
|
1329
|
+
deletedAt?: string | null | undefined;
|
|
1329
1330
|
oldId?: number | null | undefined;
|
|
1330
1331
|
description?: string | null | undefined;
|
|
1331
1332
|
productId?: string | undefined;
|
|
@@ -4072,7 +4073,9 @@ export declare const app: Elysia<"", {
|
|
|
4072
4073
|
"cp-order": {
|
|
4073
4074
|
sell: {
|
|
4074
4075
|
post: {
|
|
4075
|
-
body:
|
|
4076
|
+
body: {
|
|
4077
|
+
customerId?: string | undefined;
|
|
4078
|
+
};
|
|
4076
4079
|
params: {};
|
|
4077
4080
|
query: unknown;
|
|
4078
4081
|
headers: unknown;
|
|
@@ -4095,6 +4098,15 @@ export declare const app: Elysia<"", {
|
|
|
4095
4098
|
timeCompleted: string | null;
|
|
4096
4099
|
};
|
|
4097
4100
|
401: "Session not found";
|
|
4101
|
+
422: {
|
|
4102
|
+
type: "validation";
|
|
4103
|
+
on: string;
|
|
4104
|
+
summary?: string;
|
|
4105
|
+
message?: string;
|
|
4106
|
+
found?: unknown;
|
|
4107
|
+
property?: string;
|
|
4108
|
+
expected?: string;
|
|
4109
|
+
};
|
|
4098
4110
|
};
|
|
4099
4111
|
};
|
|
4100
4112
|
};
|
|
@@ -7029,6 +7041,47 @@ export declare const app: Elysia<"", {
|
|
|
7029
7041
|
};
|
|
7030
7042
|
};
|
|
7031
7043
|
};
|
|
7044
|
+
} & {
|
|
7045
|
+
reports: {
|
|
7046
|
+
"cp-order": {
|
|
7047
|
+
get: {
|
|
7048
|
+
body: unknown;
|
|
7049
|
+
params: {};
|
|
7050
|
+
query: {
|
|
7051
|
+
type: "Service" | "Product";
|
|
7052
|
+
};
|
|
7053
|
+
headers: unknown;
|
|
7054
|
+
response: {
|
|
7055
|
+
200: {
|
|
7056
|
+
createdAt: string | null;
|
|
7057
|
+
orderId: string | null;
|
|
7058
|
+
phone: string | null;
|
|
7059
|
+
licensePlate: string | null;
|
|
7060
|
+
name: string | null;
|
|
7061
|
+
partNumber: string | null;
|
|
7062
|
+
employeeName: unknown;
|
|
7063
|
+
quantity: number;
|
|
7064
|
+
priceBuy: number | null;
|
|
7065
|
+
price: number;
|
|
7066
|
+
discount: unknown;
|
|
7067
|
+
priceAfterDiscount: number | null;
|
|
7068
|
+
totalPrice: unknown;
|
|
7069
|
+
totalPriceNoat: unknown;
|
|
7070
|
+
}[];
|
|
7071
|
+
401: "Session not found";
|
|
7072
|
+
422: {
|
|
7073
|
+
type: "validation";
|
|
7074
|
+
on: string;
|
|
7075
|
+
summary?: string;
|
|
7076
|
+
message?: string;
|
|
7077
|
+
found?: unknown;
|
|
7078
|
+
property?: string;
|
|
7079
|
+
expected?: string;
|
|
7080
|
+
};
|
|
7081
|
+
};
|
|
7082
|
+
};
|
|
7083
|
+
};
|
|
7084
|
+
};
|
|
7032
7085
|
};
|
|
7033
7086
|
};
|
|
7034
7087
|
} & {
|
package/dist/index.js
CHANGED
|
@@ -146088,7 +146088,7 @@ var requestLogger = new Elysia({ name: "Middleware.RequestLogger" }).onRequest((
|
|
|
146088
146088
|
},
|
|
146089
146089
|
query: url2.searchParams
|
|
146090
146090
|
});
|
|
146091
|
-
}).onAfterResponse(async ({ request,
|
|
146091
|
+
}).onAfterResponse(async ({ request, responseValue, server, status: status2, set: set2, body, headers }) => {
|
|
146092
146092
|
logger2.info({
|
|
146093
146093
|
msg: "Outgoing response",
|
|
146094
146094
|
method: request.method,
|
|
@@ -146101,8 +146101,8 @@ var requestLogger = new Elysia({ name: "Middleware.RequestLogger" }).onRequest((
|
|
|
146101
146101
|
headers,
|
|
146102
146102
|
body
|
|
146103
146103
|
},
|
|
146104
|
-
response,
|
|
146105
|
-
ipAddress: headers["X-FORWARDED_FOR"] ?? server?.requestIP(request)?.address,
|
|
146104
|
+
response: responseValue,
|
|
146105
|
+
ipAddress: headers?.["X-FORWARDED_FOR"] ?? server?.requestIP(request)?.address,
|
|
146106
146106
|
method: request.method,
|
|
146107
146107
|
path: request.url,
|
|
146108
146108
|
statusCode: set2.status?.toString() ?? "200",
|
|
@@ -147358,7 +147358,8 @@ var CrmCpOrderItemLogic;
|
|
|
147358
147358
|
const [result] = await db2.insert(crmCpOrderItemTable).values({
|
|
147359
147359
|
...body,
|
|
147360
147360
|
priceUnit: sk?.price ?? product?.product.priceSell ?? 0,
|
|
147361
|
-
priceTotal: body.quantity * (sk?.price ?? product?.product.priceSell ?? 0)
|
|
147361
|
+
priceTotal: body.quantity * (sk?.price ?? product?.product.priceSell ?? 0),
|
|
147362
|
+
name: sk?.name ?? product?.product.name
|
|
147362
147363
|
}).returning();
|
|
147363
147364
|
if (body.companyProductId && product) {
|
|
147364
147365
|
const res = await CrmCpOrderItemLogic.handleWarehouseQuantityChange(body.companyProductId, body.quantity, user2, {
|
|
@@ -150717,9 +150718,10 @@ var CrmCpOrderLogic;
|
|
|
150717
150718
|
return result;
|
|
150718
150719
|
});
|
|
150719
150720
|
};
|
|
150720
|
-
CrmCpOrderLogic.createSell = async (user2) => {
|
|
150721
|
+
CrmCpOrderLogic.createSell = async (body, user2) => {
|
|
150721
150722
|
const orderId = await getOrderId("ProductSell", user2);
|
|
150722
150723
|
const [result] = await db_default.insert(crmCpOrderTable).values({
|
|
150724
|
+
...body,
|
|
150723
150725
|
companyBranchId: user2.branchId,
|
|
150724
150726
|
companyId: user2.companyId,
|
|
150725
150727
|
orderId,
|
|
@@ -151293,6 +151295,9 @@ var CrmCpOrderModel;
|
|
|
151293
151295
|
licensePlate: t.Optional(t.String()),
|
|
151294
151296
|
vehicleKindId: t.Optional(t.String({ format: "uuid" }))
|
|
151295
151297
|
});
|
|
151298
|
+
CrmCpOrderModel.createSell = t.Object({
|
|
151299
|
+
customerId: t.Optional(t.String({ format: "uuid" }))
|
|
151300
|
+
});
|
|
151296
151301
|
CrmCpOrderModel.addPackage = t.Object({
|
|
151297
151302
|
spPackageId: t.String({ format: "uuid" }),
|
|
151298
151303
|
cpOrderId: t.String({ format: "uuid" }),
|
|
@@ -151450,7 +151455,9 @@ var cpOrderRoutes = new Elysia({
|
|
|
151450
151455
|
return result;
|
|
151451
151456
|
}, {
|
|
151452
151457
|
body: model_default9.create
|
|
151453
|
-
}).post("/sell", async ({ user: user2
|
|
151458
|
+
}).post("/sell", async ({ user: user2, body }) => logic_default14.createSell(body, user2), {
|
|
151459
|
+
body: model_default9.createSell
|
|
151460
|
+
}).post("/package", async ({ body, user: user2 }) => logic_default14.addPackage(body, user2), {
|
|
151454
151461
|
body: model_default9.addPackage
|
|
151455
151462
|
}).post("/complete", async ({ user: user2, body }) => logic_default14.complete(body, user2), {
|
|
151456
151463
|
body: model_default9.complete
|
|
@@ -152201,6 +152208,39 @@ var CrmReportsLogic;
|
|
|
152201
152208
|
]);
|
|
152202
152209
|
return formatCSV(headers, rows);
|
|
152203
152210
|
};
|
|
152211
|
+
CrmReportsLogic.cpOrderReport = async (query, user2) => {
|
|
152212
|
+
const result = await db_default.select({
|
|
152213
|
+
createdAt: crmCpOrderTable.createdAt,
|
|
152214
|
+
orderId: crmCpOrderTable.orderId,
|
|
152215
|
+
phone: crmCustomerTable.phoneNumber,
|
|
152216
|
+
licensePlate: crmVehicleTable.licensePlate,
|
|
152217
|
+
name: crmCpOrderItemTable.name,
|
|
152218
|
+
partNumber: warehouseProductTable.partNumber,
|
|
152219
|
+
employeeName: sql3`STRING_AGG(${companyEmployeeTable.firstname}, ', ')`.as("employee_name"),
|
|
152220
|
+
quantity: crmCpOrderItemTable.quantity,
|
|
152221
|
+
priceBuy: warehouseProductTable.priceBuy,
|
|
152222
|
+
price: crmCpOrderItemTable.priceUnit,
|
|
152223
|
+
discount: sql3`${crmDiscountApplyTable.priceAfterDiscount} - ${crmDiscountApplyTable.priceBeforeDiscount}`.as("discount"),
|
|
152224
|
+
priceAfterDiscount: crmDiscountApplyTable.priceAfterDiscount,
|
|
152225
|
+
totalPrice: sql3`CASE WHEN ${crmCpOrderTable.isNoat} = FALSE THEN ${crmCpOrderItemTable.priceTotal} ELSE 0 END`.as("total_price"),
|
|
152226
|
+
totalPriceNoat: sql3`CASE WHEN ${crmCpOrderTable.isNoat} = TRUE THEN ${crmCpOrderItemTable.priceTotal} * 1.1 ELSE 0 END`.as("total_price_noat")
|
|
152227
|
+
}).from(crmCpOrderItemTable).leftJoin(crmCpOrderTable, eq(crmCpOrderTable.id, crmCpOrderItemTable.cpOrderId)).leftJoin(crmCustomerTable, eq(crmCustomerTable.id, crmCpOrderTable.customerId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmCpOrderTable.vehicleId)).leftJoin(warehouseProductTable, eq(warehouseProductTable.productId, crmCpOrderItemTable.companyProductId)).leftJoin(companyServiceKindTable, eq(companyServiceKindTable.id, crmCpOrderItemTable.companyServiceKindId)).leftJoin(crmCpOrderItemEmployeeTable, eq(crmCpOrderItemEmployeeTable.cpOrderItemId, crmCpOrderItemTable.id)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmCpOrderItemEmployeeTable.employeeId)).leftJoin(crmDiscountApplyTable, eq(crmDiscountApplyTable.cpOrderItemId, crmCpOrderItemTable.id)).where(and(eq(crmCpOrderTable.companyId, user2.companyId), eq(crmCpOrderTable.companyBranchId, user2.branchId).if(user2.kind === "CUSTOMER"), isNotNull(crmCpOrderItemTable.companyProductId).if(query.type === "Product"), isNotNull(crmCpOrderItemTable.companyServiceKindId).if(query.type === "Service"))).groupBy((t2) => [
|
|
152228
|
+
t2.createdAt,
|
|
152229
|
+
t2.orderId,
|
|
152230
|
+
t2.phone,
|
|
152231
|
+
t2.licensePlate,
|
|
152232
|
+
t2.name,
|
|
152233
|
+
t2.partNumber,
|
|
152234
|
+
t2.quantity,
|
|
152235
|
+
t2.priceBuy,
|
|
152236
|
+
t2.price,
|
|
152237
|
+
t2.priceAfterDiscount,
|
|
152238
|
+
t2.discount,
|
|
152239
|
+
t2.totalPrice,
|
|
152240
|
+
t2.totalPriceNoat
|
|
152241
|
+
]);
|
|
152242
|
+
return result;
|
|
152243
|
+
};
|
|
152204
152244
|
})(CrmReportsLogic ||= {});
|
|
152205
152245
|
var logic_default18 = CrmReportsLogic;
|
|
152206
152246
|
|
|
@@ -152285,6 +152325,9 @@ var CrmReportsModel;
|
|
|
152285
152325
|
totalPages: t.Number()
|
|
152286
152326
|
})
|
|
152287
152327
|
});
|
|
152328
|
+
CrmReportsModel.cpOrderReport = t.Object({
|
|
152329
|
+
type: t.UnionEnum(["Product", "Service"])
|
|
152330
|
+
});
|
|
152288
152331
|
})(CrmReportsModel ||= {});
|
|
152289
152332
|
var model_default14 = CrmReportsModel;
|
|
152290
152333
|
|
|
@@ -152339,6 +152382,8 @@ var reportsRoutes = new Elysia({
|
|
|
152339
152382
|
return csvData;
|
|
152340
152383
|
}, {
|
|
152341
152384
|
query: model_default14.csvExportQuery
|
|
152385
|
+
}).get("/cp-order", ({ query, user: user2 }) => logic_default18.cpOrderReport(query, user2), {
|
|
152386
|
+
query: model_default14.cpOrderReport
|
|
152342
152387
|
});
|
|
152343
152388
|
var reports_default = reportsRoutes;
|
|
152344
152389
|
|
|
@@ -152554,7 +152599,7 @@ var vehicleRoutes = new Elysia({
|
|
|
152554
152599
|
}).post("/many", async ({ body }) => {
|
|
152555
152600
|
for (const v of body.licensePlate) {
|
|
152556
152601
|
await logic_default11.findOrCreate({
|
|
152557
|
-
licensePlate: v.trim().replaceAll(" ", "")
|
|
152602
|
+
licensePlate: v.trim().replaceAll(" ", "").replaceAll("-", "")
|
|
152558
152603
|
});
|
|
152559
152604
|
}
|
|
152560
152605
|
}, {
|
|
@@ -152570,7 +152615,7 @@ var vehicleRoutes = new Elysia({
|
|
|
152570
152615
|
model: techdocVehicleKindTable.name,
|
|
152571
152616
|
gas: crmVehicleTable.gasType,
|
|
152572
152617
|
cc: crmVehicleTable.engineCc
|
|
152573
|
-
}).from(crmVehicleTable).where(inArray(crmVehicleTable.licensePlate, body.licensePlate.map((i2) => i2.trim().replaceAll(" ", "")))).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId));
|
|
152618
|
+
}).from(crmVehicleTable).where(inArray(crmVehicleTable.licensePlate, body.licensePlate.map((i2) => i2.trim().replaceAll(" ", "").replaceAll("-", "")))).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId));
|
|
152574
152619
|
return res;
|
|
152575
152620
|
}, {
|
|
152576
152621
|
body: t.Object({
|
|
@@ -153320,7 +153365,10 @@ var WarehouseItemModel;
|
|
|
153320
153365
|
const createSchema = createInsertSchema(warehouseItemTable);
|
|
153321
153366
|
const updateSchema = createUpdateSchema(warehouseItemTable);
|
|
153322
153367
|
WarehouseItemModel.create = OmitBaseSchema(createSchema);
|
|
153323
|
-
WarehouseItemModel.update = t.
|
|
153368
|
+
WarehouseItemModel.update = t.Composite([
|
|
153369
|
+
t.Omit(OmitBaseSchema(updateSchema), ["quantity"]),
|
|
153370
|
+
t.Pick(updateSchema, ["deletedAt"])
|
|
153371
|
+
]);
|
|
153324
153372
|
WarehouseItemModel.createMany = t.Array(WarehouseItemModel.create, {
|
|
153325
153373
|
minItems: 1
|
|
153326
153374
|
});
|