2025-12-31 02:34:30 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
|
|
class ProjectionResource extends JsonResource
|
|
|
|
|
{
|
|
|
|
|
public function toArray(Request $request): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'inflows' => InflowResource::collection($this->resource['inflows']),
|
|
|
|
|
'outflows' => OutflowResource::collection($this->resource['outflows']),
|
|
|
|
|
'draws' => DrawResource::collection($this->resource['draws']),
|
|
|
|
|
'summary' => [
|
|
|
|
|
'total_inflow' => $this->resource['inflows']->sum('amount_currency'),
|
|
|
|
|
'total_outflow' => $this->resource['outflows']->sum('amount_currency'),
|
|
|
|
|
'total_allocated' => $this->resource['draws']->sum('amount_currency'),
|
|
|
|
|
'net_cashflow' => $this->resource['inflows']->sum('amount_currency') - $this->resource['outflows']->sum('amount_currency'),
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
2026-03-19 01:09:47 +01:00
|
|
|
}
|