payservedb 5.6.0 → 5.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -37,7 +37,14 @@ const levySchema = new mongoose.Schema(
37
37
  type: String,
38
38
  required: true,
39
39
  },
40
- // New fields added from levy contract
40
+ // New billing type field
41
+ billingType: {
42
+ type: String,
43
+ enum: ['Prepaid', 'Postpaid'],
44
+ required: true,
45
+ default: 'Postpaid'
46
+ },
47
+ // Fields from levy contract
41
48
  currency: {
42
49
  type: mongoose.Schema.Types.ObjectId,
43
50
  ref: "Currency",
@@ -52,6 +59,67 @@ const levySchema = new mongoose.Schema(
52
59
  type: mongoose.Schema.Types.ObjectId,
53
60
  required: false,
54
61
  },
62
+ // New bank payment field
63
+ bankPayment: {
64
+ type: Boolean,
65
+ default: false,
66
+ required: false,
67
+ },
68
+ // Bank details for bank payment
69
+ bankDetails: {
70
+ bankName: {
71
+ type: String,
72
+ required: false,
73
+ trim: true,
74
+ },
75
+ accountName: {
76
+ type: String,
77
+ required: false,
78
+ trim: true,
79
+ },
80
+ accountNumber: {
81
+ type: String,
82
+ required: false,
83
+ trim: true,
84
+ },
85
+ branch: {
86
+ type: String,
87
+ required: false,
88
+ trim: true,
89
+ },
90
+ swiftCode: {
91
+ type: String,
92
+ required: false,
93
+ trim: true,
94
+ }
95
+ },
96
+ // GL Account Configuration (moved from levy contract)
97
+ glAccounts: {
98
+ invoice: {
99
+ debit: {
100
+ type: mongoose.Schema.Types.ObjectId,
101
+ ref: "GLAccount",
102
+ required: false,
103
+ },
104
+ credit: {
105
+ type: mongoose.Schema.Types.ObjectId,
106
+ ref: "GLAccount",
107
+ required: false,
108
+ }
109
+ },
110
+ payment: {
111
+ debit: {
112
+ type: mongoose.Schema.Types.ObjectId,
113
+ ref: "GLAccount",
114
+ required: false,
115
+ },
116
+ credit: {
117
+ type: mongoose.Schema.Types.ObjectId,
118
+ ref: "GLAccount",
119
+ required: false,
120
+ }
121
+ }
122
+ },
55
123
  disabled: {
56
124
  type: Boolean,
57
125
  required: false,
@@ -41,17 +41,6 @@ const LevyContractSchema = new Schema(
41
41
  default: 'Active',
42
42
  required: [true, 'Status is required']
43
43
  },
44
- // Replace single doubleEntryAccount with two separate accounts
45
- invoiceDoubleEntryAccount: {
46
- type: mongoose.Schema.Types.ObjectId,
47
- ref: 'GLAccountDoubleEntries',
48
- required: [true, 'Invoice double entry account is required']
49
- },
50
- paymentDoubleEntryAccount: {
51
- type: mongoose.Schema.Types.ObjectId,
52
- ref: 'GLAccountDoubleEntries',
53
- required: [true, 'Payment double entry account is required']
54
- },
55
44
  balanceBroughtForward: {
56
45
  type: Number,
57
46
  default: 0
@@ -109,22 +98,6 @@ LevyContractSchema.virtual('unit', {
109
98
  justOne: true
110
99
  });
111
100
 
112
- // Virtual populate for invoice double entry account
113
- LevyContractSchema.virtual('invoiceDoubleEntry', {
114
- ref: 'GLAccountDoubleEntries',
115
- localField: 'invoiceDoubleEntryAccount',
116
- foreignField: '_id',
117
- justOne: true
118
- });
119
-
120
- // Virtual populate for payment double entry account
121
- LevyContractSchema.virtual('paymentDoubleEntry', {
122
- ref: 'GLAccountDoubleEntries',
123
- localField: 'paymentDoubleEntryAccount',
124
- foreignField: '_id',
125
- justOne: true
126
- });
127
-
128
101
  // Pre-save middleware to ensure endDate is after startDate
129
102
  LevyContractSchema.pre('save', function (next) {
130
103
  if (this.startDate && this.endDate && this.startDate >= this.endDate) {
@@ -134,24 +107,10 @@ LevyContractSchema.pre('save', function (next) {
134
107
  }
135
108
  });
136
109
 
137
- // Pre-save middleware to maintain backward compatibility during migration
138
- LevyContractSchema.pre('save', function (next) {
139
- // If we have the old doubleEntryAccount but not the new ones,
140
- // use the old one for both new fields during the transition
141
- if (this.doubleEntryAccount &&
142
- (!this.invoiceDoubleEntryAccount || !this.paymentDoubleEntryAccount)) {
143
- this.invoiceDoubleEntryAccount = this.doubleEntryAccount;
144
- this.paymentDoubleEntryAccount = this.doubleEntryAccount;
145
- }
146
- next();
147
- });
148
-
149
110
  // Index for efficient queries
150
111
  LevyContractSchema.index({ levyId: 1, unitId: 1, status: 1 });
151
112
  LevyContractSchema.index({ facilityId: 1 });
152
113
  LevyContractSchema.index({ customerId: 1 });
153
- LevyContractSchema.index({ invoiceDoubleEntryAccount: 1 });
154
- LevyContractSchema.index({ paymentDoubleEntryAccount: 1 });
155
114
 
156
115
  module.exports = {
157
116
  schema: LevyContractSchema,