diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index df5f785..49edaa3 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -238,6 +238,13 @@ export class BranchController extends Controller { @Body() body: BranchUpdate, @Path() branchId: string, ) { + if (body.headOfficeId === branchId) + throw new HttpError( + HttpStatus.BAD_REQUEST, + "Cannot make this as head office and branch at the same time.", + "missing_or_invalid_parameter", + ); + if (body.subDistrictId || body.districtId || body.provinceId || body.headOfficeId) { const [province, district, subDistrict, branch] = await prisma.$transaction([ prisma.province.findFirst({ where: { id: body.provinceId || undefined } }),