From 536e8123945147706eff9e50384564d41b2de23b Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:48:36 +0700 Subject: [PATCH 01/13] feat: include more data for template --- src/controllers/00-doc-template-controller.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/controllers/00-doc-template-controller.ts b/src/controllers/00-doc-template-controller.ts index 99dca2a..a809787 100644 --- a/src/controllers/00-doc-template-controller.ts +++ b/src/controllers/00-doc-template-controller.ts @@ -61,6 +61,13 @@ const quotationData = (id: string) => service: true, }, }, + createdBy: { + include: { + province: true, + district: true, + subDistrict: true, + }, + }, }, }); From cfe820b89f4be8fb869f7f9184ad4f0ea9cd198a Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:13:29 +0700 Subject: [PATCH 02/13] chore: remove field from include in report --- src/controllers/00-stats-controller.ts | 37 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/controllers/00-stats-controller.ts b/src/controllers/00-stats-controller.ts index 8de7899..5ae4794 100644 --- a/src/controllers/00-stats-controller.ts +++ b/src/controllers/00-stats-controller.ts @@ -7,8 +7,6 @@ import { RequestWorkStatus, PaymentStatus, User, - Invoice, - CustomerType, } from "@prisma/client"; import { Controller, Get, Query, Request, Route, Security, Tags } from "tsoa"; import prisma from "../db"; @@ -64,6 +62,7 @@ export class StatsController extends Controller { code: true, quotationStatus: true, customerBranch: { + omit: { otpCode: true, otpExpires: true, userId: true }, include: { customer: true }, }, finalPrice: true, @@ -127,7 +126,10 @@ export class StatsController extends Controller { code: true, quotation: { select: { - customerBranch: { include: { customer: true } }, + customerBranch: { + omit: { otpCode: true, otpExpires: true, userId: true }, + include: { customer: true }, + }, }, }, payment: { @@ -198,7 +200,12 @@ export class StatsController extends Controller { invoice: { select: { quotation: { - select: { customerBranch: { include: { customer: true } } }, + select: { + customerBranch: { + omit: { otpCode: true, otpExpires: true, userId: true }, + include: { customer: true }, + }, + }, }, }, }, @@ -402,6 +409,7 @@ export class StatsController extends Controller { include: { createdBy: true, customerBranch: { + omit: { otpCode: true, otpExpires: true, userId: true }, include: { customer: true }, }, }, @@ -430,9 +438,9 @@ export class StatsController extends Controller { }); return list.reduce<{ - byProductGroup: (ProductGroup & { _count: number })[]; - bySale: (User & { _count: number })[]; - byCustomer: ((CustomerBranch & { customer: Customer }) & { _count: number })[]; + byProductGroup: ((typeof list)[number]["product"]["productGroup"] & { _count: number })[]; + bySale: ((typeof list)[number]["quotation"]["createdBy"] & { _count: number })[]; + byCustomer: ((typeof list)[number]["quotation"]["customerBranch"] & { _count: number })[]; }>( (a, c) => { { @@ -683,7 +691,9 @@ export class StatsController extends Controller { { paid: number; unpaid: number; - customerBranch: CustomerBranch & { customer: Customer }; + customerBranch: CustomerBranch & { + customer: Customer; + }; }[] >((acc, item) => { const exists = acc.find((v) => v.customerBranch.id === item.customerBranch!.id); @@ -702,6 +712,15 @@ export class StatsController extends Controller { return acc; }, []) - .map((v) => ({ ...v, _quotation: undefined })); + .map((v) => ({ + ...v, + customerBranch: { + ...v.customerBranch, + userId: undefined, + otpCode: undefined, + otpExpires: undefined, + }, + _quotation: undefined, + })); } } From e76abd787cd145660fd1989d864b7b21af975d8f Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:16:14 +0700 Subject: [PATCH 03/13] feat: allow user to specify true or false cancel --- src/controllers/09-line-controller.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/09-line-controller.ts b/src/controllers/09-line-controller.ts index 4e4910d..019d942 100644 --- a/src/controllers/09-line-controller.ts +++ b/src/controllers/09-line-controller.ts @@ -784,7 +784,7 @@ export class LineController extends Controller { async customerRequestCancel( @Path() requestDataId: string, @Request() req: RequestWithLineUser, - @Body() body: { reason: string }, + @Body() body: { cancel: boolean; reason?: string }, ) { const result = await prisma.requestData.updateMany({ where: { @@ -803,8 +803,8 @@ export class LineController extends Controller { }, }, data: { - customerRequestCancel: true, - customerRequestCancelReason: body.reason, + customerRequestCancel: body.cancel, + customerRequestCancelReason: body.reason || "", }, }); if (result.count <= 0) throw notFoundError("Request Data"); @@ -815,7 +815,7 @@ export class LineController extends Controller { async customerRequestCancelWork( @Path() requestWorkId: string, @Request() req: RequestWithLineUser, - @Body() body: { reason: string }, + @Body() body: { cancel: boolean; reason?: string }, ) { const result = await prisma.requestWork.updateMany({ where: { @@ -836,8 +836,8 @@ export class LineController extends Controller { }, }, data: { - customerRequestCancel: true, - customerRequestCancelReason: body.reason, + customerRequestCancel: body.cancel, + customerRequestCancelReason: body.reason || "", }, }); if (result.count <= 0) throw notFoundError("Request Data"); From b64cd5d1a6c5f334637a94d075de55753b5c0953 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:36:39 +0700 Subject: [PATCH 04/13] feat: add reject request cancel endpoint --- prisma/schema.prisma | 4 ++ src/controllers/06-request-list-controller.ts | 62 +++++++++++++++++++ src/controllers/09-line-controller.ts | 8 ++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2286ca9..acc8cec 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1464,6 +1464,8 @@ model RequestData { customerRequestCancel Boolean? customerRequestCancelReason String? + rejectRequestCancel Boolean? + rejectRequestCancelReason String? flow Json? @@ -1502,6 +1504,8 @@ model RequestWork { customerRequestCancel Boolean? customerRequestCancelReason String? + rejectRequestCancel Boolean? + rejectRequestCancelReason String? creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull) creditNoteId String? diff --git a/src/controllers/06-request-list-controller.ts b/src/controllers/06-request-list-controller.ts index b0d78e9..bfd9712 100644 --- a/src/controllers/06-request-list-controller.ts +++ b/src/controllers/06-request-list-controller.ts @@ -239,6 +239,68 @@ export class RequestDataController extends Controller { @Route("/api/v1/request-data/{requestDataId}") @Tags("Request List") export class RequestDataActionController extends Controller { + @Post("reject-request-cancel") + @Security("keycloak") + async rejectRequestCancel( + @Request() req: RequestWithUser, + @Path() requestDataId: string, + @Body() + body: { + reason?: string; + }, + ) { + const result = await prisma.requestData.updateManyAndReturn({ + where: { + id: requestDataId, + quotation: { + registeredBranch: { + OR: permissionCond(req.user), + }, + }, + }, + data: { + rejectRequestCancel: true, + rejectRequestCancelReason: body.reason || "", + }, + }); + + if (result.length <= 0) throw notFoundError("Request Data"); + + return result[0]; + } + + @Post("request-work/${requestWorkId}/reject-request-cancel") + @Security("keycloak") + async rejectWorkRequestCancel( + @Request() req: RequestWithUser, + @Path() requestWorkId: string, + @Body() + body: { + reason?: string; + }, + ) { + const result = await prisma.requestWork.updateManyAndReturn({ + where: { + id: requestWorkId, + request: { + quotation: { + registeredBranch: { + OR: permissionCond(req.user), + }, + }, + }, + }, + data: { + rejectRequestCancel: true, + rejectRequestCancelReason: body.reason || "", + }, + }); + + if (result.length <= 0) throw notFoundError("Request Data"); + + return result[0]; + } + @Post("cancel") @Security("keycloak") async cancelRequestData(@Path() requestDataId: string) { diff --git a/src/controllers/09-line-controller.ts b/src/controllers/09-line-controller.ts index 019d942..cf8d7f3 100644 --- a/src/controllers/09-line-controller.ts +++ b/src/controllers/09-line-controller.ts @@ -804,7 +804,9 @@ export class LineController extends Controller { }, data: { customerRequestCancel: body.cancel, - customerRequestCancelReason: body.reason || "", + customerRequestCancelReason: body.reason || null, + rejectRequestCancel: false, + rejectRequestCancelReason: null, }, }); if (result.count <= 0) throw notFoundError("Request Data"); @@ -837,7 +839,9 @@ export class LineController extends Controller { }, data: { customerRequestCancel: body.cancel, - customerRequestCancelReason: body.reason || "", + customerRequestCancelReason: body.reason || null, + rejectRequestCancel: false, + rejectRequestCancelReason: null, }, }); if (result.count <= 0) throw notFoundError("Request Data"); From 1a6a19574dac2f2eb4e478153a7f49485948eed4 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:38:40 +0700 Subject: [PATCH 05/13] chore: migration --- .../20250312093832_add_reject_cancel_field/migration.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 prisma/migrations/20250312093832_add_reject_cancel_field/migration.sql diff --git a/prisma/migrations/20250312093832_add_reject_cancel_field/migration.sql b/prisma/migrations/20250312093832_add_reject_cancel_field/migration.sql new file mode 100644 index 0000000..3ec125a --- /dev/null +++ b/prisma/migrations/20250312093832_add_reject_cancel_field/migration.sql @@ -0,0 +1,7 @@ +-- AlterTable +ALTER TABLE "RequestData" ADD COLUMN "rejectRequestCancel" BOOLEAN, +ADD COLUMN "rejectRequestCancelReason" TEXT; + +-- AlterTable +ALTER TABLE "RequestWork" ADD COLUMN "rejectRequestCancel" BOOLEAN, +ADD COLUMN "rejectRequestCancelReason" TEXT; From 676bd1d16dea402b8f3a66bf14d705fcc07a0e55 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:58:36 +0700 Subject: [PATCH 06/13] fix: typo --- src/controllers/06-request-list-controller.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/controllers/06-request-list-controller.ts b/src/controllers/06-request-list-controller.ts index bfd9712..5857be2 100644 --- a/src/controllers/06-request-list-controller.ts +++ b/src/controllers/06-request-list-controller.ts @@ -269,7 +269,7 @@ export class RequestDataActionController extends Controller { return result[0]; } - @Post("request-work/${requestWorkId}/reject-request-cancel") + @Post("request-work/{requestWorkId}/reject-request-cancel") @Security("keycloak") async rejectWorkRequestCancel( @Request() req: RequestWithUser, @@ -303,7 +303,20 @@ export class RequestDataActionController extends Controller { @Post("cancel") @Security("keycloak") - async cancelRequestData(@Path() requestDataId: string) { + async cancelRequestData(@Request() req: RequestWithUser, @Path() requestDataId: string) { + const result = await prisma.requestData.findFirst({ + where: { + id: requestDataId, + quotation: { + registeredBranch: { + OR: permissionCond(req.user), + }, + }, + }, + }); + + if (!result) throw notFoundError("Request Data"); + await prisma.$transaction(async (tx) => { const workStepCondition = { requestWork: { requestDataId }, From d2c2d94a2d239dee29fdafae983998c4a844f43e Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:27:55 +0700 Subject: [PATCH 07/13] fix: prevent quotation with 0 request from status update --- src/controllers/06-request-list-controller.ts | 19 ++++++++++++++----- src/controllers/07-task-controller.ts | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/controllers/06-request-list-controller.ts b/src/controllers/06-request-list-controller.ts index 5857be2..4bf6710 100644 --- a/src/controllers/06-request-list-controller.ts +++ b/src/controllers/06-request-list-controller.ts @@ -1020,13 +1020,22 @@ export class RequestListController extends Controller { quotationStatus: { notIn: [QuotationStatus.Canceled, QuotationStatus.ProcessComplete], }, - requestData: { - every: { - requestDataStatus: { - in: [RequestDataStatus.Canceled, RequestDataStatus.Completed], + AND: [ + { + requestData: { + every: { + requestDataStatus: { + in: [RequestDataStatus.Canceled, RequestDataStatus.Completed], + }, + }, }, }, - }, + { + requestData: { + some: {}, + }, + }, + ], }, data: { quotationStatus: QuotationStatus.ProcessComplete, urgent: false }, include: { diff --git a/src/controllers/07-task-controller.ts b/src/controllers/07-task-controller.ts index d4bcfb8..2da73b2 100644 --- a/src/controllers/07-task-controller.ts +++ b/src/controllers/07-task-controller.ts @@ -819,13 +819,22 @@ export class TaskActionController extends Controller { quotationStatus: { notIn: [QuotationStatus.Canceled, QuotationStatus.ProcessComplete], }, - requestData: { - every: { - requestDataStatus: { - in: [RequestDataStatus.Canceled, RequestDataStatus.Completed], + AND: [ + { + requestData: { + every: { + requestDataStatus: { + in: [RequestDataStatus.Canceled, RequestDataStatus.Completed], + }, + }, }, }, - }, + { + requestData: { + some: {}, + }, + }, + ], }, data: { quotationStatus: QuotationStatus.ProcessComplete, urgent: false }, include: { From 65b1b516c2c4662bbb42ba8129815064c72fd9a0 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:22:53 +0700 Subject: [PATCH 08/13] fix: wrong search condition --- src/controllers/08-credit-note-controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/08-credit-note-controller.ts b/src/controllers/08-credit-note-controller.ts index f0e3fbd..e5d2759 100644 --- a/src/controllers/08-credit-note-controller.ts +++ b/src/controllers/08-credit-note-controller.ts @@ -146,8 +146,8 @@ export class CreditNoteController extends Controller { ) { const where = { OR: queryOrNot(query, [ + { code: { contains: query, mode: "insensitive" } }, { - code: { contains: query, mode: "insensitive" }, requestWork: { some: { request: { From 8dcec9ac96b1f4d40b406ccb222a97e665416d48 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:17:21 +0700 Subject: [PATCH 09/13] feat: add manual endpoint --- src/controllers/10-manual-controller.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/controllers/10-manual-controller.ts diff --git a/src/controllers/10-manual-controller.ts b/src/controllers/10-manual-controller.ts new file mode 100644 index 0000000..f4e9a0e --- /dev/null +++ b/src/controllers/10-manual-controller.ts @@ -0,0 +1,25 @@ +import express from "express"; +import { Controller, Get, Path, Request, Route } from "tsoa"; +import { getFile } from "../utils/minio"; + +@Route("api/v1/manual") +export class ManualController extends Controller { + @Get() + async get(@Request() req: express.Request) { + return req.res?.redirect(await getFile(".manual/toc.json")); + } + + @Get("{category}/assets/{name}") + async getAsset(@Request() req: express.Request, @Path() category: string, @Path() name: string) { + return req.res?.redirect(await getFile(`.manual/${category}/assets/${name}`)); + } + + @Get("{category}/page/{page}") + async getContent( + @Request() req: express.Request, + @Path() category: string, + @Path() page: string, + ) { + return req.res?.redirect(await getFile(`.manual/${category}/${page}.md`)); + } +} From 0d002e59bd892d3d34daa5db4d91a509ba946c6e Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:20:18 +0700 Subject: [PATCH 10/13] chore: change file location --- src/utils/minio.ts | 63 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/utils/minio.ts b/src/utils/minio.ts index ba02cac..4d708ed 100644 --- a/src/utils/minio.ts +++ b/src/utils/minio.ts @@ -57,69 +57,76 @@ export async function deleteFolder(path: string) { export const fileLocation = { branch: { - line: (branchId: string) => `branch/line-qr-${branchId}`, - bank: (branchId: string, bankId: string) => `branch/bank-qr-${branchId}-${bankId}`, - img: (branchId: string, name?: string) => `branch/img-${branchId}/${name || ""}`, - attachment: (branchId: string, name?: string) => `branch/attachment-${branchId}/${name || ""}`, + line: (branchId: string) => `.system/branch/line-qr-${branchId}`, + bank: (branchId: string, bankId: string) => `.system/branch/bank-qr-${branchId}-${bankId}`, + img: (branchId: string, name?: string) => `.system/branch/img-${branchId}/${name || ""}`, + attachment: (branchId: string, name?: string) => + `.system/branch/attachment-${branchId}/${name || ""}`, }, user: { - profile: (userId: string, name?: string) => `user/profile-image-${userId}/${name || ""}`, - attachment: (userId: string, name?: string) => `user/attachment-${userId}/${name || ""}`, + profile: (userId: string, name?: string) => + `.system/user/profile-image-${userId}/${name || ""}`, + attachment: (userId: string, name?: string) => + `.system/user/attachment-${userId}/${name || ""}`, }, customer: { - img: (customerId: string, name?: string) => `customer/img-${customerId}/${name || ""}`, + img: (customerId: string, name?: string) => `.system/customer/img-${customerId}/${name || ""}`, }, customerBranch: { attachment: (customerBranchId: string, name?: string) => - `customer-branch/attachment-${customerBranchId}/${name || ""}`, + `.system/customer-branch/attachment-${customerBranchId}/${name || ""}`, citizen: (customerBranchId: string, citizenId?: string) => - `customer-branch/citizen-${customerBranchId}/${citizenId || ""}`, + `.system/customer-branch/citizen-${customerBranchId}/${citizenId || ""}`, houseRegistration: (customerBranchId: string, houseRegistrationId?: string) => - `customer-branch/house-registration-${customerBranchId}/${houseRegistrationId || ""}`, + `.system/customer-branch/house-registration-${customerBranchId}/${houseRegistrationId || ""}`, commercialRegistration: (customerBranchId: string, commercialRegistrationId?: string) => - `customer-branch/commercial-registration-${customerBranchId}/${commercialRegistrationId || ""}`, + `.system/customer-branch/commercial-registration-${customerBranchId}/${commercialRegistrationId || ""}`, vatRegistration: (customerBranchId: string, vatRegistrationId?: string) => - `customer-branch/vat-registration-${customerBranchId}/${vatRegistrationId || ""}`, + `.system/customer-branch/vat-registration-${customerBranchId}/${vatRegistrationId || ""}`, powerOfAttorney: (customerBranchId: string, powerOfAttorneyId?: string) => - `customer-branch/power-of-attorney-${customerBranchId}/${powerOfAttorneyId || ""}`, + `.system/customer-branch/power-of-attorney-${customerBranchId}/${powerOfAttorneyId || ""}`, }, employee: { - img: (employeeId: string, name?: string) => `employee/img-${employeeId}/${name || ""}`, + img: (employeeId: string, name?: string) => `.system/employee/img-${employeeId}/${name || ""}`, attachment: (employeeId: string, name?: string) => - `employee/attachment-${employeeId}/${name || ""}`, - visa: (employeeId: string, visaId?: string) => `employee/visa-${employeeId}/${visaId || ""}`, + `.system/employee/attachment-${employeeId}/${name || ""}`, + visa: (employeeId: string, visaId?: string) => + `.system/employee/visa-${employeeId}/${visaId || ""}`, passport: (employeeId: string, passportId?: string) => - `employee/passport-${employeeId}/${passportId || ""}`, + `.system/employee/passport-${employeeId}/${passportId || ""}`, inCountryNotice: (employeeId: string, noticeId?: string) => - `employee/in-country-notice-${employeeId}/${noticeId || ""}`, + `.system/employee/in-country-notice-${employeeId}/${noticeId || ""}`, }, product: { - img: (productId: string, name?: string) => `product/img-${productId}/${name || ""}`, + img: (productId: string, name?: string) => `.system/product/img-${productId}/${name || ""}`, }, service: { - img: (serviceId: string, name?: string) => `service/img-${serviceId}/${name || ""}`, + img: (serviceId: string, name?: string) => `.system/service/img-${serviceId}/${name || ""}`, }, quotation: { attachment: (quotationId: string, name?: string) => - `quotation/attachment-${quotationId}/${name || ""}`, + `.system/quotation/attachment-${quotationId}/${name || ""}`, payment: (quotationId: string, paymentId: string, name?: string) => - `quotation/payment-${quotationId}/${paymentId}/${name || ""}`, + `.system/quotation/payment-${quotationId}/${paymentId}/${name || ""}`, }, request: { attachment: (requestId: string, step: number, name?: string) => - `request/attachment-${requestId}-${step}/${name || ""}`, + `.system/request/attachment-${requestId}-${step}/${name || ""}`, }, institution: { attachment: (institutionId: string, name?: string) => - `institution/attachment-${institutionId}/${name || ""}`, - img: (institutionId: string, name?: string) => `institution/img-${institutionId}/${name || ""}`, + `.system/institution/attachment-${institutionId}/${name || ""}`, + img: (institutionId: string, name?: string) => + `.system/institution/img-${institutionId}/${name || ""}`, }, task: { - attachment: (taskId: string, name?: string) => `task/attachment-${taskId}/${name || ""}`, + attachment: (taskId: string, name?: string) => + `.system/task/attachment-${taskId}/${name || ""}`, }, creditNote: { - slip: (creditNoteId: string, name?: string) => `credit-note/slip-${creditNoteId}/${name || ""}`, + slip: (creditNoteId: string, name?: string) => + `.system/credit-note/slip-${creditNoteId}/${name || ""}`, attachment: (creditNoteId: string, name?: string) => - `credit-note/attachment-${creditNoteId}/${name || ""}`, + `.system/credit-note/attachment-${creditNoteId}/${name || ""}`, }, }; From 11c3ce42720adfd633a8fe99c7be52fcf4cc73bb Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 18 Mar 2025 10:26:53 +0700 Subject: [PATCH 11/13] refactor: extract root folder into variable --- src/utils/minio.ts | 58 ++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/utils/minio.ts b/src/utils/minio.ts index 4d708ed..dc5e244 100644 --- a/src/utils/minio.ts +++ b/src/utils/minio.ts @@ -55,78 +55,80 @@ export async function deleteFolder(path: string) { }); } +const ROOT = ".system"; + export const fileLocation = { branch: { - line: (branchId: string) => `.system/branch/line-qr-${branchId}`, - bank: (branchId: string, bankId: string) => `.system/branch/bank-qr-${branchId}-${bankId}`, - img: (branchId: string, name?: string) => `.system/branch/img-${branchId}/${name || ""}`, + line: (branchId: string) => `${ROOT}/branch/line-qr-${branchId}`, + bank: (branchId: string, bankId: string) => `${ROOT}/branch/bank-qr-${branchId}-${bankId}`, + img: (branchId: string, name?: string) => `${ROOT}/branch/img-${branchId}/${name || ""}`, attachment: (branchId: string, name?: string) => - `.system/branch/attachment-${branchId}/${name || ""}`, + `${ROOT}/branch/attachment-${branchId}/${name || ""}`, }, user: { profile: (userId: string, name?: string) => - `.system/user/profile-image-${userId}/${name || ""}`, + `${ROOT}/user/profile-image-${userId}/${name || ""}`, attachment: (userId: string, name?: string) => - `.system/user/attachment-${userId}/${name || ""}`, + `${ROOT}/user/attachment-${userId}/${name || ""}`, }, customer: { - img: (customerId: string, name?: string) => `.system/customer/img-${customerId}/${name || ""}`, + img: (customerId: string, name?: string) => `${ROOT}/customer/img-${customerId}/${name || ""}`, }, customerBranch: { attachment: (customerBranchId: string, name?: string) => - `.system/customer-branch/attachment-${customerBranchId}/${name || ""}`, + `${ROOT}/customer-branch/attachment-${customerBranchId}/${name || ""}`, citizen: (customerBranchId: string, citizenId?: string) => - `.system/customer-branch/citizen-${customerBranchId}/${citizenId || ""}`, + `${ROOT}/customer-branch/citizen-${customerBranchId}/${citizenId || ""}`, houseRegistration: (customerBranchId: string, houseRegistrationId?: string) => - `.system/customer-branch/house-registration-${customerBranchId}/${houseRegistrationId || ""}`, + `${ROOT}/customer-branch/house-registration-${customerBranchId}/${houseRegistrationId || ""}`, commercialRegistration: (customerBranchId: string, commercialRegistrationId?: string) => - `.system/customer-branch/commercial-registration-${customerBranchId}/${commercialRegistrationId || ""}`, + `${ROOT}/customer-branch/commercial-registration-${customerBranchId}/${commercialRegistrationId || ""}`, vatRegistration: (customerBranchId: string, vatRegistrationId?: string) => - `.system/customer-branch/vat-registration-${customerBranchId}/${vatRegistrationId || ""}`, + `${ROOT}/customer-branch/vat-registration-${customerBranchId}/${vatRegistrationId || ""}`, powerOfAttorney: (customerBranchId: string, powerOfAttorneyId?: string) => - `.system/customer-branch/power-of-attorney-${customerBranchId}/${powerOfAttorneyId || ""}`, + `${ROOT}/customer-branch/power-of-attorney-${customerBranchId}/${powerOfAttorneyId || ""}`, }, employee: { - img: (employeeId: string, name?: string) => `.system/employee/img-${employeeId}/${name || ""}`, + img: (employeeId: string, name?: string) => `${ROOT}/employee/img-${employeeId}/${name || ""}`, attachment: (employeeId: string, name?: string) => - `.system/employee/attachment-${employeeId}/${name || ""}`, + `${ROOT}/employee/attachment-${employeeId}/${name || ""}`, visa: (employeeId: string, visaId?: string) => - `.system/employee/visa-${employeeId}/${visaId || ""}`, + `${ROOT}/employee/visa-${employeeId}/${visaId || ""}`, passport: (employeeId: string, passportId?: string) => - `.system/employee/passport-${employeeId}/${passportId || ""}`, + `${ROOT}/employee/passport-${employeeId}/${passportId || ""}`, inCountryNotice: (employeeId: string, noticeId?: string) => - `.system/employee/in-country-notice-${employeeId}/${noticeId || ""}`, + `${ROOT}/employee/in-country-notice-${employeeId}/${noticeId || ""}`, }, product: { - img: (productId: string, name?: string) => `.system/product/img-${productId}/${name || ""}`, + img: (productId: string, name?: string) => `${ROOT}/product/img-${productId}/${name || ""}`, }, service: { - img: (serviceId: string, name?: string) => `.system/service/img-${serviceId}/${name || ""}`, + img: (serviceId: string, name?: string) => `${ROOT}/service/img-${serviceId}/${name || ""}`, }, quotation: { attachment: (quotationId: string, name?: string) => - `.system/quotation/attachment-${quotationId}/${name || ""}`, + `${ROOT}/quotation/attachment-${quotationId}/${name || ""}`, payment: (quotationId: string, paymentId: string, name?: string) => - `.system/quotation/payment-${quotationId}/${paymentId}/${name || ""}`, + `${ROOT}/quotation/payment-${quotationId}/${paymentId}/${name || ""}`, }, request: { attachment: (requestId: string, step: number, name?: string) => - `.system/request/attachment-${requestId}-${step}/${name || ""}`, + `${ROOT}/request/attachment-${requestId}-${step}/${name || ""}`, }, institution: { attachment: (institutionId: string, name?: string) => - `.system/institution/attachment-${institutionId}/${name || ""}`, + `${ROOT}/institution/attachment-${institutionId}/${name || ""}`, img: (institutionId: string, name?: string) => - `.system/institution/img-${institutionId}/${name || ""}`, + `${ROOT}/institution/img-${institutionId}/${name || ""}`, }, task: { attachment: (taskId: string, name?: string) => - `.system/task/attachment-${taskId}/${name || ""}`, + `${ROOT}/task/attachment-${taskId}/${name || ""}`, }, creditNote: { slip: (creditNoteId: string, name?: string) => - `.system/credit-note/slip-${creditNoteId}/${name || ""}`, + `${ROOT}/credit-note/slip-${creditNoteId}/${name || ""}`, attachment: (creditNoteId: string, name?: string) => - `.system/credit-note/attachment-${creditNoteId}/${name || ""}`, + `${ROOT}/credit-note/attachment-${creditNoteId}/${name || ""}`, }, }; From 46dea5514ea6b77111ce58fc647179e7e6401d5a Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 18 Mar 2025 10:27:07 +0700 Subject: [PATCH 12/13] chore: add debug script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index eafc24f..6133081 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dev": "nodemon", "check": "tsc --noEmit", "format": "prettier --write .", + "debug": "nodemon", "build": "tsoa spec-and-routes && tsc", "changelog:generate": "git-cliff -o CHANGELOG.md && git add CHANGELOG.md && git commit -m 'Update CHANGELOG.md'", "db:generate": "prisma generate", From c5d250ab0cfcd40dbabcf93b1815bd2ad773d350 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 18 Mar 2025 10:27:21 +0700 Subject: [PATCH 13/13] chore: remove unsued --- src/controllers/00-stats-controller.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/controllers/00-stats-controller.ts b/src/controllers/00-stats-controller.ts index 5ae4794..b4aef31 100644 --- a/src/controllers/00-stats-controller.ts +++ b/src/controllers/00-stats-controller.ts @@ -2,11 +2,9 @@ import config from "../config.json"; import { Customer, CustomerBranch, - ProductGroup, QuotationStatus, RequestWorkStatus, PaymentStatus, - User, } from "@prisma/client"; import { Controller, Get, Query, Request, Route, Security, Tags } from "tsoa"; import prisma from "../db";