<?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('warehouse_stocks', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('warehouse_id');
            $table->unsignedBigInteger('supplier_id')->nullable();
            $table->string('product_id');
            $table->string('attribute_id');
            $table->string('stock_date')->nullable();
            $table->integer('quantity');
            $table->decimal('unit_price', 20, 2);
            $table->decimal('tp_price', 20, 2)->nullable();
            $table->decimal('mrp_price', 20, 2)->nullable();
            $table->integer('latest_unit_price')->nullable();
            $table->decimal('tp_price_total', 20, 2)->nullable();
            $table->decimal('mrp_price_total', 20, 2)->nullable();
            $table->decimal('unit_price_total', 20, 2)->nullable();
            $table->string('opening_stock')->nullable();
            $table->string('opening_stock_date')->nullable();
            $table->string('mfg_date')->nullable();
            $table->string('exp_date')->nullable();
            $table->string('vat')->nullable();
            $table->string('tax')->nullable();
            $table->string('batch_no')->nullable();
            $table->string('conversion_input', 255)->nullable();
            $table->timestamps();
            $table->foreign('warehouse_id')->references('id')->on('warehouses')->onDelete('cascade');
        });
    }

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