reinitializing codebase and resuming development

This commit is contained in:
Shibi Chakkaravarthy
2026-09-27 00:48:18 +05:30
parent 5e894627f5
commit be7211ac28
23 changed files with 744 additions and 45 deletions
+2 -2
View File
@@ -38,11 +38,11 @@ const schema = new Schema({
},
city: {
type: String,
required: true,
required: false,
},
state: {
type: String,
required: true,
required: false,
},
});
+42
View File
@@ -0,0 +1,42 @@
import { model, Schema, Types } from "mongoose";
const schema = new Schema({
entity: {
type: Types.ObjectId,
required: true,
},
type: {
type: String,
required: true,
enum: ["user", "partner", "vendor", "expense"],
},
createdBy: {
type: Types.ObjectId,
ref: "user",
required: true,
},
approvedBy: {
type: Types.ObjectId,
ref: "user",
required: false,
},
createdOn: {
type: Date,
required: true,
},
approvedOn: {
type: Date,
required: false,
},
isAutoApproved: {
type: Boolean,
required: true,
},
isApproved: {
type: Boolean,
required: true,
default: false,
},
});
export default model("approval", schema);
+31
View File
@@ -0,0 +1,31 @@
import Model from "./model.js";
// Create
export const createApproval = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getApprovalById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
export const getApprovalByQuery = async (query) => {
return await Model.findOne(query);
}
// Read (Get all)
export const getAllApprovals = async () => {
return await Model.find();
};
// Update
export const updateApproval = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateApproval = async (pipeline) => {
return await Model.aggregate(pipeline);
};
+74
View File
@@ -0,0 +1,74 @@
import { model, Schema, Types } from "mongoose";
const itemSchema = new Schema({
product: {
type: Types.ObjectId,
required: true,
ref: "product",
},
quantity: {
type: Number,
required: true,
},
finalRate: {
type: Number,
required: true,
},
});
const remarksSchema = new Schema({
createdOn: {
type: Date,
required: true,
},
createdBy: {
type: Types.ObjectId,
required: true,
ref: "user",
},
remarks: {
type: String,
required: true,
},
type: {
type: String,
required: true,
enum: ["REJECTION REASON", "CANCELLATION REASON", "OTHER"],
},
});
const schema = new Schema({
createdBy: {
type: Types.ObjectId,
required: true,
ref: "user",
},
createdOn: {
type: Date,
required: true,
},
items: {
type: [itemSchema],
required: true,
},
totalValue: {
type: Number,
required: true,
},
status: {
type: String,
required: true,
default: "CREATED",
enum: ["CREATED", "CONFIRMED", "REJECTED", "CANCELLED", "COMPLETED"],
},
shippingAddress: {
type: String,
required: true,
},
remarks: {
type: [remarksSchema],
default: [],
},
});
export default model("enquiry", schema);
+31
View File
@@ -0,0 +1,31 @@
import Model from "./model.js";
// Create
export const createEnquiry = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getEnquiryById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
export const getEnquiryByQuery = async (query) => {
return await Model.findOne(query);
};
// Read (Get all)
export const getAllEnquiries = async (query) => {
return await Model.find(query);
};
// Update
export const updateEnquiry = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateEnquiry = async (pipeline) => {
return await Model.aggregate(pipeline);
};
+4
View File
@@ -16,6 +16,10 @@ const geofenceSchema = new Schema({
type: String,
required: false,
},
visit: {
type: Types.ObjectId,
ref: "visit",
},
});
const schema = new Schema({
+8
View File
@@ -76,6 +76,14 @@ const schema = new Schema({
type: [contactPersonSchema],
required: true,
},
isApproved: {
type: Boolean,
default: false,
},
isTemp: {
type: Boolean,
default: true,
},
});
export default model("partner", schema);
+2 -1
View File
@@ -27,12 +27,13 @@ const schema = new Schema({
},
createdBy: {
type: Types.ObjectId,
required: true,
required: false,
ref: "user",
},
isActive: {
type: Boolean,
required: true,
default: true
},
});
+25
View File
@@ -0,0 +1,25 @@
import { model, Schema, Types } from "mongoose";
const schema = new Schema({
createdOn: {
type: Date,
required: true,
},
user: {
type: Types.ObjectId,
required: true,
ref: "user",
},
venue: {
type: Types.ObjectId,
required: true,
ref: "venue",
},
assignment: {
type: Types.ObjectId,
required: true,
ref: "assignment",
},
});
export default model("visit", schema);
+31
View File
@@ -0,0 +1,31 @@
import Model from "./model.js";
// Create
export const createVisit = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getVisitById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
export const getVisitByQuery = async (query) => {
return await Model.findOne(query);
}
// Read (Get all)
export const getAllVisits = async () => {
return await Model.find();
};
// Update
export const updateVisit = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateVisit = async (pipeline) => {
return await Model.aggregate(pipeline);
};
-1
View File
@@ -9,7 +9,6 @@ export { default as Salary } from "./Salary/model";
export { default as Vendor } from "./Vendor/model";
export { default as Expense } from "./Expense/model";
export { default as Product } from "./Product/model";
export { default as Invoice } from "./Invoice/model";
export { default as Partner } from "./Partner/model";
export { default as Activity } from "./Activity/model";
export { default as Location } from "./Location/model";