|
|
@ -1280,35 +1280,38 @@ exports.getusersofParticularInstaller = async (req, reply) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dayjs = require('dayjs'); // Install this library using npm install dayjs
|
|
|
|
|
|
|
|
|
|
|
|
exports.createquotationforSensor = async (req, reply) => {
|
|
|
|
exports.createquotationforSensor = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
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,sensors, 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) => ({
|
|
|
|
// Format electricals field
|
|
|
|
|
|
|
|
const formattedElectricals = electricals.map((item) => ({
|
|
|
|
type: item.type || "",
|
|
|
|
type: item.type || "",
|
|
|
|
wire: item.wire || "",
|
|
|
|
wire: item.wire || "",
|
|
|
|
switch: item.switch || "",
|
|
|
|
switch: item.switch || "",
|
|
|
|
text: item.text || "",
|
|
|
|
text: item.text || "",
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Format current date and time
|
|
|
|
|
|
|
|
const formattedDateTime = dayjs().format('DD-MMM-YYYY - HH:mm');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a new SensorQuotation document
|
|
|
|
// Create a new SensorQuotation document
|
|
|
|
const newQuotation = new SensorQuotation({
|
|
|
|
const newQuotation = new SensorQuotation({
|
|
|
|
quatationId,
|
|
|
|
quatationId,
|
|
|
|
customerId: customerId,
|
|
|
|
customerId: customerId,
|
|
|
|
installationId: installationId,
|
|
|
|
installationId: installationId,
|
|
|
|
quote_status:"sentfrominstaller",
|
|
|
|
quote_status: "Installer Ki pampina,Vaadu reply ivvale inka",
|
|
|
|
masters,
|
|
|
|
masters,
|
|
|
|
slaves,
|
|
|
|
slaves,
|
|
|
|
sensors,
|
|
|
|
sensors,
|
|
|
|
motor_switches,
|
|
|
|
motor_switches,
|
|
|
|
electricals: formattedElectricals,
|
|
|
|
electricals: formattedElectricals,
|
|
|
|
|
|
|
|
datetime: formattedDateTime, // Add the formatted date and time
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const savedQuotation = await newQuotation.save();
|
|
|
|
const savedQuotation = await newQuotation.save();
|
|
|
@ -1328,6 +1331,7 @@ exports.createquotationforSensor = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getallquotationdata = async (req, reply) => {
|
|
|
|
exports.getallquotationdata = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await SensorQuotation.find({})
|
|
|
|
await SensorQuotation.find({})
|
|
|
|