From ca6c6d28305bc90c9f71c98ecd66b700b084f148 Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Wed, 8 Apr 2026 11:29:07 +0530 Subject: [PATCH] FIX_Partner Renewal API --- app/Controllers/DashboardController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index cf7f787..14ba582 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -1449,6 +1449,11 @@ public function partnerRenewals($id) $ref = []; $days = (int) ($this->request->getGet('days') ?? 20); + // Calculate range boundaries + // 10 => 0–10 | 20 => 11–20 | 30 => 21–30 | 40 => 31–40 | 50 => 41–50 + $endDay = $days; + $startDay = ($days <= 10) ? 0 : ($days - 9); + try { if (empty($id)) { return $this->respond([ @@ -1472,16 +1477,17 @@ public function partnerRenewals($id) ->where('pp.is_active', 1) ->where('pp.policy_number IS NOT NULL') ->where('pp.premium_amount IS NOT NULL') - ->where('pp.end_date >= CURDATE()', null, false) - ->where("pp.end_date <= DATE_ADD(CURDATE(), INTERVAL {$days} DAY)", null, false) + ->where("pp.end_date >= DATE_ADD(CURDATE(), INTERVAL {$startDay} DAY)", null, false) + ->where("pp.end_date <= DATE_ADD(CURDATE(), INTERVAL {$endDay} DAY)", null, false) ->orderBy('pp.end_date', 'ASC') ->get()->getResultArray(); $ref['days_filter'] = $days; + $ref['range'] = "day {$startDay} to day {$endDay}"; $ref['total_records'] = count($results); if (empty($results)) { - throw new \RuntimeException('No renewals due within ' . $days . ' days.', 404); + throw new \RuntimeException('No renewals due within this range.', 404); } return $this->respond([