location controller updated with heading and created new models and controllers for remaining modules

This commit is contained in:
Shibi Chakkaravarthy
2026-05-04 20:57:03 +05:30
parent 1245e09111
commit 54d9508dc8
31 changed files with 2140 additions and 96 deletions
+30 -1
View File
@@ -1,5 +1,34 @@
import { model, Schema, Types } from "mongoose";
const schema = new Schema({});
const schema = new Schema({
createdOn: {
type: Date,
required: true,
},
createdBy: {
type: Types.ObjectId,
required: true,
ref: "user",
},
isActive: {
type: Boolean,
default: true,
},
user: {
type: Types.ObjectId,
required: true,
ref: "user",
},
venue: {
type: Types.ObjectId,
required: true,
ref: "venue",
},
targetedVisits: {
type: Number,
required: true,
default: 5,
},
});
export default model("assignment", schema);
+6 -1
View File
@@ -10,11 +10,16 @@ export const getAssignmentById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
// Read (Get One by Query)
export const getAssignmentByQuery = async (query) => {
return await Model.findOne(query);
}
// Read (Get All by Query)
export const getAssignmentsByQuery = async (query) => {
return await Model.find(query);
};
// Read (Get all)
export const getAllAssignments = async () => {
return await Model.find();
+104 -1
View File
@@ -1,5 +1,108 @@
import { model, Schema, Types } from "mongoose";
const schema = new Schema({});
const paymentHistorySchema = new Schema({
amount: {
type: Number,
required: true,
},
paymentDate: {
type: Date,
required: true,
},
paymentMethod: {
type: String,
required: true,
},
transactionId: {
type: String,
required: true,
},
createdOn: {
type: Date,
required: true,
},
createdBy: {
type: Types.ObjectId,
ref: "user",
required: true,
},
});
const itemSchema = new Schema({
id: {
type: Types.ObjectId,
required: true,
},
unitCostPrice: {
type: Number,
required: true,
},
unitSellingPrice: {
type: Number,
required: true,
},
qty: {
type: Number,
required: true,
},
taxPercent: {
type: Number,
required: true,
},
taxAmount: {
type: Number,
required: true,
},
discount: {
type: Number,
required: true,
},
total: {
type: Number,
required: true,
},
});
const schema = new Schema({
customer: {
type: Types.ObjectId,
ref: "partner",
required: true,
},
items: {
type: [itemSchema],
required: true,
},
netTotal: {
type: Number,
required: true,
},
total: {
type: Number,
required: true,
},
status: {
type: String,
enum: ["PENDING", "COMPLETED", "PARTIAL"],
default: "PENDING",
},
dueDate: {
type: Date,
required: true,
},
createdOn: {
type: Date,
required: true,
},
createdBy: {
type: Types.ObjectId,
ref: "user",
required: true,
},
paymentHistory: {
type: [paymentHistorySchema],
default: [],
},
});
export default model("invoice", schema);
+26 -3
View File
@@ -1,6 +1,18 @@
import { model, Schema, Types } from "mongoose";
import { locationSchema } from "../../helpers";
const geofenceSchema = new Schema({
venue: {
type: Types.ObjectId,
required: false,
ref: "venue",
},
action: {
type: String,
required: false,
},
});
const schema = new Schema({
user: {
type: Types.ObjectId,
@@ -16,10 +28,21 @@ const schema = new Schema({
type: Number,
required: true,
},
venue: {
type: Types.ObjectId,
event: {
type: String,
required: true,
},
activity: {
type: String,
required: false,
},
heading: {
type: Number,
required: false,
},
geofence: {
type: geofenceSchema,
required: false,
ref: "venue",
},
});
+4 -3
View File
@@ -17,12 +17,13 @@ export const getLocationById = async (id) => {
};
// Read (Get by Query)
export const getLocationByQuery = async (query) => {
return await Model.findOne(query).sort({ createdOn: -1 });
export const getLocationsByQuery = async (query) => {
console.log("QUERY", query);
return await Model.find(query).sort({ createdOn: -1 });
};
// Read (Get by Radius)
export const getLocationByRadius = async (radius) => {
export const getLocationsByRadius = async (radius) => {
return await Model.find(query);
};
+16 -2
View File
@@ -20,10 +20,17 @@ const contactPersonSchema = new Schema({
});
const schema = new Schema({
id: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
tags: {
type: [String],
},
createdBy: {
type: Types.ObjectId,
required: true,
@@ -37,7 +44,7 @@ const schema = new Schema({
type: String,
required: true,
},
mobile: {
phone: {
type: String,
required: true,
},
@@ -57,11 +64,18 @@ const schema = new Schema({
type: String,
required: true,
},
gst: {
type: String,
required: true,
},
isActive: {
type: Boolean,
default: true,
},
contactPersons: [contactPersonSchema],
contactPersons: {
type: [contactPersonSchema],
required: true,
},
});
export default model("partner", schema);
+6 -1
View File
@@ -13,7 +13,12 @@ export const getPartnerById = async (id) => {
// Read (Get by Query)
export const getPartnerByQuery = async (query) => {
return await Model.findOne(query);
}
};
// Read (Get all)
export const getPartnersByQuery = async (query) => {
return await Model.find(query);
};
// Read (Get all)
export const getAllPartners = async () => {
+1
View File
@@ -32,6 +32,7 @@ const schema = new Schema({
user: {
type: Types.ObjectId,
required: true,
ref: 'user'
},
});
+1 -1
View File
@@ -15,7 +15,7 @@ const schema = new Schema({
},
refreshToken: {
type: String,
required: true,
required: false,
},
isFirstTime: {
type: Boolean,
+23
View File
@@ -1,6 +1,25 @@
import { model, Schema, Types } from "mongoose";
import { locationSchema } from "../../helpers";
const contactPersonSchema = new Schema({
name: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
mobile: {
type: String,
required: true,
},
designation: {
type: String,
required: true,
},
});
const schema = new Schema({
name: {
type: String,
@@ -47,6 +66,10 @@ const schema = new Schema({
type: Types.ObjectId,
required: false,
},
contactPerson: {
type: contactPersonSchema,
required: false,
},
});
schema.index({ location: "2dsphere" });
+2 -2
View File
@@ -11,8 +11,8 @@ export const getVenueById = async (id) => {
};
// Read (Get by Query)
export const getVenueByQuery = async (query) => {
return await Model.findOne(query);
export const getVenuesByQuery = async (query) => {
return await Model.find(query);
};
// Read (Get all)