autosync_backend2 1.2.87 → 1.2.89
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 +63 -0
- package/dist/index.js +38 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1358,6 +1358,7 @@ export declare const app: Elysia<"", {
|
|
|
1358
1358
|
salesId?: string | null | undefined;
|
|
1359
1359
|
transferId?: string | null | undefined;
|
|
1360
1360
|
transferItemId?: string | null | undefined;
|
|
1361
|
+
msRecordProductId?: string | null | undefined;
|
|
1361
1362
|
transactionType: "IN" | "OUT";
|
|
1362
1363
|
transactionKind: "ORDER" | "TRANSFER" | "RETURN" | "ADJUSTMENT" | "REJECTION" | "SALES";
|
|
1363
1364
|
};
|
|
@@ -7736,6 +7737,68 @@ export declare const app: Elysia<"", {
|
|
|
7736
7737
|
};
|
|
7737
7738
|
};
|
|
7738
7739
|
};
|
|
7740
|
+
} & {
|
|
7741
|
+
inspection: {
|
|
7742
|
+
":id": {
|
|
7743
|
+
patch: {
|
|
7744
|
+
body: {
|
|
7745
|
+
employeeId?: string | undefined;
|
|
7746
|
+
description?: string | undefined;
|
|
7747
|
+
licensePlate?: string | undefined;
|
|
7748
|
+
inspection?: {
|
|
7749
|
+
type: string;
|
|
7750
|
+
values: {
|
|
7751
|
+
description: string;
|
|
7752
|
+
question: string;
|
|
7753
|
+
answer: string;
|
|
7754
|
+
}[];
|
|
7755
|
+
}[] | undefined;
|
|
7756
|
+
};
|
|
7757
|
+
params: {
|
|
7758
|
+
id: string;
|
|
7759
|
+
};
|
|
7760
|
+
query: unknown;
|
|
7761
|
+
headers: unknown;
|
|
7762
|
+
response: {
|
|
7763
|
+
200: {
|
|
7764
|
+
companyId: string;
|
|
7765
|
+
branchId: string;
|
|
7766
|
+
vehicleId: string;
|
|
7767
|
+
inspection: {
|
|
7768
|
+
type: string;
|
|
7769
|
+
values: {
|
|
7770
|
+
description: string;
|
|
7771
|
+
question: string;
|
|
7772
|
+
answer: string;
|
|
7773
|
+
}[];
|
|
7774
|
+
}[] | null;
|
|
7775
|
+
employeeId: string | null;
|
|
7776
|
+
expireAt: Date;
|
|
7777
|
+
experience: string | null;
|
|
7778
|
+
rank: string | null;
|
|
7779
|
+
licensePlate: string;
|
|
7780
|
+
description: string | null;
|
|
7781
|
+
status: "CANCELLED" | "CREATED" | "APPROVED";
|
|
7782
|
+
id: string;
|
|
7783
|
+
createdAt: string;
|
|
7784
|
+
updatedAt: string;
|
|
7785
|
+
deletedAt: string | null;
|
|
7786
|
+
oldId: number | null;
|
|
7787
|
+
};
|
|
7788
|
+
401: "Токен олдсонгүй";
|
|
7789
|
+
422: {
|
|
7790
|
+
type: "validation";
|
|
7791
|
+
on: string;
|
|
7792
|
+
summary?: string;
|
|
7793
|
+
message?: string;
|
|
7794
|
+
found?: unknown;
|
|
7795
|
+
property?: string;
|
|
7796
|
+
expected?: string;
|
|
7797
|
+
};
|
|
7798
|
+
};
|
|
7799
|
+
};
|
|
7800
|
+
};
|
|
7801
|
+
};
|
|
7739
7802
|
} & {
|
|
7740
7803
|
inspection: {
|
|
7741
7804
|
":id": {
|
package/dist/index.js
CHANGED
|
@@ -281508,7 +281508,7 @@ var WarehouseItemLogic;
|
|
|
281508
281508
|
if (!currentItem) {
|
|
281509
281509
|
return status("Not Found", ERRORS.ITEM_NOT_FOUND);
|
|
281510
281510
|
}
|
|
281511
|
-
const quantityBefore = currentItem.quantity;
|
|
281511
|
+
const quantityBefore = Number(currentItem.quantity);
|
|
281512
281512
|
const quantityAfter = quantityBefore + quantityChange;
|
|
281513
281513
|
if (transactionDetails.transactionType === "OUT" && quantityAfter < 0) {
|
|
281514
281514
|
return status("Bad Request", ERRORS.INSUFFICIENT_STOCK);
|
|
@@ -286341,6 +286341,18 @@ var CrmInspectionLogic;
|
|
|
286341
286341
|
...content
|
|
286342
286342
|
};
|
|
286343
286343
|
};
|
|
286344
|
+
CrmInspectionLogic.update = async (id, body, user2) => {
|
|
286345
|
+
return db_default.transaction(async (db2) => {
|
|
286346
|
+
const [inspection] = await db2.update(crmInspectionTable).set(body).where(and(eq(crmInspectionTable.id, id), eq(crmInspectionTable.companyId, user2.companyId), eq(crmInspectionTable.branchId, user2.branchId).if(user2.kind === "CUSTOMER"))).returning();
|
|
286347
|
+
if (!inspection) {
|
|
286348
|
+
throw status("Not Found", "\u04AE\u0437\u043B\u044D\u0433 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
|
|
286349
|
+
}
|
|
286350
|
+
if (inspection.status === "APPROVED") {
|
|
286351
|
+
throw status("Bad Request", "\u04AE\u0437\u043B\u044D\u0433 \u0438\u0434\u044D\u0432\u0445\u0438\u0433\u0434\u0441\u044D\u043D \u0442\u0443\u043B \u0437\u0430\u0441\u0430\u0445 \u0431\u043E\u043B\u043E\u043C\u0436\u0433\u04AF\u0439.");
|
|
286352
|
+
}
|
|
286353
|
+
return inspection;
|
|
286354
|
+
});
|
|
286355
|
+
};
|
|
286344
286356
|
CrmInspectionLogic.getById = async (id, user2) => {
|
|
286345
286357
|
const [inspection] = await db_default.select().from(crmInspectionTable).where(and(eq(crmInspectionTable.id, id), eq(crmInspectionTable.companyId, user2.companyId), eq(crmInspectionTable.branchId, user2.branchId).if(user2.kind === "CUSTOMER"), softDeletedFilter(crmInspectionTable)));
|
|
286346
286358
|
if (!inspection) {
|
|
@@ -286523,6 +286535,7 @@ var CrmInspectionModel;
|
|
|
286523
286535
|
description: t.Optional(t.String()),
|
|
286524
286536
|
employeeId: t.Optional(t.String({ format: "uuid" }))
|
|
286525
286537
|
});
|
|
286538
|
+
CrmInspectionModel.update = t.Partial(CrmInspectionModel.create);
|
|
286526
286539
|
CrmInspectionModel.select = t.Composite([
|
|
286527
286540
|
t.Partial(t.Object({
|
|
286528
286541
|
search: t.String(),
|
|
@@ -286561,7 +286574,9 @@ var inspectionRoutes = new Elysia({
|
|
|
286561
286574
|
userKind: "ADMIN"
|
|
286562
286575
|
}).guard({
|
|
286563
286576
|
params: IdSchema
|
|
286564
|
-
}).get("/:id", async ({ params: { id }, user: user2 }) => logic_default21.getById(id, user2)).post("/:id", async ({ params: { id }, user: user2 }) => logic_default21.approve(id, user2)).put("/:id", async ({ params: { id }, user: user2 }) => logic_default21.cancel(id, user2)).
|
|
286577
|
+
}).get("/:id", async ({ params: { id }, user: user2 }) => logic_default21.getById(id, user2)).post("/:id", async ({ params: { id }, user: user2 }) => logic_default21.approve(id, user2)).put("/:id", async ({ params: { id }, user: user2 }) => logic_default21.cancel(id, user2)).patch("/:id", async ({ params: { id }, body, user: user2 }) => logic_default21.update(id, body, user2), {
|
|
286578
|
+
body: model_default17.update
|
|
286579
|
+
}).post("/:id/service-order", async ({ params: { id }, user: user2 }) => logic_default21.createCpOrder(id, user2));
|
|
286565
286580
|
var inspection_default = inspectionRoutes;
|
|
286566
286581
|
|
|
286567
286582
|
// src/routes/crm/reports/logic.ts
|
|
@@ -287883,6 +287898,24 @@ var MsRecordProductLogic;
|
|
|
287883
287898
|
MsRecordProductLogic.remove = async (id) => {
|
|
287884
287899
|
await db_default.update(maintenanceServiceRecordProductTable).set({ deletedAt: nowSql_helper_default }).where(eq(maintenanceServiceRecordProductTable.id, id));
|
|
287885
287900
|
};
|
|
287901
|
+
const handleWarehouseQuantityChange = async (productId, quantityChange, user2, transactionDetails, tdb = db_default) => {
|
|
287902
|
+
const warehouseItems = await tdb.select().from(warehouseItemTable).where(and(eq(warehouseItemTable.productId, productId), softDeletedFilter(warehouseItemTable)));
|
|
287903
|
+
if (warehouseItems.length === 0) {
|
|
287904
|
+
return status("Not Found", "\u0410\u0433\u0443\u0443\u043B\u0430\u0445\u044B\u043D \u0431\u0430\u0440\u0430\u0430 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
|
|
287905
|
+
}
|
|
287906
|
+
const warehouseItem = warehouseItems[0];
|
|
287907
|
+
const result = await logic_default9.changeQuantity({
|
|
287908
|
+
itemId: warehouseItem.id,
|
|
287909
|
+
quantityChange: -quantityChange,
|
|
287910
|
+
transactionDetails: {
|
|
287911
|
+
transactionType: quantityChange < 0 ? "IN" : "OUT",
|
|
287912
|
+
transactionKind: "ORDER",
|
|
287913
|
+
description: transactionDetails.description || `\u0417\u0430\u0441\u0432\u0430\u0440\u044B\u043D \u0431\u0430\u0440\u0430\u0430\u043D\u044B \u0445\u043E\u0440\u043E\u0433\u0434\u043E\u043B: ${quantityChange}`,
|
|
287914
|
+
msRecordProductId: transactionDetails.msRecordProductId
|
|
287915
|
+
}
|
|
287916
|
+
}, user2, tdb);
|
|
287917
|
+
return result;
|
|
287918
|
+
};
|
|
287886
287919
|
})(MsRecordProductLogic ||= {});
|
|
287887
287920
|
var logic_default33 = MsRecordProductLogic;
|
|
287888
287921
|
|
|
@@ -290252,7 +290285,8 @@ var WarehouseItemModel;
|
|
|
290252
290285
|
"salesId",
|
|
290253
290286
|
"orderId",
|
|
290254
290287
|
"transferId",
|
|
290255
|
-
"transferItemId"
|
|
290288
|
+
"transferItemId",
|
|
290289
|
+
"msRecordProductId"
|
|
290256
290290
|
]);
|
|
290257
290291
|
WarehouseItemModel.changeQuantity = t.Object({
|
|
290258
290292
|
itemId: t.String({ format: "uuid" }),
|
|
@@ -290404,7 +290438,7 @@ var routes_default = router2;
|
|
|
290404
290438
|
// src/index.ts
|
|
290405
290439
|
var app = new Elysia().use(index_default({
|
|
290406
290440
|
origin: true,
|
|
290407
|
-
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
290441
|
+
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
290408
290442
|
credentials: true,
|
|
290409
290443
|
allowedHeaders: ["Content-Type", "Authorization", "accessToken"]
|
|
290410
290444
|
})).get("/health", () => {
|