From fc460eceea129dcff3cd08869d50499498e33ca6 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 7 Nov 2024 15:16:35 +0700 Subject: [PATCH] fix: time got ignored --- src/services/schedule.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/schedule.ts b/src/services/schedule.ts index d3ff1f7..823797e 100644 --- a/src/services/schedule.ts +++ b/src/services/schedule.ts @@ -7,11 +7,17 @@ const jobs = [ cronTime: "0 0 0 * * *", runOnInit: true, onTick: async () => { + const current = new Date(); + + const date = current.getDate(); + const month = current.getMonth(); + const year = current.getFullYear(); + await prisma.quotation .updateMany({ where: { quotationStatus: "Issued", - dueDate: { lte: new Date() }, + dueDate: { lte: new Date(year, date - 1 === 0 ? month - 1 : month, date - 1) }, }, data: { quotationStatus: "Expired" }, })