autosync_backend2 1.2.14 → 1.2.15
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 +12 -1
- package/dist/index.js +45 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4072,7 +4072,9 @@ export declare const app: Elysia<"", {
|
|
|
4072
4072
|
"cp-order": {
|
|
4073
4073
|
sell: {
|
|
4074
4074
|
post: {
|
|
4075
|
-
body:
|
|
4075
|
+
body: {
|
|
4076
|
+
customerId?: string | undefined;
|
|
4077
|
+
};
|
|
4076
4078
|
params: {};
|
|
4077
4079
|
query: unknown;
|
|
4078
4080
|
headers: unknown;
|
|
@@ -4095,6 +4097,15 @@ export declare const app: Elysia<"", {
|
|
|
4095
4097
|
timeCompleted: string | null;
|
|
4096
4098
|
};
|
|
4097
4099
|
401: "Session not found";
|
|
4100
|
+
422: {
|
|
4101
|
+
type: "validation";
|
|
4102
|
+
on: string;
|
|
4103
|
+
summary?: string;
|
|
4104
|
+
message?: string;
|
|
4105
|
+
found?: unknown;
|
|
4106
|
+
property?: string;
|
|
4107
|
+
expected?: string;
|
|
4108
|
+
};
|
|
4098
4109
|
};
|
|
4099
4110
|
};
|
|
4100
4111
|
};
|
package/dist/index.js
CHANGED
|
@@ -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 () => {
|
|
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)).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
|
|
|
@@ -152554,7 +152594,7 @@ var vehicleRoutes = new Elysia({
|
|
|
152554
152594
|
}).post("/many", async ({ body }) => {
|
|
152555
152595
|
for (const v of body.licensePlate) {
|
|
152556
152596
|
await logic_default11.findOrCreate({
|
|
152557
|
-
licensePlate: v.trim().replaceAll(" ", "")
|
|
152597
|
+
licensePlate: v.trim().replaceAll(" ", "").replaceAll("-", "")
|
|
152558
152598
|
});
|
|
152559
152599
|
}
|
|
152560
152600
|
}, {
|
|
@@ -152570,7 +152610,7 @@ var vehicleRoutes = new Elysia({
|
|
|
152570
152610
|
model: techdocVehicleKindTable.name,
|
|
152571
152611
|
gas: crmVehicleTable.gasType,
|
|
152572
152612
|
cc: crmVehicleTable.engineCc
|
|
152573
|
-
}).from(crmVehicleTable).where(inArray(crmVehicleTable.licensePlate, body.licensePlate.map((i2) => i2.trim().replaceAll(" ", "")))).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId));
|
|
152613
|
+
}).from(crmVehicleTable).where(inArray(crmVehicleTable.licensePlate, body.licensePlate.map((i2) => i2.trim().replaceAll(" ", "").replaceAll("-", "")))).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId));
|
|
152574
152614
|
return res;
|
|
152575
152615
|
}, {
|
|
152576
152616
|
body: t.Object({
|