const mongoose = require('mongoose');

const fuelLogSchema = new mongoose.Schema({
  vehicle_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Vehicle', required: true },
  driver_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Driver' },
  trip_id: { type: mongoose.Schema.Types.ObjectId, ref: 'Trip' },
  fuel_date: { type: Date, required: true },
  liters: { type: Number, required: true },
  cost_per_liter: { type: Number, required: true },
  total_cost: { type: Number, required: true },
  station_name: String,
  station_location: String,
  odometer_reading: { type: Number, required: true },
  fuel_type: { type: String, enum: ['petrol','diesel','electric_charge','other'], default: 'diesel' },
  receipt_number: String,
  notes: String,
}, { timestamps: true });

module.exports = mongoose.model('FuelLog', fuelLogSchema);
