autosync_backend2 1.2.37 → 1.2.39

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
@@ -2246,6 +2246,49 @@ export declare const app: Elysia<"", {
2246
2246
  };
2247
2247
  };
2248
2248
  };
2249
+ } & {
2250
+ branch: {
2251
+ me: {
2252
+ get: {
2253
+ body: unknown;
2254
+ params: {};
2255
+ query: unknown;
2256
+ headers: unknown;
2257
+ response: {
2258
+ 200: {
2259
+ totalCount: number;
2260
+ totalPage: number;
2261
+ result: Omit<{
2262
+ name: string;
2263
+ id: string;
2264
+ email: string | null;
2265
+ createdAt: string;
2266
+ updatedAt: string;
2267
+ deletedAt: string | null;
2268
+ oldId: number | null;
2269
+ isActive: boolean;
2270
+ regNumber: string | null;
2271
+ phone: string;
2272
+ logoUrl: string;
2273
+ province: string | null;
2274
+ district: string | null;
2275
+ khoroo: string | null;
2276
+ street: string | null;
2277
+ socialUrls: string[] | null;
2278
+ ceoName: string | null;
2279
+ googleMapUrl: string | null;
2280
+ isNoat: boolean;
2281
+ packageId: string;
2282
+ merchantId: string;
2283
+ } & {
2284
+ totalCount: number;
2285
+ }, "totalCount">[];
2286
+ };
2287
+ 401: "Session not found";
2288
+ };
2289
+ };
2290
+ };
2291
+ };
2249
2292
  } & {
2250
2293
  branch: {
2251
2294
  post: {
@@ -8916,6 +8959,63 @@ export declare const app: Elysia<"", {
8916
8959
  };
8917
8960
  };
8918
8961
  };
8962
+ } & {
8963
+ inspection: {
8964
+ ":id": {
8965
+ put: {
8966
+ body: {
8967
+ oldId?: number | null | undefined;
8968
+ state?: "CREATED" | "SCHEDULED" | "IN_PROGRESS" | "COMPLETED" | undefined;
8969
+ timeCompleted?: Date | null | undefined;
8970
+ note?: string | null | undefined;
8971
+ templateId?: string | undefined;
8972
+ machineId?: string | undefined;
8973
+ employeeInspectedId?: string | undefined;
8974
+ userInspectedId?: string | undefined;
8975
+ hours?: number | null | undefined;
8976
+ mileageKm?: number | null | undefined;
8977
+ stateResult?: "FAILED" | "NOT_INSPECTED" | "PASSED" | "RETURNED" | "WAIVED" | null | undefined;
8978
+ timeScheduled?: Date | null | undefined;
8979
+ };
8980
+ params: {
8981
+ id: string;
8982
+ };
8983
+ query: unknown;
8984
+ headers: unknown;
8985
+ response: {
8986
+ 200: {
8987
+ machineId: string;
8988
+ templateId: string;
8989
+ employeeInspectedId: string;
8990
+ userInspectedId: string;
8991
+ hours: number | null;
8992
+ mileageKm: number | null;
8993
+ state: "CREATED" | "SCHEDULED" | "IN_PROGRESS" | "COMPLETED";
8994
+ stateResult: "FAILED" | "NOT_INSPECTED" | "PASSED" | "RETURNED" | "WAIVED" | null;
8995
+ timeScheduled: Date | null;
8996
+ timeCompleted: Date | null;
8997
+ note: string | null;
8998
+ id: string;
8999
+ createdAt: string;
9000
+ updatedAt: string;
9001
+ deletedAt: string | null;
9002
+ oldId: number | null;
9003
+ };
9004
+ 401: "Session not found";
9005
+ 404: "Хяналтын үзлэг олдсонгүй.";
9006
+ 422: {
9007
+ type: "validation";
9008
+ on: string;
9009
+ summary?: string;
9010
+ message?: string;
9011
+ found?: unknown;
9012
+ property?: string;
9013
+ expected?: string;
9014
+ };
9015
+ };
9016
+ };
9017
+ };
9018
+ };
8919
9019
  };
