<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use DB;

class ParameterSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //uang muka penjualan
        $cek = DB::table('parameter')->where("id", "Acc_sales_down_payment")->count();
        if ($cek == 0) {
            DB::table('parameter')->insert([
                [
                    'id' => "Acc_sales_down_payment",
                    'name' => 'Uang Muka Pelanggan',
                    'value' => '2101102',
                ]
            ]);
        }
        //uang muka pembelian
        $cek = DB::table('parameter')->where("id", "Acc_purchase_down_payment")->count();
        if ($cek == 0) {
            DB::table('parameter')->insert([
                [
                    'id' => "Acc_purchase_down_payment",
                    'name' => 'Uang Muka Pembelian',
                    'value' => '1141001',
                ]
            ]);
        }
        //utang usaha
        $cek = DB::table('parameter')->where("id", "Acc_hutang_dagang")->count();
        if ($cek == 0) {
            DB::table('parameter')->insert([
                [
                    'id' => "Acc_hutang_dagang",
                    'name' => 'Utang Usaha - Pihak Ketiga',
                    'value' => '2101001',
                ]
            ]);
        }
        //Persediaan barang dalam perjalanan
        // $cek = DB::table('parameter')->where("id", "Acc_persediaan_transit")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_persediaan_transit",
        //             'name' => 'Account persediaan transit',
        //             'value' => '11799',
        //         ]
        //     ]);
        // }
        //Hutang belum Di fakturkan
        // $cek = DB::table('parameter')->where("id", "Acc_debt_non_invoice")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_debt_non_invoice",
        //             'name' => 'Account Debt Non Invoice',
        //             'value' => '21199',
        //         ]
        //     ]);
        // }
        //Pendapatan Lain lain
        // $cek = DB::table('parameter')->where("id", "Acc_penjualan_barang_lain")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_penjualan_barang_lain",
        //             'name' => 'Penjualan Barang Lain',
        //             'value' => '7124',
        //         ]
        //     ]);
        // }

        //Pendapatan Lain lain
        // $cek = DB::table('parameter')->where("id", "Acc_selisih_nilai_sediaan")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_selisih_nilai_sediaan",
        //             'name' => 'Selisih Nilai sediaan',
        //             'value' => '734',
        //         ]
        //     ]);
        // }

        //Potongan TUD
        // $cek = DB::table('parameter')->where("id", "Acc_potongan_tud")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_potongan_tud",
        //             'name' => 'Potongan / TUD',
        //             'value' => '542',
        //         ]
        //     ]);
        // }

        //Potongan TUD
        // $cek = DB::table('parameter')->where("id", "Acc_persediaan_jalan")->count();
        // if ($cek == 0) {
        //     DB::table('parameter')->insert([
        //         [
        //             'id' => "Acc_persediaan_jalan",
        //             'name' => 'Persediaan Dalam Perjalanan',
        //             'value' => '11712',
        //         ]
        //     ]);
        // }

        //Sorting
        $cek = DB::table("sorting")->count();
        if($cek == 0){
            DB::table('sorting')->insert([
                [
                    'transaction_type' => "Purchase Invoice",
                    'number' => 1,
                    'times' => 1,
                ],[
                    'transaction_type' => "Purchase Invoice Makloon",
                    'number' => 2,
                    'times' => 1,
                ],[
                    'transaction_type' => "Processing Penggunaan Bahan",
                    'number' => 3,
                    'times' => -1,
                ],[
                    'transaction_type' => "Processsing Pengambilan Bahan",
                    'number' => 4,
                    'times' => 1,
                ],[
                    'transaction_type' => "Kasir Production Penggunaan Bahan",
                    'number' => 5,
                    'times' => -1,
                ],[
                    'transaction_type' => "Kasir Production Pengambilan Bahan",
                    'number' => 6,
                    'times' => 1,
                ],[
                    'transaction_type' => "Production Pengambilan Bahan",
                    'number' => 7,
                    'times' => 1,
                ],[
                    'transaction_type' => "Production Penggunaan Bahan",
                    'number' => 8,
                    'times' => -1,
                ],[
                    'transaction_type' => "Mutation Out",
                    'number' => 9,
                    'times' => -1,
                ],[
                    'transaction_type' => "Mutation In",
                    'number' => 10,
                    'times' => 1,
                ],[
                    'transaction_type' => "Sales Invoice",
                    'number' => 11,
                    'times' => -1,
                ],[
                    'transaction_type' => "Sales Return",
                    'number' => 12,
                    'times' => 1,
                ]
            ]);
        }
    }
}
