fix: time got ignored

This commit is contained in:
Methapon Metanipat 2024-11-07 15:16:35 +07:00
parent be14c7d87a
commit fc460eceea

View file

@ -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" },
})