const mongoose = require('mongoose');

const paymentSchema = new mongoose.Schema({
  invoice_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Invoice', required: true },
  payment_date: { type: Date, required: true },
  amount: { type: Number, required: true },
  payment_method: { type: String, enum: ['cash','bank_transfer','card','mobile_money','cheque'], required: true },
  reference_number: String,
  status: { type: String, enum: ['pending','confirmed','failed','refunded'], default: 'confirmed' },
  notes: String,
}, { timestamps: true });

module.exports = mongoose.model('Payment', paymentSchema);