8920
9020
  } & {
8921
9021
  fleet: {
package/dist/index.js CHANGED
@@ -146989,7 +146989,13 @@ var branchRoutes = new Elysia({
146989
146989
  }).get("/", async ({ query }) => await service2.get(query), {
146990
146990
  query: model_default2.select,
146991
146991
  userKind: "COMPANY_ADMIN"
146992
- }).post("/", async ({ body, user: user2 }) => await logic_default2.create(body, user2), {
146992
+ }).get("/me", async ({ user: user2 }) => service2.get({
146993
+ id: user2.branchId,
146994
+ pagination: {
146995
+ page: 1,
146996
+ size: 1
146997
+ }
146998
+ })).post("/", async ({ body, user: user2 }) => await logic_default2.create(body, user2), {
146993
146999
  body: model_default2.create,
146994
147000
  userKind: "COMPANY_ADMIN"
146995
147001
  }).guard({
@@ -151177,7 +151183,7 @@ var CrmCpOrderLogic;
151177
151183
  totalAmount: sql3`
151178
151184
  (
151179
151185
  (
151180
- COALESCE((select sum(${crmCpOrderItemTable.priceTotal}) from ${crmCpOrderItemTable} where ${crmCpOrderItemTable.cpOrderId} = ${crmCpOrderTable.id} and ${crmCpOrderItemTable.deletedAt} is null), 0)
151186
+ COALESCE((select sum(${crmCpOrderItemTable.priceTotal}) from ${crmCpOrderItemTable} where ${crmCpOrderItemTable.cpOrderId} = ${crmCpOrderTable.id} and ${crmCpOrderItemTable.cpOrderSpPackageId} is null and ${crmCpOrderItemTable.deletedAt} is null), 0)
151181
151187
  +
151182
151188
  COALESCE((select sum(${crmCpOrderSpPackageTable.priceTotal}) from ${crmCpOrderSpPackageTable} where ${crmCpOrderSpPackageTable.cpOrderId} = ${crmCpOrderTable.id} and ${crmCpOrderSpPackageTable.deletedAt} is null), 0)
151183
151189
  ) * CASE WHEN ${crmCpOrderTable.isNoat} THEN 1.1 ELSE 1 END
@@ -151605,12 +151611,12 @@ var DiscountLogic;
151605
151611
  });
151606
151612
  }
151607
151613
  }
151608
- await db_default.transaction(async (db2) => {
151609
- await db2.delete(crmDiscountApplyTable).where(eq(crmDiscountApplyTable.cpOrderId, cpOrderId));
151610
- if (applies.length > 0) {
151614
+ if (applies.length > 0) {
151615
+ await db_default.transaction(async (db2) => {
151616
+ await db2.delete(crmDiscountApplyTable).where(eq(crmDiscountApplyTable.cpOrderId, cpOrderId));
151611
151617
  await db2.insert(crmDiscountApplyTable).values(applies);
151612
- }
151613
- });
151618
+ });
151619
+ }
151614
151620
  };
151615
151621
  const calculateDiscountedPrice = (originalPrice, discountType, discountValue) => {
151616
151622
  if (discountType === "PERCENTAGE") {
@@ -154311,14 +154317,21 @@ var InspectionLogic;
154311
154317
  if (!user2.employeeId) {
154312
154318
  return status("Bad Request", "\u0410\u0436\u0438\u043B\u0442\u043D\u044B \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439.");
154313
154319
  }
154314
- await db_default.insert(inspectionTable).values({
154320
+ const [res] = await db_default.insert(inspectionTable).values({
154315
154321
  ...body,
154316
154322
  employeeInspectedId: user2.employeeId,
154317
154323
  userInspectedId: user2.id
154324
+ }).returning({
154325
+ id: inspectionTable.id
154318
154326
  });
154327
+ return res.id;
154319
154328
  };
154320
154329
  InspectionLogic.update = async (id, body) => {
154321
- await db_default.update(inspectionTable).set(body).where(eq(inspectionTable.id, id));
154330
+ const [result] = await db_default.update(inspectionTable).set(body).where(eq(inspectionTable.id, id)).returning();
154331
+ if (!result) {
154332
+ return status("Not Found", "\u0425\u044F\u043D\u0430\u043B\u0442\u044B\u043D \u04AF\u0437\u043B\u044D\u0433 \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
154333
+ }
154334
+ return result;
154322
154335
  };
154323
154336
  InspectionLogic.remove = async (id) => {
154324
154337
  await db_default.delete(inspectionTable).where(eq(inspectionTable.id, id));
@@ -154504,6 +154517,10 @@ var inspectionRoutes2 = new Elysia({
154504
154517
  query: model_default27.select
154505
154518
  }).post("/", async ({ body, user: user2 }) => logic_default27.create(body, user2).catch((err2) => console.error(err2)), {
154506
154519
  body: model_default27.create
154520
+ }).guard({
154521
+ params: IdSchema
154522
+ }).put("/:id", async ({ body, params: { id } }) => logic_default27.update(id, body), {
154523
+ body: model_default27.update
154507
154524
  });
154508
154525
  var inspection_default2 = inspectionRoutes2;
154509
154526
 
@@ -154571,7 +154588,7 @@ var machine_default = machineRoutes;
154571
154588
  var PmTemplateLogic;
154572
154589
  ((PmTemplateLogic) => {
154573
154590
  PmTemplateLogic.select = async (query, user2) => {
154574
- const filter = and(or(isNull2(pmTemplateTable.companyId), eq(pmTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")));
154591
+ const filter = and(or(isNull2(pmTemplateTable.companyId), eq(pmTemplateTable.companyId, user2.companyId).if(user2.kind !== "ADMIN")), softDeletedFilter(pmTemplateTable));
154575
154592
  const baseQuery = db_default.select({
154576
154593
  template: pmTemplateTable,
154577
154594
  machineKind: techdocVehicleKindTable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosync_backend2",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",