|
|
@ -109,6 +109,11 @@ exports.tankerBooking = async (req, reply) => {
|
|
|
|
const count = bookingCount.toString().padStart(4, '0')
|
|
|
|
const count = bookingCount.toString().padStart(4, '0')
|
|
|
|
const bookingId = `ARM${year}${month}${day}${count}`
|
|
|
|
const bookingId = `ARM${year}${month}${day}${count}`
|
|
|
|
bookingCount = (bookingCount + 1) % 100;
|
|
|
|
bookingCount = (bookingCount + 1) % 100;
|
|
|
|
|
|
|
|
var booking_id = await Tankerbooking.findOne({ bookingid: bookingId})
|
|
|
|
|
|
|
|
if(booking_id){
|
|
|
|
|
|
|
|
throw new Error('booking_id already exists');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
|
|
bookingsData = {
|
|
|
|
bookingsData = {
|
|
|
|
bookingid : bookingId,
|
|
|
|
bookingid : bookingId,
|
|
|
@ -116,7 +121,6 @@ exports.tankerBooking = async (req, reply) => {
|
|
|
|
capacity: req.body.capacity,
|
|
|
|
capacity: req.body.capacity,
|
|
|
|
address: req.body.address,
|
|
|
|
address: req.body.address,
|
|
|
|
dateTime: req.body.dateTime,
|
|
|
|
dateTime: req.body.dateTime,
|
|
|
|
amount :req.body.amount
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -131,10 +135,10 @@ exports.tankerBooking = async (req, reply) => {
|
|
|
|
tankersBookingData.typeofwater = usertobeInserted.typeofwater;
|
|
|
|
tankersBookingData.typeofwater = usertobeInserted.typeofwater;
|
|
|
|
tankersBookingData.address = usertobeInserted.address;
|
|
|
|
tankersBookingData.address = usertobeInserted.address;
|
|
|
|
tankersBookingData.dateTime = usertobeInserted.dateTime;
|
|
|
|
tankersBookingData.dateTime = usertobeInserted.dateTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const booking_data = await tankersBookingData.save();
|
|
|
|
const booking_data = await tankersBookingData.save();
|
|
|
|
|
|
|
|
|
|
|
|