autosync_backend2 1.2.15 → 1.2.17

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 CHANGED
@@ -1011,6 +1011,7 @@ export declare const app: Elysia<"", {
1011
1011
  warehouseId: string;
1012
1012
  productId: string;
1013
1013
  quantity: number;
1014
+ quantityUnit: number;
1014
1015
  safetyStock: number;
1015
1016
  shelfNumber: string | null;
1016
1017
  description: string | null;
@@ -1088,6 +1089,7 @@ export declare const app: Elysia<"", {
1088
1089
  oldId?: number | null | undefined;
1089
1090
  description?: string | null | undefined;
1090
1091
  quantity?: number | undefined;
1092
+ quantityUnit?: number | undefined;
1091
1093
  shelfNumber?: string | null | undefined;
1092
1094
  isOrdered?: boolean | undefined;
1093
1095
  productId: string;
@@ -1108,6 +1110,7 @@ export declare const app: Elysia<"", {
1108
1110
  quantity: number;
1109
1111
  productId: string;
1110
1112
  warehouseId: string;
1113
+ quantityUnit: number;
1111
1114
  safetyStock: number;
1112
1115
  shelfNumber: string | null;
1113
1116
  isOrdered: boolean;
@@ -1132,6 +1135,7 @@ export declare const app: Elysia<"", {
1132
1135
  oldId?: number | null | undefined;
1133
1136
  description?: string | null | undefined;
1134
1137
  quantity?: number | undefined;
1138
+ quantityUnit?: number | undefined;
1135
1139
  shelfNumber?: string | null | undefined;
1136
1140
  isOrdered?: boolean | undefined;
1137
1141
  productId: string;
@@ -1223,6 +1227,7 @@ export declare const app: Elysia<"", {
1223
1227
  warehouseId: string;
1224
1228
  productId: string;
1225
1229
  quantity: number;
1230
+ quantityUnit: number;
1226
1231
  safetyStock: number;
1227
1232
  shelfNumber: string | null;
1228
1233
  description: string | null;
@@ -1296,6 +1301,7 @@ export declare const app: Elysia<"", {
1296
1301
  warehouseId: string;
1297
1302
  productId: string;
1298
1303
  quantity: number;
1304
+ quantityUnit: number;
1299
1305
  safetyStock: number;
1300
1306
  shelfNumber: string | null;
1301
1307
  description: string | null;
@@ -1326,10 +1332,12 @@ export declare const app: Elysia<"", {
1326
1332
  ":id": {
1327
1333
  put: {
1328
1334
  body: {
1335
+ deletedAt?: string | null | undefined;
1329
1336
  oldId?: number | null | undefined;
1330
1337
  description?: string | null | undefined;
1331
1338
  productId?: string | undefined;
1332
1339
  warehouseId?: string | undefined;
1340
+ quantityUnit?: number | undefined;
1333
1341
  safetyStock?: number | undefined;
1334
1342
  shelfNumber?: string | null | undefined;
1335
1343
  isOrdered?: boolean | undefined;
@@ -1344,6 +1352,7 @@ export declare const app: Elysia<"", {
1344
1352
  warehouseId: string;
1345
1353
  productId: string;
1346
1354
  quantity: number;
1355
+ quantityUnit: number;
1347
1356
  safetyStock: number;
1348
1357
  shelfNumber: string | null;
1349
1358
  description: string | null;
@@ -7040,6 +7049,47 @@ export declare const app: Elysia<"", {
7040
7049
  };
7041
7050
  };
7042
7051
  };
7052
+ } & {
7053
+ reports: {
7054
+ "cp-order": {
7055
+ get: {
7056
+ body: unknown;
7057
+ params: {};
7058
+ query: {
7059
+ type: "Service" | "Product";
7060
+ };
7061
+ headers: unknown;
7062
+ response: {
7063
+ 200: {
7064
+ createdAt: string | null;
7065
+ orderId: string | null;
7066
+ phone: string | null;
7067
+ licensePlate: string | null;
7068
+ name: string | null;
7069
+ partNumber: string | null;
7070
+ employeeName: unknown;
7071
+ quantity: number;
7072
+ priceBuy: number | null;
7073
+ price: number;
7074
+ discount: unknown;
7075
+ priceAfterDiscount: number | null;
7076
+ totalPrice: unknown;
7077
+ totalPriceNoat: unknown;
7078
+ }[];
7079
+ 401: "Session not found";
7080
+ 422: {
7081
+ type: "validation";
7082
+ on: string;
7083
+ summary?: string;
7084
+ message?: string;
7085
+ found?: unknown;
7086
+ property?: string;
7087
+ expected?: string;
7088
+ };
7089
+ };
7090
+ };
7091
+ };
7092
+ };
7043
7093
  };
7044
7094
  };
7045
7095
  } & {
package/dist/index.js CHANGED
@@ -142990,6 +142990,7 @@ var warehouseItemTable = warehouseSchema.table("item", {
142990
142990
  warehouseId: uuid5().notNull(),
142991
142991
  productId: uuid5().notNull(),
142992
142992
  quantity: numeric({ mode: "number" }).notNull().default(0),
142993
+ quantityUnit: integer2().notNull().default(1),
142993
142994
  safetyStock: numeric({ mode: "number" }).notNull(),
142994
142995
  shelfNumber: varchar(),
142995
142996
  description: text(),
@@ -146088,7 +146089,7 @@ var requestLogger = new Elysia({ name: "Middleware.RequestLogger" }).onRequest((
146088
146089
  },
146089
146090
  query: url2.searchParams
146090
146091
  });
146091
- }).onAfterResponse(async ({ request, response, server, status: status2, set: set2, body, headers }) => {
146092
+ }).onAfterResponse(async ({ request, responseValue, server, status: status2, set: set2, body, headers }) => {
146092
146093
  logger2.info({
146093
146094
  msg: "Outgoing response",
146094
146095
  method: request.method,
@@ -146101,8 +146102,8 @@ var requestLogger = new Elysia({ name: "Middleware.RequestLogger" }).onRequest((
146101
146102
  headers,
146102
146103
  body
146103
146104
  },
146104
- response,
146105
- ipAddress: headers["X-FORWARDED_FOR"] ?? server?.requestIP(request)?.address,
146105
+ response: responseValue,
146106
+ ipAddress: headers?.["X-FORWARDED_FOR"] ?? server?.requestIP(request)?.address,
146106
146107
  method: request.method,
146107
146108
  path: request.url,
146108
146109
  statusCode: set2.status?.toString() ?? "200",
@@ -147251,7 +147252,8 @@ var WarehouseItemLogic;
147251
147252
  return status("Bad Request", "\u0411\u0430\u0440\u0430\u0430\u043D\u044B \u04AF\u043B\u0434\u044D\u0433\u0434\u044D\u043B \u0445\u04AF\u0440\u044D\u043B\u0446\u044D\u0445\u0433\u04AF\u0439 \u0431\u0430\u0439\u043D\u0430.");
147252
147253
  }
147253
147254
  const [updatedItem] = await tdb.update(warehouseItemTable).set({
147254
- quantity: quantityAfter
147255
+ quantity: quantityAfter,
147256
+ deletedAt: null
147255
147257
  }).where(eq(warehouseItemTable.id, itemId)).returning();
147256
147258
  await tdb.insert(warehouseItemTransactionTable).values({
147257
147259
  itemId,
@@ -147284,7 +147286,7 @@ var CrmCpOrderItemLogic;
147284
147286
  ((CrmCpOrderItemLogic) => {
147285
147287
  CrmCpOrderItemLogic.select = async ({ cpOrderId }) => {
147286
147288
  const filter = and(eq(crmCpOrderItemTable.cpOrderId, cpOrderId), softDeletedFilter(crmCpOrderItemTable));
147287
- const rows = await db_default.select().from(crmCpOrderItemTable).leftJoin(companyServiceKindTable, eq(companyServiceKindTable.id, crmCpOrderItemTable.companyServiceKindId)).leftJoin(warehouseProductTable, eq(warehouseProductTable.id, crmCpOrderItemTable.companyProductId)).leftJoin(crmCpOrderItemEmployeeTable, eq(crmCpOrderItemEmployeeTable.cpOrderItemId, crmCpOrderItemTable.id)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmCpOrderItemEmployeeTable.employeeId)).leftJoin(crmCpOrderSpPackageTable, eq(crmCpOrderSpPackageTable.cpOrderId, crmCpOrderItemTable.cpOrderId)).leftJoin(crmSpPackageTable, eq(crmSpPackageTable.id, crmCpOrderSpPackageTable.spPackageId)).where(filter);
147289
+ const rows = await db_default.select().from(crmCpOrderItemTable).leftJoin(companyServiceKindTable, eq(companyServiceKindTable.id, crmCpOrderItemTable.companyServiceKindId)).leftJoin(warehouseProductTable, eq(warehouseProductTable.id, crmCpOrderItemTable.companyProductId)).leftJoin(crmCpOrderItemEmployeeTable, eq(crmCpOrderItemEmployeeTable.cpOrderItemId, crmCpOrderItemTable.id)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmCpOrderItemEmployeeTable.employeeId)).leftJoin(crmCpOrderSpPackageTable, eq(crmCpOrderSpPackageTable.id, crmCpOrderItemTable.cpOrderSpPackageId)).leftJoin(crmSpPackageTable, eq(crmSpPackageTable.id, crmCpOrderSpPackageTable.spPackageId)).where(filter);
147288
147290
  const result = rows.reduce((acc, row) => {
147289
147291
  if (!acc[row.cp_order_item.id]) {
147290
147292
  acc[row.cp_order_item.id] = {
@@ -147338,7 +147340,7 @@ var CrmCpOrderItemLogic;
147338
147340
  }
147339
147341
  const curr = await db_default.select({
147340
147342
  id: crmCpOrderItemTable.id
147341
- }).from(crmCpOrderItemTable).where(and(eq(crmCpOrderItemTable.cpOrderId, body.cpOrderId), eq(crmCpOrderItemTable.companyServiceKindId, body.companyServiceKindId ?? "").if(body.companyServiceKindId), eq(crmCpOrderItemTable.companyProductId, body.companyProductId ?? "").if(body.companyProductId)));
147343
+ }).from(crmCpOrderItemTable).where(and(eq(crmCpOrderItemTable.cpOrderId, body.cpOrderId), eq(crmCpOrderItemTable.companyServiceKindId, body.companyServiceKindId ?? "").if(body.companyServiceKindId), eq(crmCpOrderItemTable.companyProductId, body.companyProductId ?? "").if(body.companyProductId), isNull2(crmCpOrderItemTable.cpOrderSpPackageId)));
147342
147344
  if (curr.length > 0) {
147343
147345
  const [updated] = await db_default.update(crmCpOrderItemTable).set({
147344
147346
  ...body,
@@ -147412,7 +147414,11 @@ var CrmCpOrderItemLogic;
147412
147414
  priceTotal: item.quantity * (item.priceUnit ?? serviceKind?.price ?? product?.product.priceSell ?? 0)
147413
147415
  });
147414
147416
  }
147415
- const currentValues = await db_default.select().from(crmCpOrderItemTable).where(and(eq(crmCpOrderItemTable.cpOrderId, insertValues[0].cpOrderId), or(inArray(crmCpOrderItemTable.companyProductId, insertValues.map((i2) => i2.companyProductId).filter((i2) => !!i2)), inArray(crmCpOrderItemTable.companyServiceKindId, insertValues.map((i2) => i2.companyServiceKindId).filter((i2) => !!i2)))));
147417
+ const currentValues = await db_default.select().from(crmCpOrderItemTable).where(and(eq(crmCpOrderItemTable.cpOrderId, insertValues[0].cpOrderId), or(...insertValues.map((i2) => {
147418
+ if (!i2.companyProductId && !i2.companyServiceKindId)
147419
+ return null;
147420
+ return and(eq(crmCpOrderItemTable.companyProductId, i2.companyProductId).if(i2.companyProductId), eq(crmCpOrderItemTable.companyServiceKindId, i2.companyServiceKindId).if(i2.companyServiceKindId), i2.cpOrderSpPackageId ? eq(crmCpOrderItemTable.cpOrderSpPackageId, i2.cpOrderSpPackageId) : isNull2(crmCpOrderItemTable.cpOrderSpPackageId));
147421
+ }).filter((i2) => !!i2))));
147416
147422
  if (currentValues.length > 0) {
147417
147423
  return status("Bad Request", "\u0411\u043E\u0440\u043B\u0443\u0443\u043B\u0430\u043B\u0442\u044B\u043D \u04AF\u0439\u043B\u0447\u0438\u043B\u0433\u044D\u044D \u044D\u0441\u0432\u044D\u043B \u0431\u0430\u0440\u0430\u0430 \u0430\u043B\u044C \u0445\u044D\u0434\u0438\u0439\u043D \u043E\u0440\u0441\u043E\u043D \u0431\u0430\u0439\u043D\u0430.");
147418
147424
  }
@@ -152208,7 +152214,7 @@ var CrmReportsLogic;
152208
152214
  ]);
152209
152215
  return formatCSV(headers, rows);
152210
152216
  };
152211
- CrmReportsLogic.cpOrderReport = async () => {
152217
+ CrmReportsLogic.cpOrderReport = async (query, user2) => {
152212
152218
  const result = await db_default.select({
152213
152219
  createdAt: crmCpOrderTable.createdAt,
152214
152220
  orderId: crmCpOrderTable.orderId,
@@ -152224,7 +152230,7 @@ var CrmReportsLogic;
152224
152230
  priceAfterDiscount: crmDiscountApplyTable.priceAfterDiscount,
152225
152231
  totalPrice: sql3`CASE WHEN ${crmCpOrderTable.isNoat} = FALSE THEN ${crmCpOrderItemTable.priceTotal} ELSE 0 END`.as("total_price"),
152226
152232
  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) => [
152233
+ }).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
152234
  t2.createdAt,
152229
152235
  t2.orderId,
152230
152236
  t2.phone,
@@ -152325,6 +152331,12 @@ var CrmReportsModel;
152325
152331
  totalPages: t.Number()
152326
152332
  })
152327
152333
  });
152334
+ CrmReportsModel.cpOrderReport = t.Object({
152335
+ type: t.UnionEnum(["Product", "Service"])
152336
+ });
152337
+ CrmReportsModel.cpOrderEmployeeReport = t.Object({
152338
+ employeeId: t.String({ format: "uuid" })
152339
+ });
152328
152340
  })(CrmReportsModel ||= {});
152329
152341
  var model_default14 = CrmReportsModel;
152330
152342
 
@@ -152379,6 +152391,8 @@ var reportsRoutes = new Elysia({
152379
152391
  return csvData;
152380
152392
  }, {
152381
152393
  query: model_default14.csvExportQuery
152394
+ }).get("/cp-order", ({ query, user: user2 }) => logic_default18.cpOrderReport(query, user2), {
152395
+ query: model_default14.cpOrderReport
152382
152396
  });
152383
152397
  var reports_default = reportsRoutes;
152384
152398
 
@@ -153360,7 +153374,10 @@ var WarehouseItemModel;
153360
153374
  const createSchema = createInsertSchema(warehouseItemTable);
153361
153375
  const updateSchema = createUpdateSchema(warehouseItemTable);
153362
153376
  WarehouseItemModel.create = OmitBaseSchema(createSchema);
153363
- WarehouseItemModel.update = t.Omit(OmitBaseSchema(updateSchema), ["quantity"]);
153377
+ WarehouseItemModel.update = t.Composite([
153378
+ t.Omit(OmitBaseSchema(updateSchema), ["quantity"]),
153379
+ t.Pick(updateSchema, ["deletedAt"])
153380
+ ]);
153364
153381
  WarehouseItemModel.createMany = t.Array(WarehouseItemModel.create, {
153365
153382
  minItems: 1
153366
153383
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",