changes in quotation

master
Varun 9 months ago
parent 66119997b4
commit b90735fbbf

@ -1285,7 +1285,14 @@ exports.createquotationforSensor = async (req, reply) => {
const i_id = await generatequatationId(); const i_id = await generatequatationId();
const quatationId = `AWQU${i_id}`; const quatationId = `AWQU${i_id}`;
const { installationId } = req.params; const { installationId } = req.params;
const { customerId, masters, slaves, motor_switches, electricals } = req.body; const { customerId, masters, slaves,sensors, motor_switches, electricals } = req.body;
// Ensure electricals field is properly formatted
const formattedElectricals = electricals.map((item) => ({
type: item.type || "",
wire: item.wire || "",
switch: item.switch || "",
text: item.text || "",
}));
// Create a new SensorQuotation document // Create a new SensorQuotation document
@ -1295,8 +1302,9 @@ exports.createquotationforSensor = async (req, reply) => {
installationId: installationId, installationId: installationId,
masters, masters,
slaves, slaves,
sensors,
motor_switches, motor_switches,
electricals, electricals: formattedElectricals,
}); });

@ -282,6 +282,7 @@ const sensorquotationSchema = new mongoose.Schema({
masters_quantity_price: { type: String }, masters_quantity_price: { type: String },
masters_total_price: { type: String }, masters_total_price: { type: String },
slaves: { type: String }, slaves: { type: String },
sensors: { type: String },
slaves_quantity_price: { type: String }, slaves_quantity_price: { type: String },
slaves_total_price: { type: String }, slaves_total_price: { type: String },
motor_switches: { type: String }, motor_switches: { type: String },
@ -290,13 +291,18 @@ const sensorquotationSchema = new mongoose.Schema({
quote_status: { type: String, default: null }, quote_status: { type: String, default: null },
quoted_amount: { type: String, default: null }, quoted_amount: { type: String, default: null },
comments: { type: String, default: null }, comments: { type: String, default: null },
electricals: [{ type: String }], electricals: [
{
type: { type: String, default: null },
wire: { type: String, default: null },
switch: { type: String, default: null },
text: { type: String, default: null },
},
],
master_type_quantity_price: { type: String, default: null }, master_type_quantity_price: { type: String, default: null },
master_type_total_price: { type: String, default: null }, master_type_total_price: { type: String, default: null },
sensor_type_quantity_price: { type: String , default: null}, sensor_type_quantity_price: { type: String , default: null},
sensor_type_total_price: { type: String , default: null}, sensor_type_total_price: { type: String , default: null},
switch_type_quantity_price: { type: String, default: null }, switch_type_quantity_price: { type: String, default: null },
switch_type_total_price: { type: String, default: null }, switch_type_total_price: { type: String, default: null },
qutation_total_price: { type: String, default: null }, qutation_total_price: { type: String, default: null },

@ -1134,6 +1134,7 @@ fastify.get("/api/getbatchnumbers/:storeId", {
handler: storeController.getbatchnumbers, handler: storeController.getbatchnumbers,
}); });
fastify.post("/api/createquotationforSensor/:installationId", { fastify.post("/api/createquotationforSensor/:installationId", {
schema: { schema: {
description: "This is for create quotation for sensors", description: "This is for create quotation for sensors",
@ -1155,11 +1156,20 @@ fastify.post("/api/createquotationforSensor/:installationId", {
customerId: { type: "string" }, customerId: { type: "string" },
masters: { type: "string" }, masters: { type: "string" },
slaves: { type: "string" }, slaves: { type: "string" },
sensors: { type: "string" },
motor_switches: { type: "string" }, motor_switches: { type: "string" },
electricals: { electricals: {
type: "array", type: "array",
items: { type: "string" }, maxItems: 2500,
description: "List of electrical items", items: {
type: "object",
properties: {
type: { type: "string", default: null },
wire: { type: "string", default: null },
switch: { type: "string", default: null },
text: { type: "string", default: null },
},
},
}, },
}, },
}, },

Loading…
Cancel
Save