fix: code always update on customer type CORP

This commit is contained in:
Methapon2001 2024-07-23 14:27:56 +07:00
parent bd425554a1
commit be8f8d462f

View file

@ -582,7 +582,11 @@ export class EmployeeController extends Controller {
const record = await prisma.$transaction(async (tx) => {
let code: string | undefined;
if (customerBranch && customerBranch.id !== employee.customerBranchId) {
if (
customerBranchId !== undefined &&
customerBranch &&
customerBranch.id !== employee.customerBranchId
) {
const last = await tx.runningNo.upsert({
where: {
key: `EMPLOYEE_${customerBranch.customer.code}-${customerBranch.branchNo.toString().padStart(2, "0")}-${new Date().getFullYear().toString().slice(-2).padStart(2, "0")}`,