payservedb 10.1.3 → 10.1.5
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 +2 -0
- package/package.json +1 -1
- package/src/models/audit_log.js +51 -0
- package/src/models/zoho_item_mapping.js +72 -0
package/index.js
CHANGED
|
@@ -244,6 +244,7 @@ const models = {
|
|
|
244
244
|
MasterWorkplanChild: require("./src/models/master_workplan_child"),
|
|
245
245
|
DutyRosterChecklist: require("./src/models/dutyRosterChecklist"),
|
|
246
246
|
AuditTrail: require("./src/models/auditTrail"),
|
|
247
|
+
AuditLog: require("./src/models/audit_log"),
|
|
247
248
|
DailyChecklist: require("./src/models/dailyChecklist"),
|
|
248
249
|
CoreInvoiceSettings: require("./src/models/coreInvoiceSettings"),
|
|
249
250
|
FacilityInvoice: require("./src/models/facilityInvoice"),
|
|
@@ -269,6 +270,7 @@ const models = {
|
|
|
269
270
|
ZohoIntegration: require("./src/models/zohoIntegration"),
|
|
270
271
|
ZohoItem: require("./src/models/zohoItem"),
|
|
271
272
|
ZohoAccount: require("./src/models/zohoAccount"),
|
|
273
|
+
ZohoItemMapping: require("./src/models/zoho_item_mapping"),
|
|
272
274
|
QuickBooksConfig: require("./src/models/quickbooks_config"),
|
|
273
275
|
QuickBooksOAuthState: require("./src/models/quickbooks_oauth_state"),
|
|
274
276
|
QuickBooksAccountMapping: require("./src/models/quickbooks_account_mapping"),
|
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Immutable trail of critical (state-changing) requests: who did what, to which
|
|
4
|
+
// record, and with what payload. Read requests are never stored here.
|
|
5
|
+
const auditLogSchema = new mongoose.Schema(
|
|
6
|
+
{
|
|
7
|
+
action: {
|
|
8
|
+
type: String,
|
|
9
|
+
enum: ['CREATE', 'UPDATE', 'DELETE'],
|
|
10
|
+
required: true,
|
|
11
|
+
index: true,
|
|
12
|
+
},
|
|
13
|
+
module: { type: String, required: true, index: true },
|
|
14
|
+
description: { type: String, default: '' },
|
|
15
|
+
|
|
16
|
+
resourceType: { type: String, default: null },
|
|
17
|
+
resourceId: { type: String, default: null, index: true },
|
|
18
|
+
// Business reference of the record (e.g. credit reference) for tracing
|
|
19
|
+
reference: { type: String, default: null, index: true },
|
|
20
|
+
accountNumber: { type: String, default: null, index: true },
|
|
21
|
+
facilityId: { type: String, default: null, index: true },
|
|
22
|
+
|
|
23
|
+
status: { type: String, enum: ['SUCCESS', 'FAILED'], default: 'SUCCESS' },
|
|
24
|
+
errorMessage: { type: String, default: null },
|
|
25
|
+
|
|
26
|
+
// Sanitised request body / changes
|
|
27
|
+
payload: { type: mongoose.Schema.Types.Mixed, default: null },
|
|
28
|
+
|
|
29
|
+
actor: {
|
|
30
|
+
userId: { type: String, default: null, index: true },
|
|
31
|
+
fullName: { type: String, default: null },
|
|
32
|
+
email: { type: String, default: null },
|
|
33
|
+
role: { type: String, default: null },
|
|
34
|
+
type: { type: String, default: null },
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
request: {
|
|
38
|
+
method: { type: String, default: null },
|
|
39
|
+
url: { type: String, default: null },
|
|
40
|
+
ip: { type: String, default: null },
|
|
41
|
+
userAgent: { type: String, default: null },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{ timestamps: { createdAt: true, updatedAt: false } }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
auditLogSchema.index({ createdAt: -1 });
|
|
48
|
+
|
|
49
|
+
const AuditLog = mongoose.model('AuditLog', auditLogSchema);
|
|
50
|
+
|
|
51
|
+
module.exports = AuditLog;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Which Zoho Books item each PayServe invoice category posts to (per facility).
|
|
2
|
+
// Mirrors quickbooks_item_mapping: invoice lines reference Items, and the Item
|
|
3
|
+
// carries the income account.
|
|
4
|
+
const mongoose = require("mongoose");
|
|
5
|
+
|
|
6
|
+
const zohoItemMappingSchema = new mongoose.Schema(
|
|
7
|
+
{
|
|
8
|
+
facilityId: {
|
|
9
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
10
|
+
ref: "Facility",
|
|
11
|
+
required: true,
|
|
12
|
+
index: true,
|
|
13
|
+
},
|
|
14
|
+
// e.g. utility_power, utility_water, rent_lease, levy_contract, service_charge,
|
|
15
|
+
// property_management, security_deposit
|
|
16
|
+
category: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
trim: true,
|
|
20
|
+
},
|
|
21
|
+
categoryLabel: {
|
|
22
|
+
type: String,
|
|
23
|
+
trim: true,
|
|
24
|
+
default: null,
|
|
25
|
+
},
|
|
26
|
+
zohoItemId: {
|
|
27
|
+
type: String,
|
|
28
|
+
trim: true,
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
zohoItemName: {
|
|
32
|
+
type: String,
|
|
33
|
+
trim: true,
|
|
34
|
+
default: null,
|
|
35
|
+
},
|
|
36
|
+
zohoAccountId: {
|
|
37
|
+
type: String,
|
|
38
|
+
trim: true,
|
|
39
|
+
default: null,
|
|
40
|
+
},
|
|
41
|
+
zohoAccountName: {
|
|
42
|
+
type: String,
|
|
43
|
+
trim: true,
|
|
44
|
+
default: null,
|
|
45
|
+
},
|
|
46
|
+
zohoTaxId: {
|
|
47
|
+
type: String,
|
|
48
|
+
trim: true,
|
|
49
|
+
default: null,
|
|
50
|
+
},
|
|
51
|
+
// auto: accepted suggestion, manual: picked by an admin,
|
|
52
|
+
// created: item created in Zoho from PayServe.
|
|
53
|
+
matchType: {
|
|
54
|
+
type: String,
|
|
55
|
+
enum: ["auto", "manual", "created"],
|
|
56
|
+
default: "manual",
|
|
57
|
+
},
|
|
58
|
+
isActive: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true,
|
|
61
|
+
},
|
|
62
|
+
mappedBy: {
|
|
63
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
64
|
+
default: null,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{ timestamps: true },
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
zohoItemMappingSchema.index({ facilityId: 1, category: 1 }, { unique: true });
|
|
71
|
+
|
|
72
|
+
module.exports = { schema: zohoItemMappingSchema };
|