FIX_Partner Renewal API

This commit is contained in:
sanjeev.p 2026-04-08 11:29:07 +05:30
parent 66422278e7
commit ca6c6d2830

View File

@ -1449,6 +1449,11 @@ public function partnerRenewals($id)
$ref = [];
$days = (int) ($this->request->getGet('days') ?? 20);
// Calculate range boundaries
// 10 => 010 | 20 => 1120 | 30 => 2130 | 40 => 3140 | 50 => 4150
$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([