From 96298daab20250ca3ae03a0d412f0dc8609e7112 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:57:08 +0700 Subject: [PATCH] fix: wrong create value --- src/controllers/customer-controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/customer-controller.ts b/src/controllers/customer-controller.ts index a091cfe..0efb941 100644 --- a/src/controllers/customer-controller.ts +++ b/src/controllers/customer-controller.ts @@ -318,9 +318,9 @@ export class CustomerController extends Controller { }, create: { key: `CUSTOMER_${body.code.toLocaleUpperCase()}`, - value: 1, + value: body.customerBranch?.length || 0, }, - update: { value: { increment: (body.customerBranch?.length || 0) + 1 } }, + update: { value: { increment: body.customerBranch?.length || 0 } }, }); body.code = body.code.toLocaleUpperCase(); @@ -358,7 +358,7 @@ export class CustomerController extends Controller { data: customerBranch?.map((v, i) => ({ ...v, - code: `${body.code}${`${last.value - customerBranch?.length + i + 2}`.padStart(6, "0")}`, + code: `${body.code}${`${last.value - customerBranch?.length + i + 1}`.padStart(6, "0")}`, createdByUserId: req.user.sub, updatedByUserId: req.user.sub, })) || [],