const mongoose = require('mongoose');

const stockOutSchema = new mongoose.Schema(
  {
    date: {
      type: Date,
      required: true,
    },
    quantity: {
      type: Number,
      required: true,
    },
    reason: {
      type: String,
      trim: true,
      default: 'Sale',
    },
    destination: {
      type: String,
      trim: true,
      default: '',
    },
    sparePart: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'SparePart',
      required: true,
    },
    createdBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
      required: true,
    },
  },
  { timestamps: true }
);

module.exports = mongoose.model('StockOut', stockOutSchema);
