payservedb 8.9.8 → 8.9.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 +2 -1
- package/package.json +1 -1
- package/src/models/facility_etims_config.js +117 -0
- package/src/models/vasinvoice.js +4 -0
package/index.js
CHANGED
|
@@ -110,6 +110,7 @@ const models = {
|
|
|
110
110
|
Report: require("./src/models/report"),
|
|
111
111
|
Ticket: require("./src/models/tickets"),
|
|
112
112
|
Rating: require("./src/models/facility_rating"),
|
|
113
|
+
FacilityEtimsConfig: require("./src/models/facility_etims_config"),
|
|
113
114
|
Stocksandspare: require("./src/models/stocksandspare"),
|
|
114
115
|
ServiceVendor: require("./src/models/maintenance_service_vendor"),
|
|
115
116
|
MaintenanceServices: require("./src/models/maintenance_services"),
|
|
@@ -251,7 +252,7 @@ const models = {
|
|
|
251
252
|
PrivacyPolicy: require("./src/models/privacy_policy"),
|
|
252
253
|
TermsAndConditions: require("./src/models/terms_and_conditions"),
|
|
253
254
|
CommunityGuidelines: require("./src/models/community_guidelines"),
|
|
254
|
-
WhatsappConversation
|
|
255
|
+
WhatsappConversation: require("./src/models/whatsapp_conversation"),
|
|
255
256
|
CustomerPreference: require("./src/models/customer_preference"),
|
|
256
257
|
MoveinApplication: require("./src/models/movein_application"),
|
|
257
258
|
EmailThread: require("./src/models/email_thread"),
|
package/package.json
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const FacilityEtimsConfigSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
facilityId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: "Facility",
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true,
|
|
10
|
+
index: true,
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
// ── KRA Organisation Details ─────────────────────────────────────────────
|
|
14
|
+
tin: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
trim: true,
|
|
18
|
+
// Kenya TIN format e.g. P051201909L
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
branchId: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true,
|
|
24
|
+
trim: true,
|
|
25
|
+
default: "00", // "00" = headquarters
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
// ── Master Enable/Disable for this facility ───────────────────────────────
|
|
29
|
+
enabled: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// ── Optional per-facility overrides (fall back to .env if absent) ─────────
|
|
35
|
+
// Leave null to use the system-wide .env values
|
|
36
|
+
baseUrl: {
|
|
37
|
+
type: String,
|
|
38
|
+
trim: true,
|
|
39
|
+
default: null,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
username: {
|
|
43
|
+
type: String,
|
|
44
|
+
trim: true,
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// Store hashed or as-is depending on your security posture.
|
|
49
|
+
// Recommend encrypting at rest; kept as String here to match
|
|
50
|
+
// the pattern used by ZohoConfig in the same codebase.
|
|
51
|
+
password: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: null,
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
// ── Audit / Meta ──────────────────────────────────────────────────────────
|
|
57
|
+
configuredBy: {
|
|
58
|
+
type: String, // user email or ID who last saved
|
|
59
|
+
default: null,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
lastUpdatedAt: {
|
|
63
|
+
type: Date,
|
|
64
|
+
default: null,
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// Lightweight sync stats (updated by the etims service)
|
|
68
|
+
syncStats: {
|
|
69
|
+
totalSynced: { type: Number, default: 0 },
|
|
70
|
+
lastSyncAt: { type: Date, default: null },
|
|
71
|
+
lastSyncStatus: {
|
|
72
|
+
type: String,
|
|
73
|
+
enum: ["success", "failed", null],
|
|
74
|
+
default: null,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
timestamps: true, // createdAt + updatedAt
|
|
80
|
+
collection: "facilityetimsconfigs",
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// ── Instance helper ───────────────────────────────────────────────────────────
|
|
85
|
+
/**
|
|
86
|
+
* Returns the effective config object ready for use in the etims service.
|
|
87
|
+
* Falls back to .env values for credentials not stored per-facility.
|
|
88
|
+
*/
|
|
89
|
+
FacilityEtimsConfigSchema.methods.toEtimsConfig = function () {
|
|
90
|
+
return {
|
|
91
|
+
enabled: this.enabled,
|
|
92
|
+
tin: this.tin,
|
|
93
|
+
branchId: this.branchId,
|
|
94
|
+
baseUrl:
|
|
95
|
+
this.baseUrl ||
|
|
96
|
+
process.env.ETIMS_BASE_URL ||
|
|
97
|
+
"http://102.217.144.50:8888/api/v1/",
|
|
98
|
+
username: this.username || process.env.ETIMS_USERNAME || "admin",
|
|
99
|
+
password: this.password || process.env.ETIMS_PASSWORD || "admin",
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// ── Static helper ────────────────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Load config for a facility. Returns null if not found.
|
|
106
|
+
* @param {string|ObjectId} facilityId
|
|
107
|
+
*/
|
|
108
|
+
FacilityEtimsConfigSchema.statics.getForFacility = async function (facilityId) {
|
|
109
|
+
return this.findOne({ facilityId }).lean();
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const FacilityEtimsConfig = mongoose.model(
|
|
113
|
+
"FacilityEtimsConfig",
|
|
114
|
+
FacilityEtimsConfigSchema
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
module.exports = FacilityEtimsConfig;
|
package/src/models/vasinvoice.js
CHANGED
|
@@ -62,6 +62,10 @@ const vasInvoiceSchema = new mongoose.Schema({
|
|
|
62
62
|
type: Number,
|
|
63
63
|
required: true
|
|
64
64
|
},
|
|
65
|
+
whatFor: {
|
|
66
|
+
invoiceType: { type: String, required: true },
|
|
67
|
+
description: { type: String },
|
|
68
|
+
},
|
|
65
69
|
currency: {
|
|
66
70
|
id: {
|
|
67
71
|
type: mongoose.Schema.Types.ObjectId
|