payservedb 4.0.8 → 4.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,186 @@
1
+ // File: models/CashPayment.js
2
+ const mongoose = require('mongoose');
3
+
4
+ // Define the schema for Cash Payments
5
+ const cashPaymentSchema = new mongoose.Schema({
6
+ // Payment reference details
7
+ paymentReference: {
8
+ type: String,
9
+ required: true,
10
+ unique: true,
11
+ trim: true
12
+ },
13
+ facilityId: {
14
+ type: mongoose.Schema.Types.ObjectId,
15
+ ref: 'Facility',
16
+ required: true
17
+ },
18
+ // Invoice details
19
+ invoice: {
20
+ invoiceId: {
21
+ type: mongoose.Schema.Types.ObjectId,
22
+ ref: 'Invoice',
23
+ required: true
24
+ },
25
+ invoiceNumber: {
26
+ type: String,
27
+ required: true,
28
+ trim: true
29
+ },
30
+ accountNumber: {
31
+ type: String,
32
+ required: true,
33
+ trim: true
34
+ },
35
+ totalAmount: {
36
+ type: Number,
37
+ required: true,
38
+ min: 0
39
+ }
40
+ },
41
+ // Client details
42
+ client: {
43
+ clientId: {
44
+ type: mongoose.Schema.Types.ObjectId,
45
+ ref: 'Customer',
46
+ required: true
47
+ },
48
+ firstName: {
49
+ type: String,
50
+ required: true
51
+ },
52
+ lastName: {
53
+ type: String,
54
+ required: true
55
+ }
56
+ },
57
+ // Payment details
58
+ paymentAmount: {
59
+ type: Number,
60
+ required: true,
61
+ min: 0
62
+ },
63
+ currency: {
64
+ id: {
65
+ type: mongoose.Schema.Types.ObjectId,
66
+ ref: 'Currency',
67
+ required: true
68
+ },
69
+ name: {
70
+ type: String,
71
+ required: true
72
+ },
73
+ code: {
74
+ type: String,
75
+ required: true,
76
+ uppercase: true,
77
+ minlength: 3,
78
+ maxlength: 3
79
+ }
80
+ },
81
+ paymentDate: {
82
+ type: Date,
83
+ required: true,
84
+ default: Date.now
85
+ },
86
+ receivedBy: {
87
+ type: mongoose.Schema.Types.ObjectId,
88
+ ref: 'User',
89
+ required: true
90
+ },
91
+ receiptNumber: {
92
+ type: String,
93
+ required: true,
94
+ unique: true
95
+ },
96
+ paymentMethod: {
97
+ type: String,
98
+ enum: ['Cash', 'Check', 'Bank Transfer'],
99
+ default: 'Cash'
100
+ },
101
+ paymentDetails: {
102
+ checkNumber: String,
103
+ bankName: String,
104
+ transferReference: String,
105
+ notes: String
106
+ },
107
+ // Reconciliation status
108
+ reconciliationStatus: {
109
+ type: String,
110
+ enum: ['Pending', 'Matched', 'Partial', 'Overpaid', 'Voided'],
111
+ default: 'Pending'
112
+ },
113
+ // Approval details
114
+ approvalStatus: {
115
+ type: String,
116
+ enum: ['Pending', 'Approved', 'Rejected'],
117
+ default: 'Pending'
118
+ },
119
+ approvedBy: {
120
+ userId: {
121
+ type: mongoose.Schema.Types.ObjectId,
122
+ ref: 'User'
123
+ },
124
+ name: String,
125
+ approvalDate: Date,
126
+ comments: String
127
+ },
128
+ // Reconciliation details
129
+ reconciliationDetails: {
130
+ appliedAmount: {
131
+ type: Number,
132
+ default: 0
133
+ },
134
+ overpayAmount: {
135
+ type: Number,
136
+ default: 0
137
+ },
138
+ reconciliationDate: Date,
139
+ reconciledBy: {
140
+ type: mongoose.Schema.Types.ObjectId,
141
+ ref: 'User'
142
+ }
143
+ },
144
+ // Exchange rate (for payments in different currencies)
145
+ exchangeRate: {
146
+ rate: {
147
+ type: Number,
148
+ default: 1
149
+ },
150
+ originalCurrency: {
151
+ code: String,
152
+ amount: Number
153
+ }
154
+ },
155
+ // Additional fields
156
+ isVoided: {
157
+ type: Boolean,
158
+ default: false
159
+ },
160
+ voidReason: {
161
+ type: String
162
+ },
163
+ voidedBy: {
164
+ type: mongoose.Schema.Types.ObjectId,
165
+ ref: 'User'
166
+ },
167
+ voidDate: Date,
168
+ attachments: [{
169
+ fileName: String,
170
+ fileUrl: String,
171
+ uploadDate: {
172
+ type: Date,
173
+ default: Date.now
174
+ },
175
+ uploadedBy: {
176
+ type: mongoose.Schema.Types.ObjectId,
177
+ ref: 'User'
178
+ }
179
+ }]
180
+ }, {
181
+ timestamps: true
182
+ });
183
+
184
+ const CashPayment = mongoose.model('CashPayment', cashPaymentSchema);
185
+
186
+ module.exports = CashPayment;