import mongoose from 'mongoose';

const stockTransactionSchema = new mongoose.Schema(
  {
    productId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Product',
      required: true,
    },
    warehouseId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Warehouse',
      required: true,
    },
    transactionDate: {
      type: Date,
      required: true,
    },
    quantityMoved: {
      type: Number,
      required: true,
      min: 1,
    },
    transactionType: {
      type: String,
      required: true,
      enum: ['Stock In', 'Stock Out'],
    },
  },
  { timestamps: true }
);

export default mongoose.model('StockTransaction', stockTransactionSchema);
