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 * * *", cronTime: "0 0 0 * * *",
runOnInit: true, runOnInit: true,
onTick: async () => { onTick: async () => {
const current = new Date();
const date = current.getDate();
const month = current.getMonth();
const year = current.getFullYear();
await prisma.quotation await prisma.quotation
.updateMany({ .updateMany({
where: { where: {
quotationStatus: "Issued", quotationStatus: "Issued",
dueDate: { lte: new Date() }, dueDate: { lte: new Date(year, date - 1 === 0 ? month - 1 : month, date - 1) },
}, },
data: { quotationStatus: "Expired" }, data: { quotationStatus: "Expired" },
}) })