payservedb 4.0.7 → 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 +1 -1
- package/src/models/cashpayment.js +186 -0
- package/src/models/user_account.js +5 -7
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -32,11 +32,9 @@ const userAccountSchema = new mongoose.Schema({
|
|
|
32
32
|
unique: true,
|
|
33
33
|
trim: true
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
type:
|
|
37
|
-
|
|
38
|
-
unique: true,
|
|
39
|
-
trim: true
|
|
35
|
+
unitId: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: 'Unit',
|
|
40
38
|
},
|
|
41
39
|
payment_type: {
|
|
42
40
|
type: String,
|
|
@@ -66,12 +64,12 @@ const userAccountSchema = new mongoose.Schema({
|
|
|
66
64
|
meter_id: {
|
|
67
65
|
type: mongoose.Schema.Types.ObjectId,
|
|
68
66
|
required: true,
|
|
69
|
-
refPath: 'meterModel'
|
|
67
|
+
refPath: 'meterModel'
|
|
70
68
|
},
|
|
71
69
|
meterModel: {
|
|
72
70
|
type: String,
|
|
73
71
|
required: true,
|
|
74
|
-
enum: ['Meter', 'AnalogMeter']
|
|
72
|
+
enum: ['Meter', 'AnalogMeter']
|
|
75
73
|
}
|
|
76
74
|
}, {
|
|
77
75
|
timestamps: true
|