fix: wrong create value

This commit is contained in:
Methapon2001 2024-08-09 09:57:08 +07:00
parent c434b085bc
commit 96298daab2

View file

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