|
|
@ -32,6 +32,7 @@ exports.orderNow = async (req, reply) => {
|
|
|
|
booking_info.delivery_agent_mobile = agent_mobile
|
|
|
|
booking_info.delivery_agent_mobile = agent_mobile
|
|
|
|
booking_info.delivery_agent_alternative_mobile = agent_alternative_mobile
|
|
|
|
booking_info.delivery_agent_alternative_mobile = agent_alternative_mobile
|
|
|
|
booking_info.price = price
|
|
|
|
booking_info.price = price
|
|
|
|
|
|
|
|
booking_info.amount_due = price
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -312,26 +313,39 @@ exports.deliveryboystartandstop = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
exports.amountUpdateByDeliveryBoy = async (req, reply) => {
|
|
|
|
exports.amountUpdateByDeliveryBoy = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log(req.params.supplierId)
|
|
|
|
const { bookingId } = req.params;
|
|
|
|
const amount_paid = parseInt(req.body.amount_paid.replace(/,/g, ''), 10)
|
|
|
|
const { amount_paid, payment_mode, orderStatus } = req.body;
|
|
|
|
const payment_mode = req.body.payment_mode
|
|
|
|
|
|
|
|
const booking = await Tankerbooking.findOneAndUpdate({bookingid:req.params.bookingId});
|
|
|
|
const booking = await Tankerbooking.findOne({ bookingid: bookingId });
|
|
|
|
const tanker_price = parseInt(booking.price.replace(/,/g, ''), 10)
|
|
|
|
if (!booking) {
|
|
|
|
const amount_due = tanker_price-amount_paid
|
|
|
|
return reply.status(404).send({ message: "Booking not found" });
|
|
|
|
const orderStatus = req.body.orderStatus
|
|
|
|
|
|
|
|
await Tankerbooking.findOneAndUpdate({bookingid:req.params.bookingId}, { $set: { amount_paid: amount_paid,amount_due:amount_due,payment_mode:payment_mode,orderStatus:orderStatus} });
|
|
|
|
|
|
|
|
const booking_data = await Tankerbooking.findOneAndUpdate({bookingid:req.params.bookingId});
|
|
|
|
|
|
|
|
const final_amount_due = parseInt(booking_data.amount_due.replace(/,/g, ''), 10)
|
|
|
|
|
|
|
|
if(final_amount_due === 0){
|
|
|
|
|
|
|
|
await Tankerbooking.findOneAndUpdate({bookingid:req.params.bookingId}, { $set: { payment_status:"paid" }});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply.send({ status_code: 200, "message": "successfully updated"});
|
|
|
|
|
|
|
|
|
|
|
|
const amount_initial_due = parseInt(booking.amount_due.replace(/,/g, ""), 10);
|
|
|
|
|
|
|
|
const amount_due = amount_initial_due - parseInt(amount_paid.replace(/,/g, ""), 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateData = {
|
|
|
|
|
|
|
|
amount_paid,
|
|
|
|
|
|
|
|
payment_mode,
|
|
|
|
|
|
|
|
orderStatus,
|
|
|
|
|
|
|
|
amount_due,
|
|
|
|
|
|
|
|
payment_status: amount_due === 0 ? "paid" : "due"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Tankerbooking.findOneAndUpdate(
|
|
|
|
|
|
|
|
{ bookingid: bookingId },
|
|
|
|
|
|
|
|
{ $set: updateData }
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, message: "Successfully updated" });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
console.error(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.userAccounts = async (req, reply) => {
|
|
|
|
exports.userAccounts = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|