diff --git a/src/controllers/07-task-controller.ts b/src/controllers/07-task-controller.ts index ad97be0..cf7b402 100644 --- a/src/controllers/07-task-controller.ts +++ b/src/controllers/07-task-controller.ts @@ -77,6 +77,7 @@ export class TaskController extends Controller { by: ["taskOrderStatus"], _count: true, }); + return task.reduce>( (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({