payservedb 2.3.5 → 2.3.8

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 CHANGED
@@ -11,7 +11,7 @@ const source = '?authSource=admin'
11
11
  async function connectToMongoDB(dbName) {
12
12
  try {
13
13
 
14
- const connectionString = `mongodb://Ps:Letmein987@127.0.0.1:27017/${dbName}${source}`;
14
+ const connectionString = `mongodb://${url}/${dbName}${source}`;
15
15
  await mongoose.connect(connectionString, {
16
16
  useNewUrlParser: true,
17
17
  });
@@ -29,7 +29,7 @@ async function switchDB(dbName) {
29
29
  return connections[dbName]; // Return existing connection
30
30
  }
31
31
  try {
32
- const connectionString = `mongodb://Ps:Letmein987@127.0.0.1:27017/${dbName}${source}`;
32
+ const connectionString = `mongodb://${url}/${dbName}${source}`;
33
33
  const dbConnection = await mongoose.createConnection(connectionString, {
34
34
  useNewUrlParser: true,
35
35
  });
@@ -64,24 +64,12 @@ const models = {
64
64
  Message: require('./src/models/message'),
65
65
  SMSAfricastalking: require('./src/models/sms_africastalking'),
66
66
  SMSMeliora: require('./src/models/sms_meliora'),
67
- WaterConcentrator: require('./src/models/waterConcentrator'),
68
- WaterMeter: require('./src/models/waterMeter'),
69
- WaterMeterSettings: require('./src/models/waterMeterSetting'),
70
67
  EntryExit: require('./src/models/entry_exit'),
71
68
  Guard: require('./src/models/guard'),
72
69
  Visitor: require('./src/models/visitor'),
73
70
  VisitLog: require('./src/models/visitLog'),
74
71
  Settings: require('./src/models/settings'),
75
- Contract: require('./src/models/contract'),
76
- Levy: require('./src/models/levy'),
77
- LevyType: require('./src/models/levytype'),
78
- Invoice: require('./src/models/invoice'),
79
- Tax: require('./src/models/tax'),
80
- InvoiceBillingSetting: require('./src/models/invoiceBillingSetting'),
81
- Penalty: require('./src/models/penalty'),
82
- Reminder: require('./src/models/reminder'),
83
- BankDetails: require('./src/models/bankdetails'),
84
- John:require('./src/models/john')
72
+ Levy:require('./src/models/levy')
85
73
  };
86
74
 
87
75
  // Function to get models dynamically from a specific database connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "2.3.5",
3
+ "version": "2.3.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,49 +1,9 @@
1
-
2
1
  const mongoose = require('mongoose');
3
-
4
- const LevySchema = new mongoose.Schema({
5
- levyName: {
6
- type: String,
7
- required: [true, 'Levy name is required'],
8
- trim: true,
9
- },
10
- amount: {
11
- type: String,
12
- required: [true, 'amount is required'],
13
- },
14
- levyType: {
15
- type: mongoose.Schema.Types.ObjectId, // Update this to reference LevyType
16
- ref: 'LevyType',
17
- required: [true, 'Levy type is required'],
18
- },
19
- levyApplicant: {
20
- type: String,
21
- required: [true, 'Levy applicant is required'],
22
- trim: true,
23
- },
24
- collectionFrequency: {
25
- type: String,
26
- required: [true, 'Collection Frequency is required'],
27
- trim: true,
28
- enum: ['Monthly', 'Quarterly', 'Annually', 'Semi-annually', 'Weekly']
29
- },
30
- invoiceDate: {
31
- type: String,
32
- required: [true, 'Invoice Date is required'],
33
- trim: true,
34
- },
35
- disabled: {
36
- type: Boolean,
37
- default: false
38
- },
39
- facilityId: {
40
- type: mongoose.Schema.Types.ObjectId,
41
- ref: 'Facility',
42
- }
43
- }, {
44
- timestamps: true, // Automatically add createdAt and updatedAt fields
45
- });
46
-
47
- const Levy = mongoose.model('Levy', LevySchema);
48
-
49
- module.exports = Levy;
2
+ const levySchema = mongoose.Schema({
3
+ title:{
4
+ type:String,
5
+ required:true
6
+ }
7
+ })
8
+ const Levy = mongoose.model('Levy', levySchema);
9
+ module.exports = Levy
@@ -1,42 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const contractSchema = new mongoose.Schema({
4
- contractName: {
5
- type: String,
6
- required: true
7
- },
8
- contractStart: {
9
- type: String,
10
- required: true
11
- },
12
- contractEnd: {
13
- type: String,
14
- required: true
15
- },
16
- levy: {
17
- type: mongoose.Schema.Types.ObjectId,
18
- ref: 'Levy',
19
- required: [true, 'Levy is required'],
20
- },
21
- units:[],
22
- disabled: {
23
- type: Boolean,
24
- default: false
25
- },
26
- facilityId: {
27
- type: mongoose.Schema.Types.ObjectId,
28
- ref: 'Facility',
29
- required: true
30
- },
31
- },
32
- // { timestamps: true }
33
- );
34
-
35
- contractSchema.index({ contractName: 1 });
36
-
37
- const Contract = mongoose.model('Contract', contractSchema);
38
-
39
- module.exports = Contract;
40
-
41
-
42
-
@@ -1,105 +0,0 @@
1
- const mongoose = require('mongoose');
2
- const Schema = mongoose.Schema;
3
-
4
- const InvoiceSchema = new Schema({
5
- invoiceNumber: {
6
- type: String,
7
- required: true,
8
- unique: true,
9
- },
10
- client: {
11
- _id: {
12
- type: mongoose.Schema.Types.ObjectId,
13
- ref: 'Customer',
14
- },
15
- name: { type: String, required: true },
16
- email: { type: String, required: true },
17
- address: { type: String },
18
- },
19
- facility: {
20
- _id: {
21
- type: mongoose.Schema.Types.ObjectId,
22
- ref: 'Facility',
23
- },
24
- name: { type: String, required: true },
25
- imageURL: { type: String, required: true }
26
- },
27
- unit: {
28
- _id: {
29
- type: mongoose.Schema.Types.ObjectId,
30
- ref: 'Unit',
31
- },
32
- name: { type: String, required: true }
33
- },
34
- items: [
35
- {
36
- description: { type: String, required: true },
37
- quantity: { type: Number, required: true },
38
- unitPrice: { type: Number, required: true },
39
- }
40
- ],
41
- subTotal: {
42
- type: Number,
43
- required: true,
44
- default: 0,
45
- },
46
- tax: {
47
- type: Number,
48
- required: true,
49
- default: 0,
50
- },
51
- totalAmount: {
52
- type: Number,
53
- required: true,
54
- default: 0,
55
- },
56
- issueDate: {
57
- type: Date,
58
- required: true,
59
- default: Date.now,
60
- },
61
- dueDate: {
62
- type: Date,
63
- required: true,
64
- },
65
- status: {
66
- type: String,
67
- enum: ['Pending', 'Paid', 'Cancelled', 'Overdue', 'Partially Paid'],
68
- default: 'Pending',
69
- },
70
- penalty: {
71
- isApplied: { type: Boolean, default: false },
72
- penaltyAmount: { type: Number, default: 0 },
73
- penaltyDate: { type: Date },
74
- penaltyReason: { type: String },
75
- },
76
- whatFor: {
77
- invoiceType: { type: String, required: true },
78
- description: { type: String, required: true }
79
- },
80
- invoiceNote: {
81
- type: String,
82
- default: ''
83
- },
84
- paymentDetails: {
85
- paymentStatus: {
86
- type: String,
87
- enum: ['Pending', 'Completed', 'Failed'],
88
- default: 'Pending'
89
- },
90
- paymentMethod: {
91
- type: String,
92
- enum: ['Credit Card', 'Bank Transfer', 'PayPal', 'Cash'],
93
- },
94
- paymentDate: {
95
- type: Date,
96
- },
97
- transactionId: {
98
- type: String,
99
- default: ''
100
- }
101
- }
102
- });
103
-
104
- const Invoice = mongoose.model('Invoice', InvoiceSchema);
105
- module.exports = Invoice
@@ -1,29 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- // Define the schema for companies
4
- const InvoiceBillingSettingSchema = new mongoose.Schema({
5
- dueDays: {
6
- type: Number,
7
- required: true,
8
- min: 1 // Ensures dueDays is at least 1
9
- },
10
- levyNote: {
11
- type: String,
12
- required: true
13
- },
14
- facilityId: {
15
- type: mongoose.Schema.Types.ObjectId,
16
- ref: 'Facility',
17
- required: true // Consider making this required if every setting must be linked to a facility
18
- }
19
- }, {
20
- timestamps: true // Automatically add createdAt and updatedAt fields
21
- });
22
-
23
- // Indexes for improved performance
24
- InvoiceBillingSettingSchema.index({ facilityId: 1 }); // Index on facilityId
25
-
26
- // Compile the model from the schema
27
- const InvoiceBillingSetting = mongoose.model('InvoiceBillingSetting', InvoiceBillingSettingSchema);
28
-
29
- module.exports = InvoiceBillingSetting;
@@ -1,9 +0,0 @@
1
- const mongoose = require('mongoose');
2
- const johnSchema = mongoose.Schema({
3
- fullName:{
4
- type:String,
5
- required:true
6
- }
7
- })
8
- const John = mongoose.model('John',johnSchema);
9
- module.exports = John
@@ -1,19 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const LevyTypeSchema = new mongoose.Schema({
4
- levyType: {
5
- type: String,
6
- required: [true, 'Levy type is required'],
7
- trim: true,
8
- },
9
- facilityId: {
10
- type: mongoose.Schema.Types.ObjectId,
11
- ref: 'Facility',
12
- }
13
- }, {
14
- timestamps: true, // Automatically add createdAt and updatedAt fields
15
- });
16
-
17
- const LevyType = mongoose.model('LevyType', LevyTypeSchema);
18
-
19
- module.exports = LevyType;
@@ -1,47 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- // Define the schema for companies
4
- const reminderSchema = new mongoose.Schema({
5
- title: {
6
- type: String,
7
- required: true
8
- },
9
- module: {
10
- type: String,
11
- required: true
12
- },
13
- type: {
14
- type: String,
15
- required: true
16
- },
17
- time: {
18
- type: String,
19
- required: true
20
- },
21
- day: {
22
- type: Number,
23
- required: true
24
- },
25
- isActive: {
26
- type: Boolean,
27
- required: true
28
- },
29
- disabled:{
30
- type:Boolean,
31
- required:true
32
- },
33
- facilityId: {
34
- type: mongoose.Schema.Types.ObjectId,
35
- ref: 'Facility',
36
- }
37
- }, {
38
- timestamps: true // Automatically add createdAt and updatedAt fields
39
- });
40
-
41
- // Indexes for improved performance
42
-
43
-
44
- // Compile the model from the schema
45
- const Reminder = mongoose.model('Reminder', reminderSchema);
46
-
47
- module.exports = Reminder;
package/src/models/tax.js DELETED
@@ -1,35 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- // Define the schema for companies
4
- const taxSchema = new mongoose.Schema({
5
- type: {
6
- type: String,
7
- required: true
8
- },
9
- percentage: {
10
- type: Boolean,
11
- required: true
12
- },
13
- amount: {
14
- type: Number,
15
- required: true
16
- },
17
- disabled:{
18
- type:Boolean,
19
- required:true
20
- },
21
- facilityId: {
22
- type: mongoose.Schema.Types.ObjectId,
23
- ref: 'Facility',
24
- }
25
- }, {
26
- timestamps: true // Automatically add createdAt and updatedAt fields
27
- });
28
-
29
- // Indexes for improved performance
30
-
31
-
32
- // Compile the model from the schema
33
- const Tax = mongoose.model('Tax', taxSchema);
34
-
35
- module.exports = Tax;
@@ -1,50 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const waterConcentratorSchema = new mongoose.Schema({
4
- serialNumber: {
5
- type: String,
6
- required: true
7
- },
8
- manufacturer: {
9
- type: String,
10
- required: true
11
- },
12
- range: {
13
- type: Number,
14
- required: true
15
- },
16
- isInstalled: {
17
- type: Boolean,
18
- required: true
19
- },
20
- isFaulty: {
21
- type: Boolean,
22
- required: true
23
- },
24
- inStock: {
25
- type: Boolean,
26
- required: true
27
- },
28
- status: {
29
- type: String,
30
- required: true,
31
- enum: ['Offline', 'Online']
32
- },
33
- location: {
34
- lat: {
35
- type: Number,
36
- required: false
37
- },
38
- long: {
39
- type: Number,
40
- required: false
41
- }
42
- },
43
- facilityId: {
44
- type: [String], // Assuming facilityId is an array of strings
45
- required: true
46
- }
47
- });
48
-
49
- const WaterConcentrator = mongoose.model('WaterConcentrator', waterConcentratorSchema);
50
- module.exports = WaterConcentrator;
@@ -1,50 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const waterMeterSchema = new mongoose.Schema({
4
- serialNumber: {
5
- type: String,
6
- required: true
7
- },
8
- manufacturer: {
9
- type: String,
10
- required: true
11
- },
12
- size: {
13
- type: String,
14
- required: true
15
- },
16
- initialValue: {
17
- type: Number,
18
- required: true
19
- },
20
- isInstalled: {
21
- type: Boolean,
22
- required: true
23
- },
24
- isFaulty: {
25
- type: Boolean,
26
- required: true
27
- },
28
- inStock: {
29
- type: Boolean,
30
- required: true
31
- },
32
- valveStatus: {
33
- type: String,
34
- required: true,
35
- enum: ['Open', 'Closed']
36
- },
37
- location: {
38
- lat: {
39
- type: Number,
40
- required: false
41
- },
42
- long: {
43
- type: Number,
44
- required: false
45
- }
46
- },
47
- });
48
-
49
- const WaterMeter = mongoose.model('waterMeter', waterMeterSchema);
50
- module.exports = WaterMeter;
@@ -1,29 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const waterMeterSettingsSchema = mongoose.Schema({
4
- meterSettings: [
5
- {
6
- manufacturers: {
7
- type: [String],
8
- required: false
9
- },
10
- meterSizes: {
11
- type: [String],
12
- required: false
13
- },
14
- }
15
- ]
16
- });
17
-
18
- // Middleware to ensure only one record exists
19
- waterMeterSettingsSchema.pre('save', async function (next) {
20
- const existingSettings = await WaterMeterSettings.findOne();
21
- if (existingSettings && !existingSettings._id.equals(this._id)) {
22
- throw new Error('Only one water meter settings record is allowed.');
23
- }
24
- next();
25
- });
26
-
27
- const WaterMeterSettings = mongoose.model("WaterMeterSettings", waterMeterSettingsSchema);
28
-
29
- module.exports = WaterMeterSettings;