const mongoose = require('mongoose');

const salesSchema = new mongoose.Schema(
  {
    invoiceNumber: {
      type: String,
      required: true,
      unique: true,
      trim: true,
    },
    salesDate: {
      type: Date,
      required: true,
    },
    paymentMethod: {
      type: String,
      required: true,
      trim: true,
    },
    totalAmountPaid: {
      type: Number,
      required: true,
      min: 0,
    },
    quantitySold: {
      type: Number,
      required: true,
      min: 0,
    },
    product_FK: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Product',
      required: true,
    },
    customer_FK: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Customer',
      required: true,
    },
  },
  { timestamps: true }
);

module.exports = mongoose.model('Sales', salesSchema);
