fix: also prefix runningNo on generate

This commit is contained in:
Methapon Metanipat 2024-09-10 14:37:33 +07:00
parent 8c0932f6d8
commit eb30202312

View file

@ -242,12 +242,14 @@ export class ServiceController extends Controller {
const record = await prisma.$transaction(
async (tx) => {
const branch = productGroup.registeredBranch;
const company = (branch.headOffice || branch).code;
const last = await tx.runningNo.upsert({
where: {
key: `SERVICE_${body.code.toLocaleUpperCase()}`,
key: `SERVICE_${company}_${body.code.toLocaleUpperCase()}`,
},
create: {
key: `SERVICE_${body.code.toLocaleUpperCase()}`,
key: `SERVICE_${company}_${body.code.toLocaleUpperCase()}`,
value: 1,
},
update: { value: { increment: 1 } },