payservedb 9.2.7 → 9.2.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/index.js CHANGED
@@ -144,6 +144,7 @@ const models = {
144
144
  ExpenseCategory: require("./src/models/expense_category"),
145
145
  InvoiceSettings: require("./src/models/levy_invoice_settings"),
146
146
  DepositSchema: require("./src/models/levy_deposits"),
147
+ ContractPaymentReceiptSchema: require("./src/models/levy_payment_receipt"),
147
148
  Account: require("./src/models/account"),
148
149
  FacilityPaymentDetails: require("./src/models/facility_payment_details"),
149
150
  DefaultPaymentDetails: require("./src/models/default_payment_details"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "9.2.7",
3
+ "version": "9.2.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -94,7 +94,7 @@ const cashPaymentSchema = new mongoose.Schema(
94
94
  },
95
95
  paymentMethod: {
96
96
  type: String,
97
- enum: ['cash', 'bank-transfer', 'cheque','mpesa', 'withholding-tax', 'landlord-wallet'],
97
+ enum: ['cash', 'bank-transfer', 'cheque','mpesa', 'withholding-tax'],
98
98
  default: 'cash'
99
99
  },
100
100
  exchangeRate: {
@@ -287,4 +287,4 @@ cashPaymentSchema.pre('save', function (next) {
287
287
  // Create model (only if not already defined by getModel utility)
288
288
  const CashPayment = mongoose.models.CashPayment || mongoose.model('CashPayment', cashPaymentSchema);
289
289
 
290
- module.exports = CashPayment;
290
+ module.exports = CashPayment;
@@ -0,0 +1,157 @@
1
+ const mongoose = require('mongoose');
2
+ const Schema = mongoose.Schema;
3
+
4
+ const ContractPaymentReceiptSchema = new Schema(
5
+ {
6
+ contractId: {
7
+ type: mongoose.Schema.Types.ObjectId,
8
+ ref: 'LevyContract',
9
+ required: [true, 'Contract ID is required']
10
+ },
11
+ customerId: {
12
+ type: mongoose.Schema.Types.ObjectId,
13
+ ref: 'Customer',
14
+ required: [true, 'Customer ID is required']
15
+ },
16
+ unitId: {
17
+ type: mongoose.Schema.Types.ObjectId,
18
+ ref: 'Unit',
19
+ required: [true, 'Unit ID is required']
20
+ },
21
+ facilityId: {
22
+ type: mongoose.Schema.Types.ObjectId,
23
+ ref: 'Facility',
24
+ required: [true, 'Facility ID is required']
25
+ },
26
+
27
+ receiptNumber: {
28
+ type: String,
29
+ required: [true, 'Receipt number is required'],
30
+ unique: true,
31
+ trim: true
32
+ },
33
+ paymentReference: {
34
+ type: String,
35
+ trim: true
36
+ },
37
+ datePaid: {
38
+ type: Date,
39
+ required: [true, 'Date paid is required']
40
+ },
41
+ paymentMethod: {
42
+ type: String,
43
+ trim: true
44
+ // e.g. 'mpesa', 'bank', 'cash' — not currently captured on the
45
+ // contract form, left optional until that's wired up
46
+ },
47
+
48
+ lineItems: [
49
+ {
50
+ lineType: {
51
+ type: String,
52
+ enum: ['Deposit', 'UpfrontPayment'],
53
+ required: true
54
+ },
55
+ description: {
56
+ type: String,
57
+ required: true
58
+ },
59
+ quantity: {
60
+ type: Number,
61
+ default: 1
62
+ },
63
+ unitAmount: {
64
+ type: Number,
65
+ required: true,
66
+ min: [0, 'Unit amount cannot be negative']
67
+ },
68
+ taxRate: {
69
+ type: Number,
70
+ default: 0
71
+ },
72
+ taxAmount: {
73
+ type: Number,
74
+ default: 0
75
+ },
76
+ lineTotal: {
77
+ type: Number,
78
+ required: true
79
+ },
80
+ depositId: {
81
+ type: mongoose.Schema.Types.ObjectId,
82
+ ref: 'Deposit'
83
+ }
84
+ }
85
+ ],
86
+
87
+ subTotal: {
88
+ type: Number,
89
+ required: true,
90
+ default: 0
91
+ },
92
+ taxTotal: {
93
+ type: Number,
94
+ required: true,
95
+ default: 0
96
+ },
97
+ totalCharges: {
98
+ type: Number,
99
+ required: true,
100
+ default: 0
101
+ },
102
+ amountPaid: {
103
+ type: Number,
104
+ required: true,
105
+ default: 0
106
+ },
107
+ balanceDue: {
108
+ type: Number,
109
+ required: true,
110
+ default: 0
111
+ // positive = still owed, negative = overpaid
112
+ },
113
+ overpaymentAmount: {
114
+ type: Number,
115
+ default: 0
116
+ },
117
+
118
+ createdBy: {
119
+ type: mongoose.Schema.Types.ObjectId,
120
+ ref: 'User'
121
+ }
122
+ },
123
+ {
124
+ timestamps: true,
125
+ toJSON: { virtuals: true },
126
+ toObject: { virtuals: true }
127
+ }
128
+ );
129
+
130
+ ContractPaymentReceiptSchema.virtual('contract', {
131
+ ref: 'LevyContract',
132
+ localField: 'contractId',
133
+ foreignField: '_id',
134
+ justOne: true
135
+ });
136
+
137
+ ContractPaymentReceiptSchema.virtual('customer', {
138
+ ref: 'Customer',
139
+ localField: 'customerId',
140
+ foreignField: '_id',
141
+ justOne: true
142
+ });
143
+
144
+ ContractPaymentReceiptSchema.virtual('unit', {
145
+ ref: 'Unit',
146
+ localField: 'unitId',
147
+ foreignField: '_id',
148
+ justOne: true
149
+ });
150
+
151
+ ContractPaymentReceiptSchema.index({ facilityId: 1, receiptNumber: 1 });
152
+ ContractPaymentReceiptSchema.index({ contractId: 1 });
153
+
154
+ module.exports = {
155
+ schema: ContractPaymentReceiptSchema,
156
+ name: 'ContractPaymentReceipt'
157
+ };
@@ -70,7 +70,24 @@ const unitSchema = new mongoose.Schema({
70
70
  moveInDescription: { type: String, default: null },
71
71
  moveInImages: { type: [String], default: [] },
72
72
  moveInAmenities: { type: [String], default: [] },
73
+ moveInLandmarks: { type: [String], default: [] },
74
+ moveInNearbyServices: { type: [String], default: [] },
75
+ moveInLocationAddress: { type: String, default: null },
76
+ moveInLocationCity: { type: String, default: null },
77
+ moveInLocationCounty: { type: String, default: null },
78
+ moveInCoordinates: {
79
+ lat: { type: Number, default: null },
80
+ lng: { type: Number, default: null },
81
+ },
73
82
  moveInApproval: { type: String, enum: ['pending', 'approved', 'rejected'], default: null, index: true },
83
+ moveInStatus: {
84
+ type: String,
85
+ enum: ['draft', 'pending_approval', 'approved_unlisted', 'listed', 'under_offer', 'reserved', 'rented', 'suspended'],
86
+ default: 'draft',
87
+ index: true,
88
+ },
89
+ moveInListingId: { type: mongoose.Schema.Types.ObjectId, default: null, index: true },
90
+ moveInLastSyncedAt: { type: Date, default: null },
74
91
  // ───────────────────────────────────────────────────────────────────────
75
92
 
76
93
  occupants: [
@@ -124,6 +141,7 @@ unitSchema.pre('save', function (next) {
124
141
  unitSchema.index({ name: 1 });
125
142
  unitSchema.index({ isManagedByPropertyManager: 1 });
126
143
  unitSchema.index({ isListedForBooking: 1 });
144
+ unitSchema.index({ listedInMoveIn: 1, moveInApproval: 1 });
127
145
 
128
146
  // Compile the model from the schema
129
147
  const Unit = mongoose.model('Unit', unitSchema);