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, })) || [],