diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index c7ce311b..f48ac65b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -893,7 +893,16 @@ export class CommandController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); } command.isSign = true; - if (new Date().getDate() > command.commandExcecuteDate.getDate()) { + if (command.commandExcecuteDate == null) + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล"); + if ( + new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) < + new Date( + command.commandExcecuteDate.getFullYear(), + command.commandExcecuteDate.getMonth(), + command.commandExcecuteDate.getDate(), + ) + ) { command.status = "WAITING"; } else { command.status = "REPORTED";