const mongoose = require('mongoose');

const deliverySchema = new mongoose.Schema(
  {
    deliveryCode: { type: String, required: true, unique: true, trim: true },
    deliveryDate: { type: Date, required: true },
    quantityDelivered: { type: Number, required: true, min: 1 },
    deliveryStatus: {
      type: String,
      required: true,
      enum: ['Scheduled', 'In Progress', 'Completed', 'Failed'],
      default: 'Scheduled',
    },
    shipmentNumber: { type: String, required: true, ref: 'Shipment' },
  },
  { timestamps: true }
);

module.exports = mongoose.model('Delivery', deliverySchema);
