payservedb 8.4.8 → 8.5.0

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.8",
3
+ "version": "8.5.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -24,6 +24,10 @@ const communityGuidelinesSchema = new mongoose.Schema({
24
24
  ref: 'Facility',
25
25
  required: true,
26
26
  },
27
+ pdfFileName: {
28
+ type: String,
29
+ required: false,
30
+ },
27
31
  }, {
28
32
  timestamps: true,
29
33
  });
@@ -0,0 +1,88 @@
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
+ required: true
53
+ },
54
+ source: {
55
+ type: String,
56
+ enum: ['manual', 'api', 'import', 'mobile'],
57
+ default: 'manual'
58
+ },
59
+ deviceInfo: {
60
+ deviceId: String,
61
+ deviceType: String,
62
+ ipAddress: String
63
+ }
64
+ }
65
+ },
66
+ {
67
+ timestamps: true
68
+ }
69
+ );
70
+
71
+ // Static methods
72
+ invoiceGenerationSchema.statics.findPendingGenerations = function (facilityId) {
73
+ return this.find({
74
+ 'facility.id': facilityId,
75
+ 'approvalStatus': 'Pending'
76
+ }).sort({ generationDate: -1 });
77
+ };
78
+
79
+ invoiceGenerationSchema.statics.findByType = function (invoiceType, facilityId) {
80
+ return this.find({
81
+ 'facility.id': facilityId,
82
+ 'invoiceType': invoiceType
83
+ }).sort({ generationDate: -1 });
84
+ };
85
+
86
+ const InvoiceGeneration = mongoose.model('InvoiceGeneration', invoiceGenerationSchema);
87
+
88
+ module.exports = InvoiceGeneration;