FIX_Partner Renewal API
This commit is contained in:
parent
66422278e7
commit
ca6c6d2830
@ -1449,6 +1449,11 @@ public function partnerRenewals($id)
|
|||||||
$ref = [];
|
$ref = [];
|
||||||
$days = (int) ($this->request->getGet('days') ?? 20);
|
$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 {
|
try {
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -1472,16 +1477,17 @@ public function partnerRenewals($id)
|
|||||||
->where('pp.is_active', 1)
|
->where('pp.is_active', 1)
|
||||||
->where('pp.policy_number IS NOT NULL')
|
->where('pp.policy_number IS NOT NULL')
|
||||||
->where('pp.premium_amount 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 {$startDay} DAY)", null, false)
|
||||||
->where("pp.end_date <= DATE_ADD(CURDATE(), INTERVAL {$days} DAY)", null, false)
|
->where("pp.end_date <= DATE_ADD(CURDATE(), INTERVAL {$endDay} DAY)", null, false)
|
||||||
->orderBy('pp.end_date', 'ASC')
|
->orderBy('pp.end_date', 'ASC')
|
||||||
->get()->getResultArray();
|
->get()->getResultArray();
|
||||||
|
|
||||||
$ref['days_filter'] = $days;
|
$ref['days_filter'] = $days;
|
||||||
|
$ref['range'] = "day {$startDay} to day {$endDay}";
|
||||||
$ref['total_records'] = count($results);
|
$ref['total_records'] = count($results);
|
||||||
|
|
||||||
if (empty($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([
|
return $this->respond([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user