fix: fixed branch no digit

This commit is contained in:
Methapon2001 2024-06-11 14:44:55 +07:00
parent 8a1354ac2b
commit 88ac8c4b81

View file

@ -345,10 +345,10 @@ export class EmployeeController extends Controller {
async (tx) => { async (tx) => {
const last = await tx.runningNo.upsert({ const last = await tx.runningNo.upsert({
where: { where: {
key: `EMPLOYEE_${customerBranch.customer.code}-${customerBranch.branchNo}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}`, key: `EMPLOYEE_${customerBranch.customer.code}-${customerBranch.branchNo.toString().padStart(2, "0")}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}`,
}, },
create: { create: {
key: `EMPLOYEE_${customerBranch.customer.code}-${customerBranch.branchNo}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}`, key: `EMPLOYEE_${customerBranch.customer.code}-${customerBranch.branchNo.toString().padStart(2, "0")}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}`,
value: 1, value: 1,
}, },
update: { value: { increment: 1 } }, update: { value: { increment: 1 } },
@ -369,7 +369,7 @@ export class EmployeeController extends Controller {
}, },
data: { data: {
...rest, ...rest,
code: `${customerBranch.customer.code}-${customerBranch.branchNo}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}${last.value.toString().padStart(4, "0")}`, code: `${customerBranch.customer.code}-${customerBranch.branchNo.toString().padStart(2, "0")}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}${last.value.toString().padStart(4, "0")}`,
employeeWork: { employeeWork: {
createMany: { createMany: {
data: employeeWork || [], data: employeeWork || [],