master^2
Varun 7 months ago
parent b5dcc1bf4c
commit 2e59a1a5a8

@ -2236,6 +2236,7 @@ exports.acceptQuotation = async (req, reply) => {
// Find the quotation by ID // Find the quotation by ID
const quotation = await SensorQuotation.findOne({ quatationId: quotationId }); const quotation = await SensorQuotation.findOne({ quatationId: quotationId });
console.log(quotation,"quotation")
if (!quotation) { if (!quotation) {
return reply.status(404).send({ error: "Quotation not found" }); return reply.status(404).send({ error: "Quotation not found" });
@ -2250,6 +2251,7 @@ exports.acceptQuotation = async (req, reply) => {
}); });
} else if (action === "accept") { } else if (action === "accept") {
const { customerId, masters, slaves, sensors, master_connections } = quotation; const { customerId, masters, slaves, sensors, master_connections } = quotation;
console.log(customerId,masters,slaves,sensors,master_connections)
// Convert quotation to an order object and include storeId // Convert quotation to an order object and include storeId
const newOrder = new Order({ const newOrder = new Order({

@ -6120,14 +6120,14 @@ async function processIotData(hw_Id, data) {
await iotTankData.save(); await iotTankData.save();
// Delete excess records (keep only the latest three records) // Delete excess records (keep only the latest three records)
const recordsToKeep = 3; // const recordsToKeep = 3;
const recordsToDelete = await IotData.find({ hardwareId: hw_Id }) // const recordsToDelete = await IotData.find({ hardwareId: hw_Id })
.sort({ date: -1, time: -1 }) // .sort({ date: -1, time: -1 })
.skip(recordsToKeep); // .skip(recordsToKeep);
for (const record of recordsToDelete) { // for (const record of recordsToDelete) {
await record.remove(); // await record.remove();
} // }
// Process each tank // Process each tank
for (const tank of tanks) { for (const tank of tanks) {

Loading…
Cancel
Save