diff --git a/src/controllers/customer-branch-controller.ts b/src/controllers/customer-branch-controller.ts index d4957b5..e6d898d 100644 --- a/src/controllers/customer-branch-controller.ts +++ b/src/controllers/customer-branch-controller.ts @@ -316,9 +316,13 @@ export class CustomerBranchController extends Controller { const record = await prisma.$transaction( async (tx) => { + const headofficeCode = customer.branch.at(0)?.code.slice(0, -3); + let runningKey = ""; - if ("citizenId" in body) { + if (headofficeCode) { + runningKey = `CUSTOMER_BRANCH_${headofficeCode}`; + } else if ("citizenId" in body) { runningKey = `CUSTOMER_BRANCH_${body.citizenId}`; } else { runningKey = `CUSTOMER_BRANCH_${body.legalPersonNo}`;