payservedb 10.2.2 → 10.2.4
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
|
@@ -276,6 +276,7 @@ const models = {
|
|
|
276
276
|
QuickBooksAccountMapping: require("./src/models/quickbooks_account_mapping"),
|
|
277
277
|
QuickBooksItemMapping: require("./src/models/quickbooks_item_mapping"),
|
|
278
278
|
QuickBooksPaymentChannelMapping: require("./src/models/quickbooks_payment_channel_mapping"),
|
|
279
|
+
QuickBooksPostingRule: require("./src/models/quickbooks_posting_rule"),
|
|
279
280
|
QuickBooksCustomerMapping: require("./src/models/quickbooks_customer_mapping"),
|
|
280
281
|
QuickBooksVendorMapping: require("./src/models/quickbooks_vendor_mapping"),
|
|
281
282
|
QuickBooksInvoiceMapping: require("./src/models/quickbooks_invoice_mapping"),
|
|
@@ -287,6 +288,7 @@ const models = {
|
|
|
287
288
|
QuickBooksCdcSweepState: require("./src/models/quickbooks_cdc_sweep_state"),
|
|
288
289
|
QuickBooksBackfillState: require("./src/models/quickbooks_backfill_state"),
|
|
289
290
|
QuickBooksInvoiceRouting: require("./src/models/quickbooks_invoice_routing"),
|
|
291
|
+
QuickBooksLog: require("./src/models/quickbooks_log"),
|
|
290
292
|
DahuaIntegration: require("./src/models/dahuaIntegration"),
|
|
291
293
|
PrivacyPolicy: require("./src/models/privacy_policy"),
|
|
292
294
|
TermsAndConditions: require("./src/models/terms_and_conditions"),
|
|
@@ -466,4 +468,4 @@ module.exports = {
|
|
|
466
468
|
initializeService,
|
|
467
469
|
...models,
|
|
468
470
|
moveIn: moveInModels,
|
|
469
|
-
};
|
|
471
|
+
};
|
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ const facilityAccountSnapshotSchema = new mongoose.Schema({
|
|
|
13
13
|
waterAccounts: { type: Number, default: 0 },
|
|
14
14
|
leaseAccounts: { type: Number, default: 0 },
|
|
15
15
|
levyAccounts: { type: Number, default: 0 },
|
|
16
|
+
powerMeters: { type: Number, default: 0 },
|
|
17
|
+
waterMeters: { type: Number, default: 0 },
|
|
16
18
|
source: { type: String, enum: ['cron', 'backfill'], required: true },
|
|
17
19
|
snapshotAt: { type: Date, default: Date.now }
|
|
18
20
|
}, {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
// Per-call QuickBooks API request/response log for a facility/realm.
|
|
4
|
+
const quickBooksLogSchema = new mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
facilityId: {
|
|
7
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
+
ref: "Facility",
|
|
9
|
+
required: true,
|
|
10
|
+
index: true,
|
|
11
|
+
},
|
|
12
|
+
qbConfigId: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: "QuickBooksConfig",
|
|
15
|
+
required: true,
|
|
16
|
+
index: true,
|
|
17
|
+
},
|
|
18
|
+
realmId: { type: String, index: true },
|
|
19
|
+
environment: { type: String },
|
|
20
|
+
direction: { type: String, enum: ["outbound", "inbound"], default: "outbound" },
|
|
21
|
+
method: { type: String, default: "GET" },
|
|
22
|
+
path: { type: String, required: true },
|
|
23
|
+
params: { type: mongoose.Schema.Types.Mixed },
|
|
24
|
+
requestBody: { type: mongoose.Schema.Types.Mixed },
|
|
25
|
+
responseBody: { type: mongoose.Schema.Types.Mixed },
|
|
26
|
+
statusCode: { type: Number },
|
|
27
|
+
errorMessage: { type: String },
|
|
28
|
+
faultCode: { type: String },
|
|
29
|
+
startedAt: { type: Date, default: Date.now, index: true },
|
|
30
|
+
endedAt: { type: Date },
|
|
31
|
+
durationMs: { type: Number },
|
|
32
|
+
correlationId: { type: String, index: true },
|
|
33
|
+
qbRequestId: { type: String },
|
|
34
|
+
},
|
|
35
|
+
{ timestamps: true },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
quickBooksLogSchema.index({ facilityId: 1, qbConfigId: 1, startedAt: -1 });
|
|
39
|
+
|
|
40
|
+
module.exports = { schema: quickBooksLogSchema };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
// One double-entry posting rule per (realm, event, set of categories).
|
|
4
|
+
//
|
|
5
|
+
// invoice_issued Dr = Accounts Receivable account Cr = income / liability account
|
|
6
|
+
// payment_received Dr = Bank / Other Current Asset Cr = Accounts Receivable account
|
|
7
|
+
//
|
|
8
|
+
// For invoices QuickBooks takes the debit as Invoice.ARAccountRef and the
|
|
9
|
+
// credit from the Item's income account, so qbItemId is the PayServe-managed
|
|
10
|
+
// Item created for the credit account.
|
|
11
|
+
const quickBooksPostingRuleSchema = new mongoose.Schema(
|
|
12
|
+
{
|
|
13
|
+
facilityId: { type: mongoose.Schema.Types.ObjectId, ref: "Facility", required: true, index: true },
|
|
14
|
+
qbConfigId: { type: mongoose.Schema.Types.ObjectId, ref: "QuickBooksConfig", required: true, index: true },
|
|
15
|
+
event: { type: String, enum: ["invoice_issued", "payment_received"], required: true },
|
|
16
|
+
categories: { type: [String], default: [] },
|
|
17
|
+
// payment_received only. Empty = every channel.
|
|
18
|
+
channels: { type: [String], default: [] },
|
|
19
|
+
|
|
20
|
+
debitQbAccountId: { type: String, required: true, trim: true },
|
|
21
|
+
debitQbAccountName: { type: String, trim: true, default: null },
|
|
22
|
+
debitQbAccountType: { type: String, trim: true, default: null },
|
|
23
|
+
|
|
24
|
+
creditQbAccountId: { type: String, required: true, trim: true },
|
|
25
|
+
creditQbAccountName: { type: String, trim: true, default: null },
|
|
26
|
+
creditQbAccountType: { type: String, trim: true, default: null },
|
|
27
|
+
|
|
28
|
+
// invoice_issued only: Item whose income account is creditQbAccountId.
|
|
29
|
+
qbItemId: { type: String, trim: true, default: null },
|
|
30
|
+
qbItemName: { type: String, trim: true, default: null },
|
|
31
|
+
|
|
32
|
+
note: { type: String, trim: true, default: null },
|
|
33
|
+
isActive: { type: Boolean, default: true },
|
|
34
|
+
updatedBy: { type: mongoose.Schema.Types.ObjectId, default: null },
|
|
35
|
+
},
|
|
36
|
+
{ timestamps: true },
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
quickBooksPostingRuleSchema.index({ facilityId: 1, qbConfigId: 1, event: 1 });
|
|
40
|
+
|
|
41
|
+
module.exports = { schema: quickBooksPostingRuleSchema };
|