<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('wages', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users'); // therapist/staff
            $table->date('period_start');
            $table->date('period_end');
            $table->integer('sessions_count')->default(0);
            $table->integer('hours_worked')->default(0);
            $table->decimal('base_amount', 15, 2);
            $table->decimal('bonus', 15, 2)->default(0);
            $table->decimal('deductions', 15, 2)->default(0);
            $table->decimal('total_amount', 15, 2);
            $table->foreignId('currency_id')->constrained('currencies');
            $table->enum('status', ['draft', 'approved', 'paid'])->default('draft');
            $table->text('notes')->nullable();
            $table->foreignId('created_by')->constrained('users');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('wages');
    }
};
