feat: check invalid data for create taskOrder
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 4s

This commit is contained in:
HAM 2025-10-14 16:19:37 +07:00
parent 5dc88c22dc
commit 78669ed7ae

View file

@ -77,6 +77,7 @@ export class TaskController extends Controller {
by: ["taskOrderStatus"],
_count: true,
});
return task.reduce<Record<TaskOrderStatus, number>>(
(a, c) => Object.assign(a, { [c.taskOrderStatus]: c._count }),
{
@ -264,6 +265,12 @@ export class TaskController extends Controller {
taskProduct?: { productId: string; discount?: number }[];
},
) {
if (!body.taskList || !body.registeredBranchId)
throw new HttpError(
HttpStatus.BAD_REQUEST,
"Your created invalid task order",
"taskOrderInvalid",
);
return await prisma.$transaction(async (tx) => {
const last = await tx.runningNo.upsert({
where: {
@ -311,10 +318,10 @@ export class TaskController extends Controller {
});
if (updated.count !== taskList.length) {
throw new HttpError(
HttpStatus.PRECONDITION_FAILED,
"All request work to issue task order must be in ready state.",
"requestWorkMustReady",
throw new httperror(
httpstatus.precondition_failed,
"all request work to issue task order must be in ready state.",
"requestworkmustready",
);
}
await tx.institution.updateMany({