<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('payroll_summaries', function (Blueprint $table) {
            $table->unsignedBigInteger('payroll_id')->index();
            $table->string('reference_no',50)->index();
            $table->date('payroll_date')->index();
            $table->string('cut_off', 5)->index();
            $table->unsignedMediumInteger('company_id')->index();
            $table->unsignedMediumInteger('dealership_id')->index();
            $table->unsignedMediumInteger('department_id')->index();
            $table->string('employee_id')->index();
            $table->decimal('monthly_salary', $precision=12, $scale=2)->default(0);
            $table->decimal('work_hours', $precision=12, $scale=2)->default(0);
            $table->decimal('basic_pay', $precision=12, $scale=2)->default(0);
            $table->decimal('leave_pay', $precision=12, $scale=2)->default(0);
            $table->decimal('absent_amount', $precision=12, $scale=2)->default(0);
            $table->decimal('late_amount', $precision=12, $scale=2)->default(0);
            $table->decimal('tardiness_amount', $precision=12, $scale=2)->default(0);
            $table->decimal('overtime_total', $precision=12, $scale=2)->default(0);
            $table->decimal('holiday_total', $precision=12, $scale=2)->default(0);
            $table->decimal('restday_total', $precision=12, $scale=2)->default(0);
            $table->decimal('gross_pay', $precision=12, $scale=2)->default(0);
            $table->decimal('sss_employee_share', $precision=12, $scale=2)->default(0);
            $table->decimal('sss_employer_share', $precision=12, $scale=2)->default(0);
            $table->decimal('philhealth_contribution', $precision=12, $scale=2)->default(0);
            $table->decimal('pagibig_contribution', $precision=12, $scale=2)->default(0);
            $table->decimal('taxable_amount', $precision=12, $scale=2)->default(0);
            $table->decimal('withholding_tax', $precision=12, $scale=2)->default(0);
            $table->decimal('income_after_tax', $precision=12, $scale=2)->default(0);
            $table->decimal('non_taxable_addition', $precision=12, $scale=2)->default(0);
            $table->decimal('non_taxable_deduction', $precision=12, $scale=2)->default(0);
            $table->decimal('net_pay', $precision=12, $scale=2)->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('payroll_summaries');
    }
};
