<?php

namespace App\Http\Resources\Finance;

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

class FinancialInvoiceResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => (int) ($this->resource['id'] ?? 0),
            'invoice_number' => $this->resource['invoice_number'] ?? null,
            'parent_id' => (int) ($this->resource['parent_id'] ?? 0),
            'parent_name' => $this->resource['parent_name'] ?? null,
            'school_year' => $this->resource['school_year'] ?? null,
            'total_amount' => (float) ($this->resource['total_amount'] ?? 0),
            'paid_amount' => (float) ($this->resource['paid_amount'] ?? 0),
            'balance' => (float) ($this->resource['balance'] ?? 0),
            'status' => $this->resource['status'] ?? null,
            'issue_date' => $this->resource['issue_date'] ?? null,
            'due_date' => $this->resource['due_date'] ?? null,
            'created_at' => $this->resource['created_at'] ?? null,
            'updated_at' => $this->resource['updated_at'] ?? null,
        ];
    }
}
