diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index b3471a16..fc93cb74 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -2321,7 +2321,7 @@ exports.acceptQuotation = async (req, reply) => { { $set: { status: "blocked", customerId, connected_to: masterHardwareId } } ); - // Assign each slave a corresponding tank + // Assign each slave a corresponding tank (1-to-1 mapping) const tanks = masterData.tanks || []; for (let j = 0; j < availableSlaves.length; j++) { @@ -2356,19 +2356,6 @@ exports.acceptQuotation = async (req, reply) => { ); } - // ✅ Step 2.5: Update master_connections.hardwareId in Order - const updatedMasterConnections = newOrder.master_connections.map((conn, index) => { - return { - ...conn, - hardwareId: blockedMasters[index]?.hardwareId || null, - }; - }); - - await Order.updateOne( - { _id: newOrder._id }, - { $set: { master_connections: updatedMasterConnections } } - ); - // Step 3: Assign Sensors to Slaves if (parseInt(sensors) > 0 && blockedSlaves.length > 0) { const availableSensors = await Insensors.find({ storeId, type: "sensor", status: "available" }) @@ -2448,7 +2435,7 @@ exports.acceptQuotation = async (req, reply) => { console.error("Error processing quotation:", err); return reply.status(500).send({ error: "Internal server error" }); } -} +};