made changes in distrubance amount

master
varun 2 years ago
parent da98313cd9
commit 2de9460631

@ -784,4 +784,23 @@ exports.getBillingInfo = async (req, reply) => {
} catch (err) { } catch (err) {
reply.status(400).send({ message: err.message }); reply.status(400).send({ message: err.message });
} }
};
exports.getAlldistrubanceamountsdetails = async (req, reply) => {
const limit = parseInt(req.query.limit) || 100;
const page = parseInt(req.query.page) || 1;
const startindex = (page - 1) * limit;
const customerId = req.params.customerId
try {
await Tankerbooking.find({ customerId: customerId, payment_status: "due",distrubance_status:"1"})
.limit(limit)
.skip(startindex)
.exec()
.then((docs) => {
reply.send({ status_code: 200, data: docs, count: docs.length });
})
} catch (err) {
reply.status(400).send({ message: err.message });
}
}; };

@ -684,15 +684,15 @@ exports.distrubanceStatus = async (req, reply) => {
const distrubance_price = parseInt(booking.distrubance_price .replace(/,/g, ''), 10) const distrubance_price = parseInt(booking.distrubance_price .replace(/,/g, ''), 10)
const price = parseInt(booking.price.replace(/,/g, ''), 10) const price = parseInt(booking.price.replace(/,/g, ''), 10)
const amount_due = parseInt(booking.amount_due .replace(/,/g, ''), 10) const amount_due = parseInt(booking.amount_due .replace(/,/g, ''), 10)
const price_variation = price-distrubance_price const price_variation = price-distrubance_price
if (action === "accept") { if (action === "accept") {
await Tankerbooking.findOneAndUpdate({ bookingid:bookingid }, { $set: { amount_due: price,amount_difference:"0" } }); await Tankerbooking.findOneAndUpdate({ bookingid:bookingid }, { $set: { amount_due: distrubance_price,amount_difference:price_variation},distrubance_status:"1" });
} }
if (action === "reject") { if (action === "reject") {
await Tankerbooking.findOneAndUpdate({ bookingid:bookingid }, { $set: { amount_due: distrubance_price,amount_difference:"0" } }); await Tankerbooking.findOneAndUpdate({ bookingid:bookingid }, { $set: { amount_due: price,amount_difference:"0",distrubance_status:"0" } });
} }

@ -71,6 +71,7 @@ const tankersbookingSchema = new mongoose.Schema({
longitude: { type : Number,default: 0.0}, longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0}, latitude: {type: Number,default: 0.0},
deliveredDate: { type: String, default: null }, deliveredDate: { type: String, default: null },
distrubance_status: { type: String, default: "0" },
}); });
const boreSchema = new mongoose.Schema({ const boreSchema = new mongoose.Schema({

@ -712,6 +712,37 @@ module.exports = function (fastify, opts, next) {
}); });
fastify.route({
method: "GET",
url: "/api/getAlldistrubanceamountsdetails/:customerId",
schema: {
tags: ["Supplier-Order"],
description:"This is to get all distrubance amount accounts",
summary: "This is to get all distrubance amount accounts",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler:supplierOrderController.getAlldistrubanceamountsdetails,
});
next(); next();
} }

Loading…
Cancel
Save