<?php

namespace App\Filament\Pages\Reports;

use App\Models\Sales\Invoice;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
 * Base for the reports the source app renders as empty placeholders:
 * `expenses`, `payroll` and `profit-loss` all do nothing but
 * `Inertia::render('reports/x')` with no data at all, and are gated by
 * `dashboard.access` rather than a report module of their own.
 *
 * Ported as stubs deliberately (docs/migration-plan.md Phase 9 scope: "ported
 * as stubs, matching current behavior — not built out further"). Building real
 * expense/payroll/P&L reporting would be new functionality, not a migration.
 */
abstract class StubReport extends ReportPage
{
    protected string $view = 'filament.pages.reports.stub';

    /**
     * Each stub now carries a module of its own (`reports_expenses`,
     * `reports_payroll`, `reports_profit_loss`) instead of riding on
     * `dashboard.access` as the source app did.
     *
     * Sharing `dashboard.access` meant these three entries appeared in the
     * sidebar of every user who could see the dashboard at all and could not be
     * hidden without taking the dashboard away too — three permanently empty
     * pages that no permission governed. With their own modules they behave like
     * every other report: nothing is granted them by default, so they stay out of
     * the menu entirely until someone deliberately grants them.
     */
    abstract public static function moduleKey(): string;

    /**
     * Nothing to export from a page with no rows, and the module deliberately
     * has no `export` action for the same reason.
     */
    public function canExport(): bool
    {
        return false;
    }

    public function columns(): array
    {
        return [];
    }

    public function rows(): array
    {
        return [];
    }

    public function csvFilename(): string
    {
        return 'report.csv';
    }

    protected function reportQuery(): Builder
    {
        return Invoice::query()->whereRaw('1 = 0');
    }

    protected function exportRow(Model $record): array
    {
        return [];
    }

    public function summary(): array
    {
        return [];
    }

    protected function receiptLine(Model $record): array
    {
        return ['label' => '', 'value' => ''];
    }

    /**
     * @return array<string, mixed>
     */
    protected function getViewData(): array
    {
        return [];
    }
}
