Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AccrueInterestAction | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\SuperAdmin; |
| 6 | |
| 7 | use App\Domain\SuperAdmin\Service\SuperAdminService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use App\Support\Row; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | /** |
| 14 | * POST /api/super-admin/accrue-interest |
| 15 | * |
| 16 | * Batch-runs daily interest accrual for a date range. |
| 17 | */ |
| 18 | final readonly class AccrueInterestAction |
| 19 | { |
| 20 | public function __construct( |
| 21 | private SuperAdminService $superAdminService, |
| 22 | private JsonRenderer $renderer, |
| 23 | ) {} |
| 24 | |
| 25 | public function __invoke( |
| 26 | ServerRequestInterface $request, |
| 27 | ResponseInterface $response, |
| 28 | ): ResponseInterface { |
| 29 | $data = (array)$request->getParsedBody(); |
| 30 | |
| 31 | $result = $this->superAdminService->accrueInterest( |
| 32 | Row::nullableString($data, 'startDate'), |
| 33 | Row::nullableString($data, 'endDate'), |
| 34 | ); |
| 35 | |
| 36 | return $this->renderer->json($response, [ |
| 37 | 'success' => true, |
| 38 | 'message' => "Accrued interest for {$result['daysProcessed']} day(s)", |
| 39 | 'data' => $result, |
| 40 | ]); |
| 41 | } |
| 42 | } |