<?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('stocks', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->index()->constrained('users')->onDelete('cascade');
            $table->foreignId('purchase_id')->index()->constrained('purchases')->onDelete('cascade');
            $table->foreignId('medicine_id')->index()->constrained('medicines')->onDelete('cascade');
            $table->foreignId('leaf_setting_id')->index()->constrained('leaf_settings')->onDelete('cascade');
            $table->string('leaf_qty');
            $table->string('sku_qty');
            $table->double('supplier_price', 10, 2)->default(0);
            $table->double('box_mrp', 10, 2)->default(0);
            $table->double('sell_price', 10, 2)->default(0)->comment('per qty');
            $table->double('total_purchase_price', 10, 2)->default(0);
            $table->timestamps();
        });
    }

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