From b3e2a16c8e9f83cd5edfd4a1fa219166527120d5 Mon Sep 17 00:00:00 2001 From: faisolavolut Date: Mon, 3 Nov 2025 10:42:36 +0700 Subject: [PATCH] fix: Add validation for date filtering in payment status endpoint --- src/controllers/transferController.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/controllers/transferController.ts b/src/controllers/transferController.ts index efaaef2..514967a 100644 --- a/src/controllers/transferController.ts +++ b/src/controllers/transferController.ts @@ -445,6 +445,13 @@ export async function paymentStatus(req: Request, res: Response) { const where: any = {}; if (startdate || enddate) { + if (!startdate || !enddate) { + return res + .status(400) + .json({ + error: "startdate and enddate are required when filtering by date", + }); + } where.created_at = {} as any; if (startdate) { const s = new Date(String(startdate)); @@ -462,14 +469,6 @@ export async function paymentStatus(req: Request, res: Response) { if (c_invoice_id) { where.c_invoice_id = Number(c_invoice_id); } - console.log({ - ...where, - and: { - NOT: { - c_invoice_id: null, - }, - }, - }); const rows = await db.transactions_lines.findMany({ where: {