From 95d657f7e293c7c9687d55939e91bc97f8c3051c Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Tue, 27 Aug 2024 09:56:33 +0700 Subject: [PATCH] fix: wrong length slice --- src/controllers/branch-controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index 22692e0..6de8699 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -300,7 +300,7 @@ export class BranchController extends Controller { const { provinceId, districtId, subDistrictId, headOfficeId, bank, contact, code, ...rest } = body; - if (headOfficeId && head && head.code.slice(0, -6) !== code) { + if (headOfficeId && head && head.code.slice(0, -5) !== code) { throw new HttpError( HttpStatus.BAD_REQUEST, "Headoffice code not match with branch code", @@ -572,7 +572,7 @@ export class BranchController extends Controller { if (record.isHeadOffice) { await tx.runningNo.delete({ where: { - key: `MAIN_BRANCH_${record.code.slice(0, -6)}`, + key: `MAIN_BRANCH_${record.code.slice(0, -5)}`, }, }); }