diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 6662c397..78e0aae8 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1638,7 +1638,18 @@ exports.createquotationforSensor = async (req, reply) => { tankName: tank.tankName || "", tankLocation: tank.tankLocation || "" })) - : [] + : [], + motor_switches: Array.isArray(item.motor_switches) + ? item.motor_switches.map(motor_switch => ({ + + from_tank: motor_switch.from_tank || "", + from_location: motor_switch.from_location || "", + to_tank: motor_switch.to_tank || "", + to_location: motor_switch.to_location || "", + + })) + : [], + })); // Fetch pricing data from Iotprice database @@ -1705,6 +1716,8 @@ exports.createquotationforSensor = async (req, reply) => { + + exports.editQuotationForSensor = async (req, reply) => { try { const { quatationId } = req.params; // Get the ID of the quotation to edit diff --git a/src/models/store.js b/src/models/store.js index 676cac82..ecb965ca 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -528,6 +528,15 @@ const sensorquotationSchema = new mongoose.Schema({ }, ], + motor_switches: [ + { + from_tank: { type: String, default: null }, + from_location: { type: String, default: null }, + to_tank: { type: String, default: null }, + to_location: { type: String, default: null }, + }, + ], + }, ], diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index e30bad00..18cb49fe 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1439,6 +1439,19 @@ fastify.post("/api/createquotationforSensor/:surveyId", { }, default: [], }, + motor_switches: { + type: "array", + items: { + type: "object", + properties: { + from_tank: { type: "string", default: null }, + from_location: { type: "string", default: null }, + to_tank: { type: "string", default: null }, + to_location: { type: "string", default: null } + }, + }, + default: [], + }, }, }, }, @@ -1462,6 +1475,7 @@ fastify.post("/api/createquotationforSensor/:surveyId", { handler: storeController.createquotationforSensor, }); + fastify.post("/api/createEstimationPrice", { schema: { description: "Calculate estimated cost for a list of items",