|
|
@ -10,6 +10,7 @@ const fastify = require("fastify")({
|
|
|
|
logger: true,
|
|
|
|
logger: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
|
|
|
|
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
|
|
|
|
|
|
|
|
const moment = require("moment");
|
|
|
|
|
|
|
|
|
|
|
|
exports.orderStartedSms = async (request, reply) => {
|
|
|
|
exports.orderStartedSms = async (request, reply) => {
|
|
|
|
//console.log(bookingId,supplierContact,deliveryAgentContact,mobile)
|
|
|
|
//console.log(bookingId,supplierContact,deliveryAgentContact,mobile)
|
|
|
@ -377,14 +378,15 @@ exports.deliveryboystartandstop = async (req, reply) => {
|
|
|
|
exports.amountUpdateByDeliveryBoy = async (req, reply) => {
|
|
|
|
exports.amountUpdateByDeliveryBoy = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const { bookingId } = req.params;
|
|
|
|
const { bookingId } = req.params;
|
|
|
|
const { amount_paid, payment_mode, orderStatus } = req.body;
|
|
|
|
const { amount_paid, payment_mode, orderStatus, deliveredDate } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
const booking = await Tankerbooking.findOne({ bookingid: bookingId });
|
|
|
|
const booking = await Tankerbooking.findOne({ bookingid: bookingId });
|
|
|
|
if (!booking) {
|
|
|
|
if (!booking) {
|
|
|
|
return reply.status(404).send({ message: "Booking not found" });
|
|
|
|
return reply.status(404).send({ message: "Booking not found" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const amount_initial_due = parseInt(booking.amount_due.replace(/,/g, ""), 10);
|
|
|
|
// const amount_initial_due = parseInt(booking.amount_due.replace(/,/g, ""), 10);
|
|
|
|
|
|
|
|
const amount_initial_due = booking.amount_due ? parseInt(booking.amount_due.replace(/,/g, ""), 10) : 0;
|
|
|
|
const amount_due = amount_initial_due - parseInt(amount_paid.replace(/,/g, ""), 10);
|
|
|
|
const amount_due = amount_initial_due - parseInt(amount_paid.replace(/,/g, ""), 10);
|
|
|
|
|
|
|
|
|
|
|
|
const updateData = {
|
|
|
|
const updateData = {
|
|
|
@ -392,14 +394,14 @@ exports.amountUpdateByDeliveryBoy = async (req, reply) => {
|
|
|
|
payment_mode,
|
|
|
|
payment_mode,
|
|
|
|
orderStatus,
|
|
|
|
orderStatus,
|
|
|
|
amount_due,
|
|
|
|
amount_due,
|
|
|
|
payment_status: amount_due === 0 ? "paid" : "due"
|
|
|
|
payment_status: amount_due === 0 ? "paid" : "due",
|
|
|
|
|
|
|
|
deliveredDate: moment(deliveredDate, "DD-MM-YYYY HH:mm:ss").tz('Asia/Kolkata').format("DD-MM-YYYY HH:mm:ss"),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
await Tankerbooking.findOneAndUpdate(
|
|
|
|
await Tankerbooking.findOneAndUpdate(
|
|
|
|
{ bookingid: bookingId },
|
|
|
|
{ bookingid: bookingId },
|
|
|
|
{ $set: updateData }
|
|
|
|
{ $set: updateData }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, message: "Successfully updated" });
|
|
|
|
reply.send({ status_code: 200, message: "Successfully updated" });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|