<?php

namespace App\Http\Resources\Finance;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class FinancialReportResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'selectedYear' => $this->resource['selectedYear'] ?? null,
            'dateFrom' => $this->resource['dateFrom'] ?? null,
            'dateTo' => $this->resource['dateTo'] ?? null,
            'schoolYears' => $this->resource['schoolYears'] ?? [],
            'invoices' => FinancialInvoiceResource::collection($this->resource['invoices'] ?? []),
            'payments' => FinancialPaymentResource::collection($this->resource['payments'] ?? []),
            'paymentBreakdown' => $this->resource['paymentBreakdown'] ?? [],
            'paymentTotals' => $this->resource['paymentTotals'] ?? [],
            'refunds' => FinancialRefundResource::collection($this->resource['refunds'] ?? []),
            'expenses' => FinancialExpenseSummaryResource::collection($this->resource['expenses'] ?? []),
            'reimbursements' => FinancialReimbursementSummaryResource::collection($this->resource['reimbursements'] ?? []),
            'discounts' => FinancialDiscountResource::collection($this->resource['discounts'] ?? []),
        ];
    }
}
