<?php

declare(strict_types=1);

namespace App\Modules\Ledger\Controllers;

use App\Modules\Ledger\Application\LedgerService;

class LedgerController
{
    public function __construct(private readonly LedgerService $ledgerService)
    {
    }

    /**
     * @return array<string, mixed>
     */
    public function index(string $tenantId, string $memberId = 'tenant-member-demo'): array
    {
        $overview = $this->ledgerService->accountingOverview($tenantId, $memberId);

        return [
            'view' => 'ledger.index',
            'data' => [
                'title' => 'Ledger und Buchungsspur',
                'ledger' => $overview['entries'] ?? [],
                'ledgerOverview' => $overview,
            ],
        ];
    }
}
