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,