<?php

namespace Tests\Unit;

use App\Enums\InvestmentTransactionType;
use App\Models\InvestmentTransaction;
use App\Support\InvestmentLedger;
use Tests\TestCase;

class AppliedPercentLabelTest extends TestCase
{
    public function test_period_accrual_shows_effective_period_percent_not_inflated(): void
    {
        $txn = new InvestmentTransaction([
            'type' => InvestmentTransactionType::PeriodAccrual,
            'applied_percent' => 4.0,
            'accrual_on' => '2026-08-30',
        ]);

        $this->assertSame('4.00% del período', InvestmentLedger::appliedPercentLabel($txn));
    }

    public function test_daily_gain_shows_monthly_equivalent(): void
    {
        $txn = new InvestmentTransaction([
            'type' => InvestmentTransactionType::DailyGain,
            'applied_percent' => 3.5 / 31,
            'accrual_on' => '2026-07-30',
        ]);

        $this->assertSame('3.50% mes', InvestmentLedger::appliedPercentLabel($txn));
    }
}
