<?php

namespace App\OldDataMigrations;

class HrMigration extends BaseOldDataMigration
{
    public function priority(): int
    {
        return 6;
    }

    public function migrate(): array
    {
        $results = [];

        $results['employee_advances'] = $this->migrateTable('employee_advances', function ($row) {
            $row['status'] = match ($row['status'] ?? '') {
                'approved' => 'disbursed',
                'paid' => 'repaid',
                'cancelled' => 'rejected',
                default => $row['status'],
            };

            return $row;
        });
        $results['employee_advance_payments'] = $this->migrateTable('employee_advance_payments');
        $results['attendances'] = $this->migrateTable('attendances');
        $results['leave_requests'] = $this->migrateTable('leave_requests');
        $results['payroll_periods'] = $this->migrateTable('payroll_periods');
        $results['payrolls'] = $this->migrateTable('payrolls');
        $results['payroll_adjustments'] = $this->migrateTable('payroll_adjustments');

        return $results;
    }
}
