changes in store quote

master^2
Varun 7 months ago
parent ddba664104
commit 51b01ec127

@ -1422,6 +1422,31 @@ exports.getbatchnumbers = async (req, reply) => {
};
exports.getbatquotationsforparticularstore = async (req, reply) => {
try {
const storeId = req.params.storeId;
let type = req.params.type ? req.params.type.toLowerCase() : null; // Convert type to uppercase
let query = { storeId: storeId };
if (type !== "ALL") {
query.type = type;
}
// Fetch data based on the query
const result = await Insensors.find(query);
if (!result ) {
return reply.send({ status_code: 404, error: "not found" });
}
reply.send({ status_code: 200, data: result });
} catch (err) {
throw boom.boomify(err);
}
};
exports.getiots = async (req, reply) => {
try {
const storeId = req.params.storeId;
@ -1475,7 +1500,7 @@ exports.createquotationforSensor = async (req, reply) => {
try {
const i_id = await generatequatationId();
const quatationId = `AWQU${i_id}`;
const { installationId } = req.params;
const { surveyId } = req.params;
const { customerId, masters, slaves, sensors, motor_switches, electricals } = req.body;
// Format electricals field
@ -1518,7 +1543,7 @@ exports.createquotationforSensor = async (req, reply) => {
const newQuotation = new SensorQuotation({
quatationId,
customerId,
installationId,
surveyId,
quote_status: "sentfrominstaller",
masters,
slaves,

@ -381,6 +381,7 @@ const orderSchema = new mongoose.Schema({
const sensorquotationSchema = new mongoose.Schema({
customerId: { type: String },
surveyId: { type: String, default: null },
installationId: { type: String, default: null },
quatationId: { type: String, default: null },
masters: { type: String },

@ -1238,6 +1238,33 @@ fastify.get("/api/getbatchnumbers/:storeId/:type", {
handler: storeController.getbatchnumbers,
});
fastify.get("/api/getbatquotationsforparticularstore/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get quotations for store based on store id",
summary: "This is to Get quotations for store based on store id",
params: {
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
required: ["storeId"],
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getbatquotationsforparticularstore,
});
fastify.get("/api/getiots/:storeId/:type", {
schema: {
tags: ["Store-Data"],
@ -1268,18 +1295,18 @@ fastify.get("/api/getiots/:storeId/:type", {
});
fastify.post("/api/createquotationforSensor/:installationId", {
fastify.post("/api/createquotationforSensor/:surveyId", {
schema: {
description: "This is for create quotation for sensors",
tags: ["Install"],
summary: "This is for create quotation for sensors",
params: {
required: ["installationId"],
required: ["surveyId"],
type: "object",
properties: {
installationId: {
surveyId: {
type: "string",
description: "installationId",
description: "surveyId",
},
},
},

Loading…
Cancel
Save