From 2d056d3b567bab361be704dc6a76862561cdb557 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 26 Aug 2024 13:15:23 +0700 Subject: [PATCH] change: branch code now have 5 digit --- src/controllers/branch-controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index bf7d721..22692e0 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -180,9 +180,9 @@ export class BranchController extends Controller { ) { const where = { AND: { + zipCode, headOfficeId: headOfficeId ?? (filter === "head" || tree ? null : undefined), NOT: { headOfficeId: filter === "sub" && !headOfficeId ? null : undefined }, - zipCode, }, OR: [ { nameEN: { contains: query } }, @@ -323,7 +323,7 @@ export class BranchController extends Controller { if (last.value === 1) { const exist = await tx.branch.findFirst({ - where: { code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(6, "0")}` }, + where: { code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(5, "0")}` }, }); if (exist) throw new HttpError( @@ -352,7 +352,7 @@ export class BranchController extends Controller { data: { ...rest, statusOrder: +(rest.status === "INACTIVE"), - code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(6, "0")}`, + code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(5, "0")}`, bank: bank ? { createMany: { data: bank } } : undefined, isHeadOffice: !headOfficeId, contact: {