<?php

namespace Database\Seeders;

use App\Models\Business;
use App\Models\ExpenseCategory;
use Illuminate\Database\Seeder;

class ExpenseCategorySeeder extends Seeder
{
    public function run(): void
    {
        $defaults = [
            ['Rent','RENT','Office, branch and storage rent.'],
            ['Internet','INTERNET','Internet and connectivity expenses.'],
            ['Security','SECURITY','Security services and related costs.'],
            ['Software','SOFTWARE','Software subscriptions, licences and systems.'],
            ['Insurance','INSURANCE','Business, property and operational insurance.'],
            ['Other','OTHER','Other approved operating expenses.'],
        ];

        Business::query()->each(function (Business $business) use ($defaults): void {
            foreach ($defaults as [$name,$code,$description]) {
                ExpenseCategory::updateOrCreate(
                    ['business_id'=>$business->id,'name'=>$name],
                    ['code'=>$code,'description'=>$description,'status'=>'active']
                );
            }
        });
    }
}