From bcd765c71a12a63023c22cfb80bcaa6dfa9da727 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:48:41 +0700 Subject: [PATCH] fix: condition not cover --- src/controllers/branch-controller.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index aa808dc..e8fb801 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -330,6 +330,14 @@ export class BranchController extends Controller { ); } + if (last.value !== 1 && !headOfficeId) { + throw new HttpError( + HttpStatus.BAD_REQUEST, + "Branch with same code already exists.", + "sameBranchCodeExists", + ); + } + return await tx.branch.create({ include: { province: true,