payservedb 8.4.9 → 8.5.1

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
@@ -94,6 +94,7 @@ const models = {
94
94
  LevyType: require("./src/models/levytype"),
95
95
  LevyContract: require("./src/models/levycontract"),
96
96
  Invoice: require("./src/models/invoice"),
97
+ InvoiceGeneration: require("./src/models/invoice_generation_approval"),
97
98
  ShortUrl: require("./src/models/short_urls"),
98
99
  InvoicingSchedule: require("./src/models/invoicing_schedule"),
99
100
  Reminder: require("./src/models/reminder"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "8.4.9",
3
+ "version": "8.5.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,87 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const invoiceGenerationSchema = new mongoose.Schema(
4
+ {
5
+ invoiceType: {
6
+ type: String,
7
+ enum: ['levy', 'lease'],
8
+ required: true
9
+ },
10
+ facility: {
11
+ id: {
12
+ type: mongoose.Schema.Types.ObjectId,
13
+ ref: "Facility",
14
+ required: true
15
+ },
16
+ name: {
17
+ type: String,
18
+ required: true,
19
+ trim: true
20
+ }
21
+ },
22
+ yearMonth: {
23
+ type: String,
24
+ required: true,
25
+ trim: true
26
+ },
27
+ generationDate: {
28
+ type: Date,
29
+ required: true,
30
+ default: Date.now
31
+ },
32
+ approvalStatus: {
33
+ type: String,
34
+ enum: ['Pending', 'Approved', 'Rejected'],
35
+ default: 'Pending'
36
+ },
37
+ approvedBy: {
38
+ userId: mongoose.Schema.Types.ObjectId,
39
+ name: String,
40
+ approvalDate: Date,
41
+ comments: String
42
+ },
43
+ rejectedBy: {
44
+ userId: mongoose.Schema.Types.ObjectId,
45
+ name: String,
46
+ rejectionDate: Date,
47
+ reason: String
48
+ },
49
+ metadata: {
50
+ createdBy: {
51
+ type: mongoose.Schema.Types.ObjectId
52
+ },
53
+ source: {
54
+ type: String,
55
+ enum: ['manual', 'api', 'import', 'mobile'],
56
+ default: 'manual'
57
+ },
58
+ deviceInfo: {
59
+ deviceId: String,
60
+ deviceType: String,
61
+ ipAddress: String
62
+ }
63
+ }
64
+ },
65
+ {
66
+ timestamps: true
67
+ }
68
+ );
69
+
70
+ // Static methods
71
+ invoiceGenerationSchema.statics.findPendingGenerations = function (facilityId) {
72
+ return this.find({
73
+ 'facility.id': facilityId,
74
+ 'approvalStatus': 'Pending'
75
+ }).sort({ generationDate: -1 });
76
+ };
77
+
78
+ invoiceGenerationSchema.statics.findByType = function (invoiceType, facilityId) {
79
+ return this.find({
80
+ 'facility.id': facilityId,
81
+ 'invoiceType': invoiceType
82
+ }).sort({ generationDate: -1 });
83
+ };
84
+
85
+ const InvoiceGeneration = mongoose.model('InvoiceGeneration', invoiceGenerationSchema);
86
+
87
+ module.exports = InvoiceGeneration;