const mongoose = require("mongoose");

const warehouseSchema = new mongoose.Schema(
  {
    warehouseName: {
      type: String,
      required: true,
      trim: true,
    },

    warehouseCode: {
      type: String,
      // required: true,
      // unique: true,
      uppercase: true,
      trim: true,
    },

    address: {
      line1: {
        type: String,
        trim: true,
      },
      line2: {
        type: String,
        trim: true,
      },
      city: {
        type: String,
        trim: true,
      },
      state: {
        type: String,
        trim: true,
      },
      country: {
        type: String,
        default: "India",
      },
      pincode: {
        type: String,
        trim: true,
      },
    },

    capacity: {
      type: Number,
      default: 0,
      min: 0,
    },

    uomId: {
  type: mongoose.Schema.Types.ObjectId,
  ref: "UnitOfMeasurement",
  required: false,
},

 
    incharge : {
        type : mongoose.Schema.Types.ObjectId,
        ref : "User"
    },

    status: {
      type: String,
      enum: ["ACTIVE", "INACTIVE"],
      default: "ACTIVE",
    },

    isDeleted: {
      type: Boolean,
      default: false,
    },

    // Audit fields
    createdBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },

    updatedBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
    },
  },
  {
    timestamps: true,
  }
);

module.exports = mongoose.model("Warehouse", warehouseSchema);