const mongoose = require('mongoose');

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

module.exports = mongoose.model('StockTransaction', stockTransactionSchema);
