<?php

namespace App\Modules\HR\Loans\Listeners;

use App\Modules\HR\Loans\Services\LoanPayrollSettlementService;
use App\Modules\Payroll\Events\PayrollPeriodFinalized;

class SettleLoanInstallmentsOnPayrollFinalized
{
    public function __construct(
        private readonly LoanPayrollSettlementService $settlement,
    ) {}

    public function handle(PayrollPeriodFinalized $event): void
    {
        $this->settlement->settleForFinalizedPeriod($event->period);
    }
}
