<?php

namespace App\Notifications;

use App\Models\IncomeTaxDeclaration;

class IncomeTaxDeclarationSubmittedNotification extends HrmsNotification
{
    public function __construct(
        public IncomeTaxDeclaration $declaration
    ) {}

    public function notificationCategory(): string
    {
        return 'income_tax';
    }

    public function notificationSubject(): string
    {
        $name = $this->declaration->user?->name ?? 'An employee';

        return 'Income tax declaration submitted — ' . $name;
    }

    public function notificationLines(): array
    {
        $user = $this->declaration->user;

        return [
            ($user?->name ?? 'An employee') . ' submitted an income tax declaration for verification.',
            'Financial year: ' . $this->declaration->financial_year,
            'Regime: ' . ucfirst($this->declaration->regime),
            'Declared deductions: ₹' . number_format((float) $this->declaration->total_deductions_declared, 2),
        ];
    }

    public function actionUrl(): ?string
    {
        return route('payroll.income-tax.admin.review', $this->declaration);
    }

    public function actionLabel(): string
    {
        return 'Review declaration';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'income_tax_submitted',
            'message' => ($this->declaration->user?->name ?? 'Employee') . ' submitted FY ' . $this->declaration->financial_year . ' tax declaration.',
            'declaration_id' => $this->declaration->id,
            'financial_year' => $this->declaration->financial_year,
            'url' => route('payroll.income-tax.admin.review', $this->declaration),
        ];
    }
}
