feat: also consider code from head office

This commit is contained in:
Methapon Metanipat 2024-08-20 17:35:43 +07:00
parent 8d446113da
commit c7f7713cbd

View file

@ -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}`;