From 0af6dbaae124ef85cae04acaf1083ca45611519d Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 17 Oct 2024 15:32:01 +0700 Subject: [PATCH] fix: change running no to custoer branch id instead --- src/controllers/05-quotation-controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index a220f8f..ac93fa8 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -321,10 +321,10 @@ export class QuotationController extends Controller { const nonExistEmployee = body.worker.filter((v) => typeof v !== "string"); const lastEmployee = await tx.runningNo.upsert({ where: { - key: `EMPLOYEE_${customerBranch.code}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}`, + key: `EMPLOYEE_${customerBranch.id}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}`, }, create: { - key: `EMPLOYEE_${customerBranch.code}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}`, + key: `EMPLOYEE_${customerBranch.id}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}`, value: nonExistEmployee.length, }, update: { value: { increment: nonExistEmployee.length } }, @@ -334,7 +334,7 @@ export class QuotationController extends Controller { tx.employee.create({ data: { ...v, - code: `${customerBranch.code}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}${`${lastEmployee.value - nonExistEmployee.length + i + 1}`.padStart(7, "0")}`, + code: `${customerBranch.id}-${`${new Date().getFullYear()}`.slice(-2).padStart(2, "0")}${`${lastEmployee.value - nonExistEmployee.length + i + 1}`.padStart(7, "0")}`, customerBranchId: customerBranch.id, }, }),