You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1146 lines
34 KiB

const mongoose = require('mongoose')
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;
const { Counter} = require('../models/User')
const code = Math.floor(100000 + Math.random() * 900000);
const generateinstallationId = async () => {
var result = await Counter.findOneAndUpdate(
{ _id: 'installation_id' },
{ $inc: { seq: 1 } },
{ upsert: true, new: true }
);
return result.seq;
};
const generatequatationId = async () => {
var result = await Counter.findOneAndUpdate(
{ _id: 'installation_id' },
{ $inc: { seq: 1 } },
{ upsert: true, new: true }
);
return result.seq;
};
const installationschema = new mongoose.Schema({
// name: { type: String },
phone: { type: String, unique: true, trim: true },
address: String,
installationId: { type: String },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number},
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: [{ email: String, verified: { type: Boolean, default: false } }],
services: { password: { bcrypt: String } },
1 year ago
alternativeNumber: { type: String, default: null },
firstName: { type: String, default: null },
lastName: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },
designation: { type: String, default: null },
reportingManager: { type: String, default: null },
departmentName: { type: String, default: null },
zone: { type: String, default: null },
type: { type: String },
profile: {
1 year ago
state: { type: String, default: null },
country: { type: String, default: null },
},
team : { type: String, default: null},
manager : { type: String, default: null},
team_member: {
team_member: [
{
teamMemberId: { type: String },
firstName: { type: String },
phone: { type: String },
installationTeamMemId: { type: String },
password: { type: String, default: null },
status: { type: String, default: "active" },
email: { type: String },
alternativePhone: { type: String },
}
],
},
longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0},
fcmId: { type: String, default: null },
createdAt: {
type: Date,
default: function () {
return Date.now();
},
},
createdBy: ObjectId,
updatedAt: {
type: Date,
default: function () {
return Date.now();
},
},
updatedBy: ObjectId,
});
const surveyschema = new mongoose.Schema({
// name: { type: String },
phone: { type: String, unique: true, trim: true },
address: String,
surveyId: { type: String },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number},
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: [{ email: String, verified: { type: Boolean, default: false } }],
services: { password: { bcrypt: String } },
alternativeNumber: { type: String, default: null },
firstName: { type: String, default: null },
lastName: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },
designation: { type: String, default: null },
reportingManager: { type: String, default: null },
departmentName: { type: String, default: null },
zone: { type: String, default: null },
type: { type: String },
profile: {
state: { type: String, default: null },
country: { type: String, default: null },
},
team : { type: String, default: null},
manager : { type: String, default: null},
team_member: {
team_member: [
{
survey_teamMemberId: { type: String },
name: { type: String },
phone: { type: String },
installationTeamMemId: { type: String },
password: { type: String, default: null },
status: { type: String, default: "active" },
email: { type: String },
alternativePhone: { type: String },
}
],
},
longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0},
fcmId: { type: String, default: null },
createdAt: {
type: Date,
default: function () {
return Date.now();
},
},
createdBy: ObjectId,
updatedAt: {
type: Date,
default: function () {
return Date.now();
},
},
updatedBy: ObjectId,
});
const profilePictureInstallSchema = new Schema({
installationId: {
type: String,
unique: true,
required: true
},
picture: {
type: String, // Change the type to String
required: true,
validate: {
validator: function (value) {
const supportedFormats = ['jpg', 'jpeg', 'png'];
const fileExtension = value.split('.').pop().toLowerCase();
return supportedFormats.includes(fileExtension);
},
message: 'Picture must be a JPEG, PNG, or JPG image'
}
}
});
const profilePictureStoreSchema = new Schema({
storeId: {
type: String,
unique: true,
required: true
},
picture: {
type: String, // Change the type to String
required: true,
validate: {
validator: function (value) {
const supportedFormats = ['jpg', 'jpeg', 'png'];
const fileExtension = value.split('.').pop().toLowerCase();
return supportedFormats.includes(fileExtension);
},
message: 'Picture must be a JPEG, PNG, or JPG image'
}
}
});
4 months ago
const IssueSchema = new Schema({
//ticketId: { type: String, unique: true },
4 months ago
type: {
type: String,
4 months ago
enum: ["GSM Disconnected", "LoRa Disconnected", "GSM or LoRa Disconnected"],
4 months ago
required: true
},
hardwareId: {
type: String,
required: true
},
masterHardwareId: {
type: String
},
masterName: {
type: String
},
slaveName: {
type: String
},
hardwareIds: [String],
slaveNames: [String],
resolved: {
type: Boolean,
default: false
},
movedToCategory: {
type: Boolean,
default: false
},
category: {
type: String
},
createdAt: {
type: String
},
lastTicketRaisedAt: {
type: String
},
movedAt: {
type: String
}
});
const CategorizedIssueSchema = new Schema({
type: {
type: String,
4 months ago
enum:["GSM Disconnected", "LoRa Disconnected", "GSM or LoRa Disconnected"],
4 months ago
required: true
},
hardwareId: {
type: String,
required: true
},
masterHardwareId: {
type: String,
required: true
},
slaveName: {
type: String
},
category: {
type: String,
3 months ago
enum: ["Power Outage", "Resolved", "OutDoor Escalation","LongTerm Issues"],
4 months ago
required: true
},
// ticketId: String,
4 months ago
movedAt: {
type: String,
required: true
},
assignedTo: {
name: String,
support_teamMemberId: String,
phone: String,
email: String,
startDate: String,
3 months ago
endDate: String,
assignedAt: String,
assignmentCode: String
4 months ago
}
});
const CommentSchema = new Schema({
text: { type: String, required: true },
customerId: String,
hardwareId: String,
createdAt: { type: Date, default: Date.now }
});
const CallRecordSchema = new Schema({
call_status: { type: String },
call_time: { type: String },
customerId: String,
hardwareId: String,
createdAt: { type: Date, default: Date.now }
});
5 months ago
const supportschema = new mongoose.Schema({
// name: { type: String },
phone: { type: String, unique: true, trim: true },
address: String,
supportId: { type: String },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number},
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: [{ email: String, verified: { type: Boolean, default: false } }],
services: { password: { bcrypt: String } },
alternativeNumber: { type: String, default: null },
firstName: { type: String, default: null },
lastName: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },
designation: { type: String, default: null },
reportingManager: { type: String, default: null },
departmentName: { type: String, default: null },
zone: { type: String, default: null },
type: { type: String },
dateOfLogin: { type: String, default: null },
timeOfLogin: { type: String, default: null },
currentTime: { type: Date, default: Date.now },
4 months ago
comments: [CommentSchema],
callRecord: [CallRecordSchema],
lastTicketRaisedAt: {type : String},
4 months ago
issues: [IssueSchema],
categorizedIssues: [CategorizedIssueSchema],
resolvedIssues: [
{
type: { type: String },
hardwareId: String,
masterHardwareId: String,
category: String, // will be 'Resolved'
resolvedAt: String, // ISO string or Date
originalMovedAt: String, // store original movedAt for reference
// ticketId: String,
reason: String,
}
],
masterDisconnected: [{ // new field for master disconnected details
hardwareId: String,
masterName: String,
disconnectedAt: String,
}],
disconnectedSlaves: [{ // new field for disconnected slaves details
slaveHardwareId: String,
slaveName: String,
}],
4 months ago
// categorizedIssues: [
// {
// type: {
// type: String,
// required: true
// },
// hardwareId: {
// type: String,
// required: true
// },
// masterHardwareId: {
// type: String,
// required: true
// },
// slaveName: {
// type: String,
// },
// category: {
// type: String,
// enum: [ "Power Outage",
// "Resolved",
// "Escalation",],
// required: true
// },
// movedAt: {
// type: String, // or Date, depending on your preference
// required: true
// },
// assignedTo: {
// name: String,
// support_teamMemberId: String,
// phone: String,
// email: String,
// startDate: String,
// endDate: String
// }
// }
// ],
5 months ago
profile: {
state: { type: String, default: null },
country: { type: String, default: null },
},
team : { type: String, default: null},
manager : { type: String, default: null},
team_member: {
team_member: [
{
support_teamMemberId: { type: String },
name: { type: String },
phone: { type: String },
installationTeamMemId: { type: String },
password: { type: String, default: null },
status: { type: String, default: "active" },
email: { type: String },
alternativePhone: { type: String },
}
],
},
longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0},
fcmId: { type: String, default: null },
createdAt: {
type: Date,
default: function () {
return Date.now();
},
},
createdBy: ObjectId,
updatedAt: {
type: Date,
default: function () {
return Date.now();
},
},
updatedBy: ObjectId,
});
const storeSchema = new mongoose.Schema({
storename: { type: String },
phone: { type: String, unique: true, trim: true },
contactPersonName: {type: String},
contactPersonPhone: { type: String, unique: true, trim: true },
storeId: { type: String, default: null },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number, default: 11111 },
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: {type: String},
designation: { type: String, default: null },
reportingManager: { type: String, default: null },
departmentName: { type: String, default: null },
zone: { type: String, default: null },
7 months ago
services: { password: { bcrypt: String } },
description: { type: String, default: null },
startingPrice: { type: String, default: 0.0 },
profile: {
role: [{ type: String, default: "store" }],
firstName: { type: String, default: null },
lastName: { type: String, default: null },
contactNumber: { type: String, default: null },
alternativeContactNumber: { type: String, default: null },
store_address: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },
state: { type: String, default: null },
country: { type: String, default: null },
zip: { type: String, default: null },
},
status: {
type: String,
enum: ['inactive', 'active'],
default: 'active'
},
longitude: { type: Number, default: 0.0 },
latitude: { type: Number, default: 0.0 },
isActive: Boolean,
tenantId: ObjectId,
fcmId: { type: String, default: null },
createdAt: {
type: Date,
default: function () {
return Date.now();
},
},
createdBy: ObjectId,
updatedAt: {
type: Date,
default: function () {
return Date.now();
},
},
updatedBy: ObjectId,
}, { versionKey: false });
const waterLeverSensorInSchema = new mongoose.Schema({
storeId:{ type: String },
hardwareId: { type: String },
masterId: { type: String, default: null },
type: { type: String },
indate: { type: String },
hardwareId_company: { type: String },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback:{ type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId:{ type: String,default:"0" },
comments:{ type: String,default:"0" },
slaves: {
source: { type: String },
tankhardware: [
{
tankhardwareId: { type: String },
slaveId: { type: String, default: null },
type: { type: String },
indate: { type: String },
hardwareId_company: { type: String },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback:{ type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId:{ type: String,default:"0" },
comments:{ type: String,default:"0" },
}
]
}
});
const motorSwitchSensorInSchema = new mongoose.Schema({
storeId:{ type: String },
motorId: { type: String },
masterId: { type: String, default: null },
type: { type: String },
indate: { type: String },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback:{ type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId:{ type: String,default:"0" },
comments:{ type: String,default:"0" },
});
const insensorsSchema = new mongoose.Schema({
storeId: { type: String },
hardwareId: { type: String, default: null },
masterId: { type: String, default: null },
type: { type: String },
model: { type: String },
indate: { type: String },
hardwareId_company: { type: String, default: null },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback: { type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId: { type: String, default: "0" },
comments: { type: String, default: "0" },
quantity: { type: Number, default: 0 },
batchno: { type: String, default: null },
sensor_type: { type: String }, // adding sensor_type field
8 months ago
status: { type: String, default: "pending" },
connected_to: { type: String, default: "0" },
tankName: { type: String, default: "0" },
tankLocation: { type: String, default: "0" },
connected_slave: { type: String, default: null },
3 months ago
connected_status: { type: String, enum: ["connected", "disconnected", "Not connected", "unknown"], default: "unknown" },
masterName: { type: String, default: null },
location: { type: String, default: null },
tankhardwareId: { type: String, default: null },
4 months ago
support_issue_status: {
type: String,
enum: ['active', 'inactive'],
default: 'inactive'
},
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 },
},
],
connected_gsm_time: { type: String, default: null },
connected_gsm_date: { type: String, default: null },
connected_lora_date: { type: String, default: null },
connected_lora_time: { type: String, default: null },
typeOfWater:{ type: String, default: null },
gsm_last_check_time : { type: String, default: null },
support_gsm_last_check_time : { type: String, default: null },
support_lora_last_check_time : { type: String, default: null },
team_member_support_gsm_last_check_time : { type: String, default: null },
team_member_support_lora_last_check_time : { type: String, default: null },
lora_last_check_time : { type: String, default: null },
5 months ago
gsm_last_disconnect_time : { type: String, default: null },
outDoor_status: {
type: String,
3 months ago
enum: ['inprogress', 'inprogress at store','ready to pick up', 'dispatched'],
default: 'inprogress' // optional: set default
},
5 months ago
lora_last_disconnect_time : { type: String, default: null },
hardwareList: {
type: [
{
name: { type: String, required: true },
value: { type: Number, required: true }
}
],
default: []
},
quality_check_details: [{
damage_check: { result: String },
stickering_check: { result: String },
power_check: { result: String },
master_connecting_gsm: { result: String },
slave_connecting: { result: String },
5 months ago
motor_start: { result: String },
motor_stop: { result: String },
motor_starting: {
result: String,
steps: [
{ step: Number, result: String }
]
},
connecting_to_sensor: { result: String },
connecting_to_slave: { result: String },
data_sending: { result: String },
connected_slave_count: {type : String},
lastTicketRaisedAt: { type: String },
// hardwareList: {
// type: Map,
// of: Number,
// default: {}
// },
distance_check: {
result: String,
steps: [
{ step: Number, result: String }
]
}
}]
});
8 months ago
const iotpriceSchema = new mongoose.Schema({
name: { type: String },
type: { type: String ,default:null},
cost: { type: Number, default: null },
});
const estimationorderSchema = new mongoose.Schema({
orderId: { type: String, unique: true, required: true },
customerId: { type: String, required: true },
items: { type: Array, required: true },
estimatedTotal: { type: String, required: true },
status: { type: String, default: "pending" },
}, { timestamps: true });
const sensorquotationSchema = new mongoose.Schema({
1 year ago
customerId: { type: String },
surveyId: { type: String, default: null },
storeId: { type: String, default: null },
installationId: { type: String, default: null },
quatationId: { type: String, default: null },
masters: { type: String },
masters_quantity_price: { type: String },
masters_total_price: { type: String },
slaves: { type: String },
sensors: { type: String },
slaves_quantity_price: { type: String },
slaves_total_price: { type: String },
motor_switches: { type: String },
motor_switches_quantity_price: { type: String },
motor_switches_total_price: { type: String },
quote_status: { type: String, default: null },
quoted_amount: { type: String, default: null },
comments: { type: String, default: null },
datetime: { type: String, default: null },
9 months ago
updated_at: { type: String, default: null },
master_connections: [
{
master_name: { type: String, default: null },
slaves: { type: String, default: null },
6 months ago
location: { type: String, default: null },
googleLocation: { type: String, default: null },
longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0},
tanks: [
{
tankName: { type: String, default: null },
tankLocation: { type: String, default: null },
},
],
5 months ago
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 },
},
],
},
],
electricals: [
{
type: { type: String, default: null },
wire: { type: String, default: null },
switch: { type: String, default: null },
text: { type: String, default: null },
available_quantity: { type: String, default: null },
},
],
master_type_quantity_price: { type: String, default: null },
master_available_quantity: { type: String, default: null },
slave_available_quantity: { type: String, default: null },
sensor_available_quantity: { type: String, default: null },
master_type_total_price: { type: String, default: null },
sensor_type_quantity_price: { type: String , default: null},
sensor_type_total_price: { type: String , default: null},
switch_type_quantity_price: { type: String, default: null },
switch_type_total_price: { type: String, default: null },
qutation_total_price: { type: String, default: null },
});
const orderSchema = new mongoose.Schema({
customerId: { type: String },
surveyId: { type: String, default: null },
storeId: { type: String, default: null },
installationId: { type: String, default: null },
quatationId: { type: String, default: null },
masters: { type: String },
masters_quantity_price: { type: String },
masters_total_price: { type: String },
slaves: { type: String },
sensors: { type: String },
slaves_quantity_price: { type: String },
slaves_total_price: { type: String },
motor_switches: { type: String },
motor_switches_quantity_price: { type: String },
motor_switches_total_price: { type: String },
quote_status: { type: String, default: null },
quoted_amount: { type: String, default: null },
comments: { type: String, default: null },
datetime: { type: String, default: null },
updated_at: { type: String, default: null },
assignedTeamMembers: [{ type: String }],
5 months ago
tankhardwareId: [{ type: String,default: null }],
master_connections: [
{
master_name: { type: String, default: null },
5 months ago
hardwareId: { type: String, default: null },
slaves: { type: String, default: null },
location: { type: String, default: null },
googleLocation: { type: String, default: null },
longitude: { type : Number,default: 0.0},
latitude: {type: Number,default: 0.0},
tanks: [
{
tankName: { type: String, default: null },
tankLocation: { type: String, default: null },
},
],
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 },
},
],
},
],
electricals: [
{
type: { type: String, default: null },
wire: { type: String, default: null },
switch: { type: String, default: null },
text: { type: String, default: null },
available_quantity: { type: String, default: null },
},
],
master_type_quantity_price: { type: String, default: null },
master_available_quantity: { type: String, default: null },
slave_available_quantity: { type: String, default: null },
sensor_available_quantity: { type: String, default: null },
master_type_total_price: { type: String, default: null },
sensor_type_quantity_price: { type: String, default: null },
sensor_type_total_price: { type: String, default: null },
switch_type_quantity_price: { type: String, default: null },
switch_type_total_price: { type: String, default: null },
qutation_total_price: { type: String, default: null },
3 months ago
type: { type: String, default: null },
status: { type: String, default: "pending" },
quatation_status: { type: String, default: "pending" },
});
const SensorStockSchema = new mongoose.Schema({
storeId: {
type: String,
required: true,
ref: "Store",
},
type: {
type: String,
required: true,
enum: ["master", "slave", "sensor"], // Ensures only valid types
},
total_count: {
type: Number,
required: true,
default: 0,
},
total_available: {
type: Number,
required: true,
default: 0,
},
total_count_before_qc: {
type: Number,
required: true,
default: 0,
},
total_blocked: {
type: Number,
required: true,
default: 0,
},
total_repair: {
type: Number,
required: true,
default: 0,
},
7 months ago
excess_needed: {
type: Number,
required: true,
default: 0,
},
total_installed: {
type: Number,
required: true,
default: 0,
},
}, { timestamps: true });
const hardwareCartSchema = new mongoose.Schema({
productId: { type: String},
productName: { type: String },
description: { type: String, default: null },
GST: { type: Number, min: 0 },
unitPrice: { type: Number, min: 0 },
quantity: { type: Number, min: 1 },
grandTotal: { type: Number, min: 0 },
totalAmount: { type: Number, min: 0 }, // Amount before GST
serialId: { type: String, default: null },
category: { type: String, enum: ['slaves', 'master', 'switches'], default: 'slaves' },
discount: { type: Number, default: 0, min: 0 },
}, {
timestamps: true,
});
const serviceCartSchema = new mongoose.Schema({
installationId: {type: String},
productId: { type: String},
productName: { type: String },
description: { type: String, default: null },
GST: { type: Number, min: 0 },
unitPrice: { type: Number, min: 0 },
quantity: { type: Number, min: 1 },
grandTotal: { type: Number, min: 0 },
totalAmount: { type: Number, min: 0 }, // Amount before GST
serialId: { type: String, default: null },
category: { type: String, enum: ['slaves', 'master', 'switches'], default: 'slaves' },
discount: { type: Number, default: 0, min: 0 },
}, {
timestamps: true,
});
const salesSchema = new mongoose.Schema({
username: { type: String },
phone: { type: String, unique: true, trim: true },
salesId: { type: String, default: null },
phoneVerified: { type: Boolean, default: false },
phoneVerificationCode: { type: Number, default: 11111 },
passwordResetCode: { type: Number, default: 11111 },
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: {type: String},
services: {
password: {
bcrypt: { type: String, required: true }
}
},
description: { type: String, default: null },
designation: { type: String, default: null },
reportingManager: { type: String, default: null },
departmentName: { type: String, default: null },
zone: { type: String, default: null },
profile: {
role: [{ type: String, default: "sales" }],
firstName: { type: String, default: null },
lastName: { type: String, default: null },
contactNumber: { type: String, default: null },
alternativeContactNumber: { type: String, default: null },
address1: { type: String, default: null },
address2: { type: String, default: null },
city: { type: String, default: null },
state: { type: String, default: null },
country: { type: String, default: null },
zip: { type: String, default: null },
},
status: {
type: String,
enum: ['inactive', 'active'],
default: 'active'
},
longitude: { type: Number, default: 0.0 },
latitude: { type: Number, default: 0.0 },
isActive: Boolean,
tenantId: ObjectId,
fcmId: { type: String, default: null },
createdAt: {
type: Date,
default: function () {
return Date.now();
},
},
createdBy: ObjectId,
updatedAt: {
type: Date,
default: function () {
return Date.now();
},
},
updatedBy: ObjectId,
}, { versionKey: false });
const masterSlaveDataSchema = new mongoose.Schema({
installationId: {type: String},
customerId: {type: String},
type: { type: String},
hardwareId: { type: String },
batchno: { type: String, default: null },
masterId: { type: String },
tankName: { type: String },
tankLocation: { type: String },
materialRecived: { type: String },
electricityWork: { type: String },
plumbingWork: { type: String },
electricityWorkPictures: [
{
url: { type: String },
uploadedAt: { type: Date, default: Date.now }
}
],
plumbingWorkPictures: [
{
url: { type: String },
uploadedAt: { type: Date, default: Date.now }
}
],
materialRecievedPictures: [
{
url: { type: String },
uploadedAt: { type: Date, default: Date.now }
}
],
loraCheck: { type: String },
}, {
timestamps: true,
});
const electrictyWorkPicturesSchema = new Schema({
installationId: {
type: String,
//required: true,
//unique: true
},
customerId: {
type: String,
//required: true
},
pictureUrl: [{
url: {
type: String,
},
}],
createdAt: {
type: Date,
default: Date.now
}
});
const plumbingWorkPicturesSchema = new Schema({
installationId: {
type: String,
//required: true,
//unique: true
},
customerId: {
type: String,
//required: true
},
pictureUrl: [{
url: {
type: String,
},
}],
createdAt: {
type: Date,
default: Date.now
}
});
const materialRecievedPicturesSchema = new Schema({
installationId: {
type: String,
//required: true,
//unique: true
},
customerId: {
type: String,
//required: true
},
pictureUrl: [{
url: {
type: String,
},
}],
createdAt: {
type: Date,
default: Date.now
}
});
const RepairorderSchema = new mongoose.Schema({
customerId: { type: String, required: true },
supportId: { type: String },
storeId: { type: String },
status: { type: String, default: "pending" },
packageId: { type: String,},
otp: { type: String, },
replacements: [
{
type: {
type: String,
enum: ["master", "slave", "sensor"],
required: true
},
oldHardwareId: { type: String, required: true },
newHardwareId: { type: String }
}
],
createdAt: { type: Date, default: Date.now }
});
const Repairorder = mongoose.model('Repairorder', RepairorderSchema);
8 months ago
const Iotprice = mongoose.model('Iotprice', iotpriceSchema);
const Insensors = mongoose.model('Insensors', insensorsSchema);
const MasterSlaveData = mongoose.model('MasterSlaveData', masterSlaveDataSchema);
const ElectrictyWorkPictures = mongoose.model('ElectrictyWorkPictures', electrictyWorkPicturesSchema);
const PlumbingWorkPictures = mongoose.model('PlumbingWorkPictures', plumbingWorkPicturesSchema);
const MaterialRecievedPictures = mongoose.model('MaterialRecievedPictures', materialRecievedPicturesSchema);
const Order = mongoose.model('Order', orderSchema);
const EstimationOrder = mongoose.model('EstimationOrder', estimationorderSchema);
const Store = mongoose.model("Store", storeSchema);
const WaterLeverSensor = mongoose.model('WaterLeverSensor', waterLeverSensorInSchema);
const ProfilePictureStore = mongoose.model('ProfilePictureStore', profilePictureStoreSchema);
const ProfilePictureInstall = mongoose.model('ProfilePictureInstall', profilePictureInstallSchema);
const MotorSwitchSensor = mongoose.model('MotorSwitchSensor', motorSwitchSensorInSchema);
const SensorQuotation = mongoose.model('SensorQuotationSchema', sensorquotationSchema);
const SensorStock = mongoose.model("SensorStock", SensorStockSchema);
const Install = mongoose.model("Install", installationschema);
const Survey = mongoose.model("Survey", surveyschema);
5 months ago
const Support = mongoose.model("Support", supportschema);
const HardwareCart = mongoose.model("HardwareCart", hardwareCartSchema);
const ServiceCart = mongoose.model("ServiceCart", serviceCartSchema);
const Sales = mongoose.model("Sales", salesSchema);
7 months ago
module.exports = {Repairorder,Support,MaterialRecievedPictures,PlumbingWorkPictures,ElectrictyWorkPictures,MasterSlaveData,SensorStock,Order,EstimationOrder,Iotprice,Sales, Install,Survey, ProfilePictureInstall, SensorQuotation,generateinstallationId,Store,ProfilePictureStore,WaterLeverSensor,MotorSwitchSensor,Insensors,generatequatationId, HardwareCart, ServiceCart};