<?php

namespace App\Support\Simulation;

final class SimulationLoanAdjustmentExpectations
{
    public const AS_OF_DATE = '2026-08-15';

    /** @return array<string, array<string, mixed>> */
    public static function scenarios(): array
    {
        return [
            'top_up' => [
                'base_purpose' => 'SIM-ADJ-TOPUP-BASE',
                'replacement_purpose' => 'SIM-ADJ-TOPUP-REPLACEMENT',
                'branch' => 'SIM-DAR',
                'customer' => 'SIM-CUS-DAR-001',
                'base_principal' => '1000000.00',
                'base_total_repayment' => '1155000.00',
                'new_principal' => '1400000.00',
                'new_total_repayment' => '1611000.00',
                'internal_settlement' => '1155000.00',
                'cash_to_customer' => '245000.00',
                'account' => 'SIM Dar Bank',
            ],
            'early_settlement' => [
                'purpose' => 'SIM-ADJ-EARLY-SETTLEMENT',
                'branch' => 'SIM-ARU',
                'customer' => 'SIM-CUS-ARU-002',
                'principal' => '700000.00',
                'subtotal' => '813000.00',
                'adjustment' => '-30000.00',
                'final_amount' => '783000.00',
                'disbursement_account' => 'SIM Arusha Bank',
                'settlement_account' => 'SIM Arusha Cash',
            ],
            'restructure_approved' => [
                'purpose' => 'SIM-ADJ-RESTRUCTURE-APPROVED',
                'branch' => 'SIM-MZA',
                'customer' => 'SIM-CUS-MZA-001',
                'principal' => '900000.00',
                'total_outstanding' => '1041000.00',
                'account' => 'SIM Mwanza Bank',
                'new_schedule' => "2026-09-15 | 347000.00\n2026-10-15 | 347000.00\n2026-11-15 | 347000.00",
                'new_installments' => 3,
            ],
            'restructure_rejected' => [
                'purpose' => 'SIM-ADJ-RESTRUCTURE-REJECTED',
                'branch' => 'SIM-MZA',
                'customer' => 'SIM-CUS-MZA-003',
                'principal' => '500000.00',
                'total_outstanding' => '585000.00',
                'account' => 'SIM Mwanza Bank',
                'new_schedule' => "2026-09-20 | 292500.00\n2026-10-20 | 292500.00",
            ],
            'write_off_recovery' => [
                'purpose' => 'SIM-ADJ-WRITEOFF-RECOVERY',
                'branch' => 'SIM-DAR',
                'customer' => 'SIM-CUS-DAR-001',
                'principal' => '600000.00',
                'write_off_amount' => '699000.00',
                'recovery_amount' => '200000.00',
                'recoverable_balance' => '499000.00',
                'disbursement_account' => 'SIM Dar Bank',
                'recovery_account' => 'SIM Dar Cash',
            ],
            'write_off_rejected' => [
                'purpose' => 'SIM-ADJ-WRITEOFF-REJECTED',
                'branch' => 'SIM-ARU',
                'customer' => 'SIM-CUS-ARU-004',
                'principal' => '400000.00',
                'write_off_amount' => '471000.00',
                'account' => 'SIM Arusha Bank',
            ],
        ];
    }

    /** @return array<string, string> */
    public static function expectedAccountBalances(): array
    {
        return [
            'SIM Dar Cash' => '25615000.00',
            'SIM Dar Bank' => '70655000.00',
            'SIM Mwanza Bank' => '37200000.00',
            'SIM Arusha Cash' => '12783000.00',
            'SIM Arusha Bank' => '28900000.00',
        ];
    }

    /** @return array<string, string|int> */
    public static function aggregateControls(): array
    {
        return [
            'base_adjustment_loans' => 6,
            'top_up_records' => 1,
            'early_settlements' => 1,
            'restructurings' => 2,
            'approved_restructurings' => 1,
            'rejected_restructurings' => 1,
            'write_offs' => 2,
            'approved_write_offs' => 1,
            'rejected_write_offs' => 1,
            'write_off_recoveries' => 1,
            'recovery_cash' => '200000.00',
            'expected_account_total' => '222922000.00',
        ];
    }
}
