<?php

namespace Database\Seeders;

use App\Models\SssTable;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class SssTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {

        $sssData = 
            [
                'compensation_from' => 1,
                'compensation_to' => 5250,
                'ec' => 5000,
                'monthly_salary_wisp' => 0,
                'regular_ss_er' => 500,
                'regular_ss_ee' => 250,
                'ec_er' => 10,
                'ec_ee' => 0,
                'wisp_er' => 0,
                'wisp_ee' => 0,
                'total_er' => 510,
                'total_ee' => 250,
                'created_at' => now(),
                'updated_at' => now(),
            ];

            SssTable::insert($sssData);

        $compensation_from = 5250;
        $compensation_to = 5749.99;

        $ec = 5000;
        
        $monthly_salary_wisp = 500.0;

        $regular_ss_er = 550.00;
        $regular_ss_ee = 275.00;

        $ec_er = 10;

        $wisp_er = 0;
        $wisp_ee = 0;

        $total_er = 560;
        $total_ee = 275;

        for($i = 1; $i <= 60; $i++){

            if($i >= 31){
                $monthly_salary_wisp += 500;
            } else {
                $monthly_salary_wisp = 0;
            }

            if($i >= 31){
                $wisp_er += 50;
                $wisp_ee += 25;
            } else {
                $wisp_er = 0;
                $wisp_ee = 0;
            }

            $ec += 500;

            if($ec >= 20000){
                $ec = 20000;
            }
            
            $sssData = 
            [
                'compensation_from' => $compensation_from,
                'compensation_to' => $compensation_to,
                'ec' => $ec,
                'monthly_salary_wisp' => $monthly_salary_wisp,
                'regular_ss_er' => $regular_ss_er,
                'regular_ss_ee' => $regular_ss_ee,
                'ec_er' => $ec_er,
                'ec_ee' => 0,
                'wisp_er' => $wisp_er,
                'wisp_ee' => $wisp_ee,
                'total_er' => $total_er,
                'total_ee' => $total_ee,
                'created_at' => now(),
                'updated_at' => now(),
            ];

            $compensation_from += 500;
            $compensation_to += 500;

            if($i == 19){
                $ec_er += 20;
                $total_er += 20;
            }

            if($i < 30){
                $regular_ss_er += 50;
                $regular_ss_ee += 25;
            }
            
            if($i > 30){
                $ec += 500;
            }

            $total_er += 50;
            $total_ee += 25;
            SssTable::insert($sssData);
        }

        $sssData = 
            [
                'compensation_from' => 29750,
                'compensation_to' => 99999999,
                'ec' => 20000,
                'monthly_salary_wisp' => 10000,
                'regular_ss_er' => 1900,
                'regular_ss_ee' => 900,
                'ec_er' => 30,
                'ec_ee' => 0,
                'wisp_er' => 950,
                'wisp_ee' => 450,
                'total_er' => 2880,
                'total_ee' => 1350,
                'created_at' => now(),
                'updated_at' => now(),
            ];

            SssTable::insert($sssData);
    }

    public function reset()
    {
        SssTable::truncate();
    }
}
