<?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('tbl_stock_products', function (Blueprint $table) {
            $table->id();
            $table->string('stock_erp', 100)->nullable();
            $table->float('stock_system', 20, 2)->nullable();
            $table->date('registration_date');
            $table->date('last_update');
            $table->bigInteger('idproduct')->unsigned();
            $table->bigInteger('idwarehouse')->nullable()->unsigned();
            $table->char('type_movement', 1)->comment('1: Ingreso, 2: Salida');
            $table->float('initial_stock', 20, 2);
            $table->float('difference', 20, 2);
            $table->char('isAdjustment', 1)->default(0)->comment('1: Si, 0: No');
            $table->string('folio')->nullable();
            $table->varchar('type_dte', 3)->nullable();
            $table->dateTime('date_dte')->nullable();
            $table->bigInteger('idcompany')->unsigned();
            $table->char('status', 1)->default(1);
            $table->timestamps();

            $table->foreign('idproduct')->references('id')->on('tbl_products');
            $table->foreign('idwarehouse')->references('id')->on('tbl_store');
            $table->foreign('idcompany')->references('id')->on('tbl_company');
        });
    }

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