<?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('dettaglio_ripartizione_spese', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ripartizione_spese_id')->constrained('ripartizione_spese')->cascadeOnDelete();
            $table->unsignedBigInteger('unita_immobiliare_id');
            $table->unsignedBigInteger('anagrafica_condominiale_id');
            $table->decimal('millesimi', 8, 3);
            $table->decimal('importo_calcolato', 10, 2);
            $table->decimal('importo_rettificato', 10, 2)->nullable();
            $table->string('motivo_rettifica')->nullable();
            $table->text('note')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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