From 3a8bb7a82d6b43461bc05de20ce614df7918df01 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 16 Sep 2024 16:36:02 +0700 Subject: [PATCH] fix: customer code should not have company code --- src/controllers/03-customer-branch-controller.ts | 4 ++-- src/controllers/03-customer-controller.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/03-customer-branch-controller.ts b/src/controllers/03-customer-branch-controller.ts index 0f8e9ca..c1f4045 100644 --- a/src/controllers/03-customer-branch-controller.ts +++ b/src/controllers/03-customer-branch-controller.ts @@ -390,8 +390,8 @@ export class CustomerBranchController extends Controller { }, data: { ...rest, - code: `${runningKey.replace("CUSTOMER_BRANCH_", "")}-${`${last.value - 1}`.padStart(2, "0")}`, - codeCustomer: runningKey.replace("CUSTOMER_BRANCH_", ""), + code: `${runningKey.replace(`CUSTOMER_BRANCH_${company}_`, "")}-${`${last.value - 1}`.padStart(2, "0")}`, + codeCustomer: runningKey.replace(`CUSTOMER_BRANCH_${company}_`, ""), customer: { connect: { id: customerId } }, province: { connect: provinceId ? { id: provinceId } : undefined }, district: { connect: districtId ? { id: districtId } : undefined }, diff --git a/src/controllers/03-customer-controller.ts b/src/controllers/03-customer-controller.ts index efd8b79..4b25b4e 100644 --- a/src/controllers/03-customer-controller.ts +++ b/src/controllers/03-customer-controller.ts @@ -298,8 +298,8 @@ export class CustomerController extends Controller { branch: { create: branch.map((v, i) => ({ ...v, - code: `${runningKey.replace("CUSTOMER_BRANCH_", "")}-${`${last.value - branch.length + i}`.padStart(2, "0")}`, - codeCustomer: runningKey.replace("CUSTOMER_BRANCH_", ""), + code: `${runningKey.replace(`CUSTOMER_BRANCH_${company}_`, "")}-${`${last.value - branch.length + i}`.padStart(2, "0")}`, + codeCustomer: runningKey.replace(`CUSTOMER_BRANCH_${company}_`, ""), province: connectOrNot(v.provinceId), provinceId: undefined, district: connectOrNot(v.districtId),