<?php

namespace App\Console\Commands;

use App\Support\InvestmentLedger;
use Illuminate\Console\Command;

class FinalizeEndedInvestmentsCommand extends Command
{
    protected $signature = 'investments:finalize-ended';

    protected $description = 'Marca como finalizadas las inversiones activas que ya cumplieron su plazo o vencimiento.';

    public function handle(): int
    {
        $count = InvestmentLedger::finalizeEndedActiveInvestments();

        $this->info("Inversiones marcadas como finalizadas: {$count}.");

        return self::SUCCESS;
    }
}
