CRUD lecturas de bomba

This commit is contained in:
2026-06-29 23:22:53 +00:00
parent 8482ee608d
commit 1aaee34a83
4 changed files with 507 additions and 0 deletions

View File

@ -0,0 +1,89 @@
import mongoose from "mongoose";
const pumpReadingSchema = new mongoose.Schema({
readingNumber:{
type:String,
required:true,
unique:true
},
fuelPumpId:{
type:mongoose.Schema.Types.ObjectId,
ref:"FuelPump",
required:true
},
fuelTypeId:{
type:mongoose.Schema.Types.ObjectId,
ref:"FuelType",
required:true
},
readingDate:{
type:Date,
required:true
},
initialReading:{
type:Number,
required:true,
min:0
},
finalReading:{
type:Number,
required:true,
min:0
},
gallonsDispensed:{
type:Number,
default:0
},
systemDispensed:{
type:Number,
default:0
},
difference:{
type:Number,
default:0
},
createdBy:{
type:mongoose.Schema.Types.ObjectId,
ref:"User",
required:true
},
status:{
type:String,
enum:["ABIERTA",
"CUADRADA",
"CON_DIFERENCIA"
],
default:"ABIERTA"
},
comments:{
type:String
}
},
{
timestamps:true,
versionKey:false
}
);
pumpReadingSchema.pre("save",
function(){
this.gallonsDispensed = this.finalReading-this.initialReading;
}
);
export default mongoose.model("PumpReading",pumpReadingSchema);