<?php

namespace App\Console\Commands;

use App\Services\MalawiTerritorySalaryService;
use Illuminate\Console\Command;

class SeedMalawiSalaryComponents extends Command
{
    protected $signature = 'hrm:seed-malawi-salary';

    protected $description = 'Seed Malawi Territory salary components and assign employee salary structures';

    public function handle(MalawiTerritorySalaryService $salary): int
    {
        try {
            $stats = $salary->seedForCompany();
        } catch (\Throwable $e) {
            $this->error($e->getMessage());

            return self::FAILURE;
        }

        $this->info('Salary components created/updated: ' . $stats['components']);
        $this->info('Employee salary records synced: ' . $stats['employee_salaries']);

        return self::SUCCESS;
    }
}
