payservedb 2.3.8 → 2.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -1
- package/package.json +1 -1
- package/src/models/invoice.js +77 -0
- package/src/models/levy.js +49 -7
- package/src/models/levycontract.js +59 -0
- package/src/models/levytype.js +23 -0
- package/src/models/notification.js +24 -0
- package/src/models/penalty.js +10 -19
- package/src/models/reminder.js +33 -0
package/index.js
CHANGED
|
@@ -69,7 +69,13 @@ const models = {
|
|
|
69
69
|
Visitor: require('./src/models/visitor'),
|
|
70
70
|
VisitLog: require('./src/models/visitLog'),
|
|
71
71
|
Settings: require('./src/models/settings'),
|
|
72
|
-
Levy:require('./src/models/levy')
|
|
72
|
+
Levy:require('./src/models/levy'),
|
|
73
|
+
LevyType:require('./src/models/levytype'),
|
|
74
|
+
LevyContract:require('./src/models/levycontract'),
|
|
75
|
+
Invoice:require('./src/models/invoice'),
|
|
76
|
+
Reminder:require('./src/models/reminder'),
|
|
77
|
+
Penalty:require('./src/models/penalty'),
|
|
78
|
+
Notifiaction:require('./src/models/notification')
|
|
73
79
|
};
|
|
74
80
|
|
|
75
81
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Invoice
|
|
4
|
+
const invoiceSchema = new mongoose.Schema({
|
|
5
|
+
invoiceNumber: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true
|
|
9
|
+
},
|
|
10
|
+
client: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Customer',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
facility: {
|
|
16
|
+
id: { type: mongoose.Schema.Types.ObjectId, ref: 'Facility', required: true },
|
|
17
|
+
name: { type: String, required: true }
|
|
18
|
+
},
|
|
19
|
+
unit: {
|
|
20
|
+
id: { type: mongoose.Schema.Types.ObjectId, ref: 'Unit', required: true },
|
|
21
|
+
name: { type: String, required: true }
|
|
22
|
+
},
|
|
23
|
+
items: [{
|
|
24
|
+
description: { type: String, required: true },
|
|
25
|
+
quantity: { type: Number, required: true, min: 1 },
|
|
26
|
+
unitPrice: { type: Number, required: true, min: 0 }
|
|
27
|
+
}],
|
|
28
|
+
subTotal: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
tax: {
|
|
33
|
+
type: Number,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
totalAmount: {
|
|
37
|
+
type: Number,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
issueDate: {
|
|
41
|
+
type: Date,
|
|
42
|
+
required: true
|
|
43
|
+
},
|
|
44
|
+
dueDate: {
|
|
45
|
+
type: Date,
|
|
46
|
+
required: true
|
|
47
|
+
},
|
|
48
|
+
status: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: true,
|
|
51
|
+
enum: ['Pending', 'Paid', 'Overdue']
|
|
52
|
+
},
|
|
53
|
+
penalty: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 0
|
|
56
|
+
},
|
|
57
|
+
whatFor: {
|
|
58
|
+
invoiceType: { type: String, required: true },
|
|
59
|
+
description: { type: String }
|
|
60
|
+
},
|
|
61
|
+
invoiceNote: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: null
|
|
64
|
+
},
|
|
65
|
+
paymentDetails: {
|
|
66
|
+
paymentStatus: { type: String, required: true },
|
|
67
|
+
paymentMethod: { type: String },
|
|
68
|
+
paymentDate: { type: Date },
|
|
69
|
+
transactionId: { type: String }
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
timestamps: true
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const Invoice = mongoose.model('Invoice', invoiceSchema);
|
|
76
|
+
|
|
77
|
+
module.exports = Invoice;
|
package/src/models/levy.js
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
// Define the schema for Levy
|
|
4
|
+
const levySchema = new mongoose.Schema({
|
|
5
|
+
levyName: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
trim: true,
|
|
9
|
+
minlength: [1, 'Levy name must be at least 1 character long']
|
|
10
|
+
},
|
|
11
|
+
levyType: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'LevyType',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
amount: {
|
|
17
|
+
type: Number,
|
|
18
|
+
required: true,
|
|
19
|
+
min: [0, 'Amount must be a positive number']
|
|
20
|
+
},
|
|
21
|
+
dueDate: {
|
|
22
|
+
type: Date,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
levyApplicant: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
trim: true
|
|
29
|
+
},
|
|
30
|
+
collectionFrequency: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
trim: true
|
|
34
|
+
},
|
|
35
|
+
invoiceDate: {
|
|
36
|
+
type: Date,
|
|
37
|
+
required: true
|
|
38
|
+
},
|
|
39
|
+
facilityId: {
|
|
40
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
41
|
+
ref: 'Facility',
|
|
42
|
+
required: true
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
timestamps: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Compile the model from the schema
|
|
8
49
|
const Levy = mongoose.model('Levy', levySchema);
|
|
9
|
-
|
|
50
|
+
|
|
51
|
+
module.exports = Levy;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for LevyContract
|
|
4
|
+
const levyContractSchema = new mongoose.Schema({
|
|
5
|
+
contractName: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
trim: true
|
|
9
|
+
},
|
|
10
|
+
levyId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Levy',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
customerId: {
|
|
16
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
+
ref: 'Customer',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
unitId: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: 'Unit',
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
amount: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: true,
|
|
28
|
+
min: [0, 'Amount must be a positive number']
|
|
29
|
+
},
|
|
30
|
+
startDate: {
|
|
31
|
+
type: Date,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
endDate: {
|
|
35
|
+
type: Date,
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: true,
|
|
41
|
+
enum: ['Active', 'Inactive']
|
|
42
|
+
},
|
|
43
|
+
paymentFrequency: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: true,
|
|
46
|
+
trim: true
|
|
47
|
+
},
|
|
48
|
+
facilityId: {
|
|
49
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
+
ref: 'Facility',
|
|
51
|
+
required: true
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
timestamps: true
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const LevyContract = mongoose.model('LevyContract', levyContractSchema);
|
|
58
|
+
|
|
59
|
+
module.exports = LevyContract;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for LevyType
|
|
4
|
+
const levyTypeSchema = new mongoose.Schema({
|
|
5
|
+
name: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
trim: true,
|
|
9
|
+
minlength: [1, 'Levy type name must be at least 1 character long']
|
|
10
|
+
},
|
|
11
|
+
facilityId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'Facility',
|
|
14
|
+
required: [true, 'Facility ID is required']
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Compile the model from the schema
|
|
21
|
+
const LevyType = mongoose.model('LevyType', levyTypeSchema);
|
|
22
|
+
|
|
23
|
+
module.exports = LevyType;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Notifications
|
|
4
|
+
const notificationSchema = new mongoose.Schema({
|
|
5
|
+
userId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'User',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
message: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
dateSent: {
|
|
15
|
+
type: Date,
|
|
16
|
+
required: true
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
timestamps: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const Notification = mongoose.model('Notification', notificationSchema);
|
|
23
|
+
|
|
24
|
+
module.exports = Notification;
|
package/src/models/penalty.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
-
// Define the schema for
|
|
3
|
+
// Define the schema for Penalty
|
|
4
4
|
const penaltySchema = new mongoose.Schema({
|
|
5
|
-
|
|
6
|
-
type: String,
|
|
7
|
-
required: true
|
|
8
|
-
},
|
|
9
|
-
module: {
|
|
5
|
+
name: {
|
|
10
6
|
type: String,
|
|
11
7
|
required: true
|
|
12
8
|
},
|
|
@@ -19,33 +15,28 @@ const penaltySchema = new mongoose.Schema({
|
|
|
19
15
|
required: true
|
|
20
16
|
},
|
|
21
17
|
percentage: {
|
|
22
|
-
type:
|
|
23
|
-
required: true
|
|
18
|
+
type: Number,
|
|
19
|
+
required: true,
|
|
20
|
+
min: [0, 'Percentage must be at least 0']
|
|
24
21
|
},
|
|
25
22
|
amount: {
|
|
26
23
|
type: Number,
|
|
27
|
-
required: true
|
|
24
|
+
required: true,
|
|
25
|
+
min: [0, 'Amount must be a positive number']
|
|
28
26
|
},
|
|
29
27
|
isActive: {
|
|
30
28
|
type: Boolean,
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
disabled:{
|
|
34
|
-
type:Boolean,
|
|
35
|
-
required:true
|
|
29
|
+
default: true
|
|
36
30
|
},
|
|
37
31
|
facilityId: {
|
|
38
32
|
type: mongoose.Schema.Types.ObjectId,
|
|
39
33
|
ref: 'Facility',
|
|
34
|
+
required: true
|
|
40
35
|
}
|
|
41
36
|
}, {
|
|
42
|
-
timestamps: true
|
|
37
|
+
timestamps: true
|
|
43
38
|
});
|
|
44
39
|
|
|
45
|
-
// Indexes for improved performance
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Compile the model from the schema
|
|
49
40
|
const Penalty = mongoose.model('Penalty', penaltySchema);
|
|
50
41
|
|
|
51
42
|
module.exports = Penalty;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Reminder
|
|
4
|
+
const reminderSchema = new mongoose.Schema({
|
|
5
|
+
name: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
trim: true
|
|
9
|
+
},
|
|
10
|
+
type: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
time: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
day: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
facilityId: {
|
|
23
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
24
|
+
ref: 'Facility',
|
|
25
|
+
required: true
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
timestamps: true
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const Reminder = mongoose.model('Reminder', reminderSchema);
|
|
32
|
+
|
|
33
|
+
module.exports = Reminder;
|