feat: check if installments is valid
This commit is contained in:
parent
978eb0eee2
commit
6b4e13e94d
1 changed files with 24 additions and 0 deletions
|
|
@ -308,6 +308,18 @@ export class ServiceController extends Controller {
|
|||
|
||||
await permissionCheck(req.user, productGroup.registeredBranch);
|
||||
|
||||
if (body.installments && body.work) {
|
||||
for (let i = 0; i < body.installments; i++) {
|
||||
if (!body.work.some((w) => w.product.some((p) => p.installmentNo === i + 1))) {
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Installments validate failed.",
|
||||
"installmentsValidateFailed",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const record = await prisma.$transaction(
|
||||
async (tx) => {
|
||||
const branch = productGroup.registeredBranch;
|
||||
|
|
@ -419,6 +431,18 @@ export class ServiceController extends Controller {
|
|||
await permissionCheck(req.user, productGroup.registeredBranch);
|
||||
}
|
||||
|
||||
if (body.installments && body.work) {
|
||||
for (let i = 0; i < body.installments; i++) {
|
||||
if (!body.work.some((w) => w.product.some((p) => p.installmentNo === i + 1))) {
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Installments validate failed.",
|
||||
"installmentsValidateFailed",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const record = await prisma.$transaction(async (tx) => {
|
||||
if (payload.workflowId === "") payload.workflowId = undefined;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue