payservedb 8.3.7 → 8.3.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.
Files changed (179) hide show
  1. package/.env +2 -2
  2. package/ZOHO_INTEGRATION_SCHEMA.md +644 -0
  3. package/index.js +307 -306
  4. package/package.json +17 -17
  5. package/src/models/account.js +52 -52
  6. package/src/models/agent_departments.js +59 -59
  7. package/src/models/agent_notifications.js +53 -53
  8. package/src/models/agent_performance.js +127 -127
  9. package/src/models/agent_roles.js +77 -77
  10. package/src/models/agents.js +154 -154
  11. package/src/models/apilog.js +18 -18
  12. package/src/models/approvalsWorkflows.js +49 -49
  13. package/src/models/archivedapilog.js +18 -18
  14. package/src/models/asset.js +92 -92
  15. package/src/models/assetsAssignment.js +64 -64
  16. package/src/models/auditTrail.js +346 -346
  17. package/src/models/bankdetails.js +47 -47
  18. package/src/models/billerAddress.js +124 -124
  19. package/src/models/booking_invoice.js +151 -151
  20. package/src/models/bookinganalytics.js +63 -63
  21. package/src/models/bookingconfig.js +45 -45
  22. package/src/models/bookingproperty.js +122 -122
  23. package/src/models/bookingreservation.js +192 -192
  24. package/src/models/bookingrevenuerecord.js +84 -84
  25. package/src/models/budget.js +95 -95
  26. package/src/models/budgetCategory.js +19 -19
  27. package/src/models/campaigns.js +108 -108
  28. package/src/models/cashpayment.js +264 -264
  29. package/src/models/combinedUnits.js +62 -62
  30. package/src/models/common_area_electricity.js +38 -38
  31. package/src/models/common_area_generator.js +41 -41
  32. package/src/models/common_area_utility_alert.js +37 -37
  33. package/src/models/common_area_water.js +39 -39
  34. package/src/models/communication_status.js +33 -33
  35. package/src/models/communication_user_opt.js +32 -32
  36. package/src/models/company.js +53 -53
  37. package/src/models/coreBaseSettings.js +16 -16
  38. package/src/models/coreInvoiceSettings.js +100 -100
  39. package/src/models/counter_schema.js +21 -21
  40. package/src/models/country_tax.js +42 -42
  41. package/src/models/currency_settings.js +39 -39
  42. package/src/models/customer.js +210 -210
  43. package/src/models/customer_satisfaction_survey.js +278 -278
  44. package/src/models/customer_surveys.js +139 -139
  45. package/src/models/customer_tickets.js +239 -239
  46. package/src/models/dailyChecklist.js +312 -312
  47. package/src/models/default_payment_details.js +17 -17
  48. package/src/models/deliveryTimeMarks.js +18 -18
  49. package/src/models/document_type.js +19 -19
  50. package/src/models/dutyRosterChecklist.js +250 -250
  51. package/src/models/dutyroster.js +136 -136
  52. package/src/models/email.js +37 -37
  53. package/src/models/email_sms_queue.js +61 -61
  54. package/src/models/entry_exit.js +53 -53
  55. package/src/models/expense.js +99 -99
  56. package/src/models/expense_category.js +45 -45
  57. package/src/models/facility.js +62 -62
  58. package/src/models/facilityBillingPrices.js +29 -29
  59. package/src/models/facilityInvoice.js +240 -223
  60. package/src/models/facilityInvoicePayment.js +52 -47
  61. package/src/models/facilityInvoiceRecipient.js +32 -32
  62. package/src/models/facilityWalletTransactionsMetadata.js +236 -236
  63. package/src/models/facility_departements.js +20 -20
  64. package/src/models/facility_payment_details.js +20 -20
  65. package/src/models/facilityasset.js +25 -25
  66. package/src/models/faq.js +14 -14
  67. package/src/models/gl_account_double_entries.js +25 -25
  68. package/src/models/gl_accounts.js +56 -56
  69. package/src/models/gl_entries.js +49 -49
  70. package/src/models/goodsReceivedNotes.js +115 -115
  71. package/src/models/guard.js +47 -47
  72. package/src/models/handover.js +247 -247
  73. package/src/models/inspection_category.js +38 -38
  74. package/src/models/invoice.js +387 -387
  75. package/src/models/invoicing_schedule.js +36 -36
  76. package/src/models/item_inspection.js +96 -96
  77. package/src/models/knowledge_base.js +109 -109
  78. package/src/models/knowledge_base_rating.js +44 -44
  79. package/src/models/leaseagreement.js +236 -236
  80. package/src/models/leasetemplate.js +17 -17
  81. package/src/models/levy.js +223 -223
  82. package/src/models/levy_invoice_settings.js +26 -26
  83. package/src/models/levycontract.js +177 -177
  84. package/src/models/levytype.js +23 -23
  85. package/src/models/maintenance_service_vendor.js +38 -38
  86. package/src/models/maintenance_services.js +17 -17
  87. package/src/models/maintenancerequisition.js +31 -31
  88. package/src/models/master_workplan.js +32 -32
  89. package/src/models/master_workplan_child.js +34 -34
  90. package/src/models/message.js +38 -38
  91. package/src/models/module.js +21 -21
  92. package/src/models/notification.js +44 -44
  93. package/src/models/paymentTermsMarks.js +19 -19
  94. package/src/models/penalty.js +76 -76
  95. package/src/models/pendingCredentials.js +32 -32
  96. package/src/models/powerMeterCommunicationProtocol.js +17 -17
  97. package/src/models/powerMeterCustomerAccount.js +78 -78
  98. package/src/models/powerMeterCustomerBand.js +14 -14
  99. package/src/models/powerMeterDailyReading.js +30 -30
  100. package/src/models/powerMeterGateways.js +40 -40
  101. package/src/models/powerMeterMonthlyReading.js +34 -34
  102. package/src/models/powerMeterPowerCharges.js +85 -85
  103. package/src/models/powerMeterSettings.js +159 -159
  104. package/src/models/powerMeterSingleDayReading.js +32 -32
  105. package/src/models/powerMeters.js +116 -116
  106. package/src/models/powerMetersManufacturer.js +14 -14
  107. package/src/models/power_meter_account.js +81 -81
  108. package/src/models/power_meter_command_logs.js +30 -30
  109. package/src/models/power_meter_command_queue.js +33 -33
  110. package/src/models/power_meter_negative_balance.js +44 -44
  111. package/src/models/power_prepaid_credits.js +47 -47
  112. package/src/models/power_prepaid_debits.js +53 -53
  113. package/src/models/power_prepaid_orders.js +78 -78
  114. package/src/models/power_sms_notification.js +26 -26
  115. package/src/models/propertyManagerContract.js +556 -556
  116. package/src/models/propertyManagerRevenue.js +195 -195
  117. package/src/models/purchaseOrderInvoice.js +74 -74
  118. package/src/models/purchase_order.js +213 -213
  119. package/src/models/purchase_request.js +110 -110
  120. package/src/models/refresh_token.js +23 -23
  121. package/src/models/reminder.js +197 -197
  122. package/src/models/report.js +13 -13
  123. package/src/models/resident.js +121 -121
  124. package/src/models/rfq_details.js +131 -131
  125. package/src/models/rfq_response.js +153 -153
  126. package/src/models/service_charge_invoice_upload.js +42 -42
  127. package/src/models/service_charge_payments.js +27 -27
  128. package/src/models/servicerequest.js +55 -55
  129. package/src/models/settings.js +62 -62
  130. package/src/models/short_urls.js +21 -21
  131. package/src/models/smart_meter_daily_consumption.js +44 -44
  132. package/src/models/sms_africastalking.js +20 -20
  133. package/src/models/sms_balance_notification.js +26 -26
  134. package/src/models/sms_meliora.js +20 -20
  135. package/src/models/staff.js +36 -36
  136. package/src/models/stocksandspare.js +161 -161
  137. package/src/models/suppliers.js +74 -74
  138. package/src/models/tickets.js +173 -173
  139. package/src/models/tickets_category.js +72 -72
  140. package/src/models/unitManagementTemplate.js +44 -44
  141. package/src/models/unitasset.js +25 -25
  142. package/src/models/units.js +118 -118
  143. package/src/models/user.js +186 -186
  144. package/src/models/valueaddedservices.js +79 -79
  145. package/src/models/vas_invoices_upload.js +50 -50
  146. package/src/models/vas_payments.js +24 -24
  147. package/src/models/vasinvoice.js +192 -192
  148. package/src/models/vasvendor.js +57 -57
  149. package/src/models/visitLog.js +95 -95
  150. package/src/models/visitor.js +67 -67
  151. package/src/models/waitlist.js +45 -45
  152. package/src/models/wallet.js +44 -44
  153. package/src/models/wallet_transactions.js +50 -50
  154. package/src/models/water_invoice.js +351 -351
  155. package/src/models/water_meter_Command_Queue.js +33 -33
  156. package/src/models/water_meter_account.js +82 -82
  157. package/src/models/water_meter_billing.js +58 -58
  158. package/src/models/water_meter_communication.js +17 -17
  159. package/src/models/water_meter_communication_logs.js +39 -39
  160. package/src/models/water_meter_concentrator.js +70 -70
  161. package/src/models/water_meter_daily_history.js +32 -32
  162. package/src/models/water_meter_high_risk.js +36 -36
  163. package/src/models/water_meter_iot_cards.js +34 -34
  164. package/src/models/water_meter_manufacturer.js +35 -35
  165. package/src/models/water_meter_monthly_history.js +36 -36
  166. package/src/models/water_meter_negative_amounts.js +44 -44
  167. package/src/models/water_meter_settings.js +283 -283
  168. package/src/models/water_meter_single_day_history.js +34 -34
  169. package/src/models/water_meter_size.js +15 -15
  170. package/src/models/water_meters.js +133 -133
  171. package/src/models/water_meters_delivery.js +76 -76
  172. package/src/models/water_prepaid_credit.js +47 -47
  173. package/src/models/water_prepaid_debit.js +50 -50
  174. package/src/models/workorder.js +49 -49
  175. package/src/models/zohoIntegration.js +262 -0
  176. package/.idea/material_theme_project_new.xml +0 -12
  177. package/.idea/modules.xml +0 -8
  178. package/.idea/psdb.iml +0 -12
  179. package/.idea/vcs.xml +0 -6
@@ -1,161 +1,161 @@
1
- const mongoose = require("mongoose");
2
-
3
- // Metadata subdocument schema for tracking stock changes
4
- const stockMetadataSchema = new mongoose.Schema(
5
- {
6
- timestamp: {
7
- type: Date,
8
- default: Date.now,
9
- required: true,
10
- },
11
- description: {
12
- type: String,
13
- required: true,
14
- trim: true,
15
- },
16
- changeType: {
17
- type: String,
18
- enum: ["increment", "decrement", "adjustment", "initial", "edit"],
19
- required: true,
20
- },
21
- previousQuantity: {
22
- type: Number,
23
- min: 0,
24
- },
25
- newQuantity: {
26
- type: Number,
27
- min: 0,
28
- required: true,
29
- },
30
- quantityChanged: {
31
- type: Number,
32
- required: true,
33
- },
34
- userId: {
35
- type: mongoose.Schema.Types.ObjectId,
36
- ref: "User", // assuming you have a User model
37
- },
38
- },
39
- { _id: false },
40
- ); // _id: false to prevent auto-generation of _id for subdocuments
41
-
42
- const stockAndSparesSchema = new mongoose.Schema(
43
- {
44
- facilityId: {
45
- type: mongoose.Schema.Types.ObjectId,
46
- ref: "Facility",
47
- required: true,
48
- },
49
- name: {
50
- type: String,
51
- required: true,
52
- },
53
- description: {
54
- type: String,
55
- },
56
- skuDetails: {
57
- type: String,
58
- required: true,
59
- },
60
- quantityInStock: {
61
- type: Number,
62
- required: true,
63
- min: 0,
64
- },
65
- reOrderLevel: {
66
- type: Number,
67
- required: true,
68
- min: 0,
69
- },
70
- // New metadata field to track all stock changes
71
- metadata: [stockMetadataSchema],
72
- },
73
- {
74
- timestamps: true,
75
- },
76
- );
77
-
78
- // Pre-save middleware to automatically add metadata entry when quantity changes
79
- stockAndSparesSchema.pre("save", function (next) {
80
- if (this.isModified("quantityInStock") && !this.isNew) {
81
- // Get the original document to compare quantities
82
- const originalDoc = this.constructor.findById(this._id);
83
- originalDoc.then((original) => {
84
- if (original && original.quantityInStock !== this.quantityInStock) {
85
- const quantityChanged = this.quantityInStock - original.quantityInStock;
86
- const changeType =
87
- quantityChanged > 0
88
- ? "increment"
89
- : quantityChanged < 0
90
- ? "decrement"
91
- : "adjustment";
92
-
93
- // Add metadata entry (you can set description and userId from your controller)
94
- this.metadata.push({
95
- previousQuantity: original.quantityInStock,
96
- newQuantity: this.quantityInStock,
97
- quantityChanged: quantityChanged,
98
- changeType: changeType,
99
- description:
100
- this._metadataDescription ||
101
- `Stock ${changeType}: ${Math.abs(quantityChanged)} units`,
102
- userId: this._userId || null,
103
- });
104
- }
105
- });
106
- }
107
- next();
108
- });
109
-
110
- // Instance method to add stock with metadata
111
- stockAndSparesSchema.methods.addStock = function (
112
- quantity,
113
- description,
114
- userId,
115
- ) {
116
- const previousQuantity = this.quantityInStock;
117
- this.quantityInStock += quantity;
118
-
119
- this.metadata.push({
120
- previousQuantity: previousQuantity,
121
- newQuantity: this.quantityInStock,
122
- quantityChanged: quantity,
123
- changeType: "increment",
124
- description: description || `Added ${quantity} units to stock`,
125
- userId: userId,
126
- });
127
-
128
- return this.save();
129
- };
130
-
131
- // Instance method to reduce stock with metadata
132
- stockAndSparesSchema.methods.reduceStock = function (
133
- quantity,
134
- description,
135
- userId,
136
- ) {
137
- if (this.quantityInStock < quantity) {
138
- throw new Error("Insufficient stock quantity");
139
- }
140
-
141
- const previousQuantity = this.quantityInStock;
142
- this.quantityInStock -= quantity;
143
-
144
- this.metadata.push({
145
- previousQuantity: previousQuantity,
146
- newQuantity: this.quantityInStock,
147
- quantityChanged: -quantity,
148
- changeType: "decrement",
149
- description: description || `Removed ${quantity} units from stock`,
150
- userId: userId,
151
- });
152
-
153
- return this.save();
154
- };
155
-
156
- // Instance method to get stock history
157
- stockAndSparesSchema.methods.getStockHistory = function () {
158
- return this.metadata.sort((a, b) => b.timestamp - a.timestamp);
159
- };
160
-
161
- module.exports = mongoose.model("Stocksandspare", stockAndSparesSchema);
1
+ const mongoose = require("mongoose");
2
+
3
+ // Metadata subdocument schema for tracking stock changes
4
+ const stockMetadataSchema = new mongoose.Schema(
5
+ {
6
+ timestamp: {
7
+ type: Date,
8
+ default: Date.now,
9
+ required: true,
10
+ },
11
+ description: {
12
+ type: String,
13
+ required: true,
14
+ trim: true,
15
+ },
16
+ changeType: {
17
+ type: String,
18
+ enum: ["increment", "decrement", "adjustment", "initial", "edit"],
19
+ required: true,
20
+ },
21
+ previousQuantity: {
22
+ type: Number,
23
+ min: 0,
24
+ },
25
+ newQuantity: {
26
+ type: Number,
27
+ min: 0,
28
+ required: true,
29
+ },
30
+ quantityChanged: {
31
+ type: Number,
32
+ required: true,
33
+ },
34
+ userId: {
35
+ type: mongoose.Schema.Types.ObjectId,
36
+ ref: "User", // assuming you have a User model
37
+ },
38
+ },
39
+ { _id: false },
40
+ ); // _id: false to prevent auto-generation of _id for subdocuments
41
+
42
+ const stockAndSparesSchema = new mongoose.Schema(
43
+ {
44
+ facilityId: {
45
+ type: mongoose.Schema.Types.ObjectId,
46
+ ref: "Facility",
47
+ required: true,
48
+ },
49
+ name: {
50
+ type: String,
51
+ required: true,
52
+ },
53
+ description: {
54
+ type: String,
55
+ },
56
+ skuDetails: {
57
+ type: String,
58
+ required: true,
59
+ },
60
+ quantityInStock: {
61
+ type: Number,
62
+ required: true,
63
+ min: 0,
64
+ },
65
+ reOrderLevel: {
66
+ type: Number,
67
+ required: true,
68
+ min: 0,
69
+ },
70
+ // New metadata field to track all stock changes
71
+ metadata: [stockMetadataSchema],
72
+ },
73
+ {
74
+ timestamps: true,
75
+ },
76
+ );
77
+
78
+ // Pre-save middleware to automatically add metadata entry when quantity changes
79
+ stockAndSparesSchema.pre("save", function (next) {
80
+ if (this.isModified("quantityInStock") && !this.isNew) {
81
+ // Get the original document to compare quantities
82
+ const originalDoc = this.constructor.findById(this._id);
83
+ originalDoc.then((original) => {
84
+ if (original && original.quantityInStock !== this.quantityInStock) {
85
+ const quantityChanged = this.quantityInStock - original.quantityInStock;
86
+ const changeType =
87
+ quantityChanged > 0
88
+ ? "increment"
89
+ : quantityChanged < 0
90
+ ? "decrement"
91
+ : "adjustment";
92
+
93
+ // Add metadata entry (you can set description and userId from your controller)
94
+ this.metadata.push({
95
+ previousQuantity: original.quantityInStock,
96
+ newQuantity: this.quantityInStock,
97
+ quantityChanged: quantityChanged,
98
+ changeType: changeType,
99
+ description:
100
+ this._metadataDescription ||
101
+ `Stock ${changeType}: ${Math.abs(quantityChanged)} units`,
102
+ userId: this._userId || null,
103
+ });
104
+ }
105
+ });
106
+ }
107
+ next();
108
+ });
109
+
110
+ // Instance method to add stock with metadata
111
+ stockAndSparesSchema.methods.addStock = function (
112
+ quantity,
113
+ description,
114
+ userId,
115
+ ) {
116
+ const previousQuantity = this.quantityInStock;
117
+ this.quantityInStock += quantity;
118
+
119
+ this.metadata.push({
120
+ previousQuantity: previousQuantity,
121
+ newQuantity: this.quantityInStock,
122
+ quantityChanged: quantity,
123
+ changeType: "increment",
124
+ description: description || `Added ${quantity} units to stock`,
125
+ userId: userId,
126
+ });
127
+
128
+ return this.save();
129
+ };
130
+
131
+ // Instance method to reduce stock with metadata
132
+ stockAndSparesSchema.methods.reduceStock = function (
133
+ quantity,
134
+ description,
135
+ userId,
136
+ ) {
137
+ if (this.quantityInStock < quantity) {
138
+ throw new Error("Insufficient stock quantity");
139
+ }
140
+
141
+ const previousQuantity = this.quantityInStock;
142
+ this.quantityInStock -= quantity;
143
+
144
+ this.metadata.push({
145
+ previousQuantity: previousQuantity,
146
+ newQuantity: this.quantityInStock,
147
+ quantityChanged: -quantity,
148
+ changeType: "decrement",
149
+ description: description || `Removed ${quantity} units from stock`,
150
+ userId: userId,
151
+ });
152
+
153
+ return this.save();
154
+ };
155
+
156
+ // Instance method to get stock history
157
+ stockAndSparesSchema.methods.getStockHistory = function () {
158
+ return this.metadata.sort((a, b) => b.timestamp - a.timestamp);
159
+ };
160
+
161
+ module.exports = mongoose.model("Stocksandspare", stockAndSparesSchema);
@@ -1,75 +1,75 @@
1
- const mongoose = require('mongoose');
2
-
3
- const supplierSchema = new mongoose.Schema({
4
- // Existing fields remain unchanged
5
- facilityId: {
6
- type: mongoose.Schema.Types.ObjectId,
7
- ref: 'Facility',
8
- required: true,
9
- index: true
10
- },
11
- name: {
12
- type: String,
13
- required: true,
14
- trim: true,
15
- index: true
16
- },
17
- email: {
18
- type: String,
19
- required: true,
20
- trim: true,
21
- lowercase: true
22
- },
23
- phone: {
24
- type: String,
25
- required: true,
26
- trim: true
27
- },
28
- contactPerson: {
29
- name: {
30
- type: String,
31
- trim: true
32
- }
33
- },
34
- department: {
35
- name: {
36
- type: String,
37
- trim: true
38
- }
39
- },
40
- taxIdentificationNumber: {
41
- type: String,
42
- trim: true
43
- },
44
- documents: [{
45
- documentName: {
46
- type: String,
47
- required: true
48
- },
49
- documentType: {
50
- type: String,
51
- required: true
52
- },
53
- document: {
54
- type: String,
55
- required: true
56
- }
57
- }],
58
- status: {
59
- type: String,
60
- enum: ['active', 'inactive', 'blacklisted'],
61
- default: 'active',
62
- index: true
63
- },
64
- userId: {
65
- type: mongoose.Schema.Types.ObjectId,
66
- ref: 'User',
67
- index: true
68
- }
69
- }, {
70
- timestamps: true
71
- });
72
-
73
- const Supplier = mongoose.model('Supplier', supplierSchema);
74
-
1
+ const mongoose = require('mongoose');
2
+
3
+ const supplierSchema = new mongoose.Schema({
4
+ // Existing fields remain unchanged
5
+ facilityId: {
6
+ type: mongoose.Schema.Types.ObjectId,
7
+ ref: 'Facility',
8
+ required: true,
9
+ index: true
10
+ },
11
+ name: {
12
+ type: String,
13
+ required: true,
14
+ trim: true,
15
+ index: true
16
+ },
17
+ email: {
18
+ type: String,
19
+ required: true,
20
+ trim: true,
21
+ lowercase: true
22
+ },
23
+ phone: {
24
+ type: String,
25
+ required: true,
26
+ trim: true
27
+ },
28
+ contactPerson: {
29
+ name: {
30
+ type: String,
31
+ trim: true
32
+ }
33
+ },
34
+ department: {
35
+ name: {
36
+ type: String,
37
+ trim: true
38
+ }
39
+ },
40
+ taxIdentificationNumber: {
41
+ type: String,
42
+ trim: true
43
+ },
44
+ documents: [{
45
+ documentName: {
46
+ type: String,
47
+ required: true
48
+ },
49
+ documentType: {
50
+ type: String,
51
+ required: true
52
+ },
53
+ document: {
54
+ type: String,
55
+ required: true
56
+ }
57
+ }],
58
+ status: {
59
+ type: String,
60
+ enum: ['active', 'inactive', 'blacklisted'],
61
+ default: 'active',
62
+ index: true
63
+ },
64
+ userId: {
65
+ type: mongoose.Schema.Types.ObjectId,
66
+ ref: 'User',
67
+ index: true
68
+ }
69
+ }, {
70
+ timestamps: true
71
+ });
72
+
73
+ const Supplier = mongoose.model('Supplier', supplierSchema);
74
+
75
75
  module.exports = Supplier;