<?php

namespace Modules\Accounts\Database\Seeders;

use Illuminate\Database\Seeder;
use Modules\Accounts\Enums\AccountTypeEnum;
use Modules\Accounts\Models\ChartOfAccount;

class DefaultChartOfAccountSeederOld extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        foreach (AccountTypeEnum::cases() as $type) {
            ChartOfAccount::query()->updateOrCreate(
                ['account_code' => $type->rootCode()],
                [
                    'account_name' => $type->label(),
                    'parent_id'    => null,
                    'is_group'     => true,
                    'account_type' => $type->value,
                    'is_cash'      => false,
                    'is_bank'      => false,
                    'description'  => $type->label() . ' root account',
                    'status'       => true,
                ]
            );
        }
    }
}
