payservedb 10.0.1 → 10.0.2
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/package.json +1 -1
- package/src/models/combined_invoice.js +1 -1
- package/src/models/levycontract.js +14 -1
- package/src/models/quickbooks_invoice_mapping.js +6 -1
- package/src/models/quickbooks_outbound_sync_state.js +16 -1
- package/src/models/quickbooks_payment_mapping.js +4 -1
- package/src/models/quickbooks_vendor_mapping.js +4 -1
package/package.json
CHANGED
|
@@ -147,7 +147,7 @@ const combinedInvoiceSchema = new mongoose.Schema(
|
|
|
147
147
|
type: {
|
|
148
148
|
type: String,
|
|
149
149
|
required: true,
|
|
150
|
-
enum: ["levy", "lease", "water", "service", "utility", "contract"],
|
|
150
|
+
enum: ["levy", "lease", "water", "power", "service", "utility", "contract"],
|
|
151
151
|
},
|
|
152
152
|
description: {
|
|
153
153
|
type: String,
|
|
@@ -159,8 +159,21 @@ const LevyContractSchema = new Schema(
|
|
|
159
159
|
type: Number,
|
|
160
160
|
default: 0
|
|
161
161
|
},
|
|
162
|
+
// Was declared as [String] while updateUpfrontPaymentTracking
|
|
163
|
+
// (generate_upfront_invoice.js) has always pushed structured
|
|
164
|
+
// objects here - every upfront invoice's tracking update threw a
|
|
165
|
+
// CastError after the invoice itself was already created and
|
|
166
|
+
// synced, making the whole generation look like it failed.
|
|
162
167
|
processedPeriods: {
|
|
163
|
-
type: [
|
|
168
|
+
type: [{
|
|
169
|
+
_id: false,
|
|
170
|
+
label: String,
|
|
171
|
+
rangeStart: Date,
|
|
172
|
+
rangeEnd: Date,
|
|
173
|
+
isProrated: Boolean,
|
|
174
|
+
invoiceId: { type: mongoose.Schema.Types.ObjectId, ref: 'Invoice', default: null },
|
|
175
|
+
processedAt: { type: Date, default: Date.now },
|
|
176
|
+
}],
|
|
164
177
|
default: []
|
|
165
178
|
},
|
|
166
179
|
numberOfMonths: {
|
|
@@ -86,9 +86,14 @@ quickBooksInvoiceMappingSchema.index(
|
|
|
86
86
|
{ facilityId: 1, qbConfigId: 1, sourceType: 1, payserveInvoiceId: 1 },
|
|
87
87
|
{ unique: true },
|
|
88
88
|
);
|
|
89
|
+
// sparse is a no-op on a compound index once every other key (facilityId,
|
|
90
|
+
// qbConfigId) is always present - MongoDB only excludes a doc from a sparse
|
|
91
|
+
// compound index when ALL of its keys are missing, so every mapping row
|
|
92
|
+
// missing qbInvoiceId still got indexed as qbInvoiceId: null and collided.
|
|
93
|
+
// partialFilterExpression is the correct null-safe fix.
|
|
89
94
|
quickBooksInvoiceMappingSchema.index(
|
|
90
95
|
{ facilityId: 1, qbConfigId: 1, qbInvoiceId: 1 },
|
|
91
|
-
{ unique: true,
|
|
96
|
+
{ unique: true, partialFilterExpression: { qbInvoiceId: { $type: "string" } } },
|
|
92
97
|
);
|
|
93
98
|
|
|
94
99
|
module.exports = { schema: quickBooksInvoiceMappingSchema };
|
|
@@ -13,9 +13,12 @@ const quickBooksOutboundSyncStateSchema = new mongoose.Schema(
|
|
|
13
13
|
ref: "QuickBooksConfig",
|
|
14
14
|
required: true,
|
|
15
15
|
},
|
|
16
|
+
// "Invoice" is invoice_service's own scheduler leg; "InvoiceCreate" is
|
|
17
|
+
// backend_main's outbound_sync.js leg - two distinct sync passes writing
|
|
18
|
+
// to this shared collection, not a naming duplicate.
|
|
16
19
|
entity: {
|
|
17
20
|
type: String,
|
|
18
|
-
enum: ["Customer", "Invoice", "Payment", "InvoiceVoid", "Vendor"],
|
|
21
|
+
enum: ["Customer", "Invoice", "InvoiceCreate", "Payment", "InvoiceVoid", "Vendor"],
|
|
19
22
|
required: true,
|
|
20
23
|
},
|
|
21
24
|
status: {
|
|
@@ -29,6 +32,18 @@ const quickBooksOutboundSyncStateSchema = new mongoose.Schema(
|
|
|
29
32
|
processed: { type: Number, default: 0 },
|
|
30
33
|
skipped: { type: Number, default: 0 },
|
|
31
34
|
errors: { type: Number, default: 0 },
|
|
35
|
+
// Capped per-record breakdown for admin visibility ("what actually got
|
|
36
|
+
// looked at"), not just aggregate counts. Each sync run overwrites this
|
|
37
|
+
// with its own findings - not a running log.
|
|
38
|
+
details: [
|
|
39
|
+
{
|
|
40
|
+
_id: false,
|
|
41
|
+
id: String,
|
|
42
|
+
label: String,
|
|
43
|
+
status: { type: String, enum: ["processed", "skipped", "error"] },
|
|
44
|
+
error: String,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
32
47
|
},
|
|
33
48
|
lastError: { type: String, default: null },
|
|
34
49
|
},
|
|
@@ -114,9 +114,12 @@ const quickBooksPaymentMappingSchema = new mongoose.Schema(
|
|
|
114
114
|
{ timestamps: true },
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
+
// sparse is a no-op on a compound index once facilityId/qbConfigId are
|
|
118
|
+
// always present - see quickbooks_invoice_mapping.js for the full
|
|
119
|
+
// explanation. partialFilterExpression is the correct null-safe fix.
|
|
117
120
|
quickBooksPaymentMappingSchema.index(
|
|
118
121
|
{ facilityId: 1, qbConfigId: 1, qbPaymentId: 1 },
|
|
119
|
-
{ unique: true,
|
|
122
|
+
{ unique: true, partialFilterExpression: { qbPaymentId: { $type: "string" } } },
|
|
120
123
|
);
|
|
121
124
|
|
|
122
125
|
module.exports = { schema: quickBooksPaymentMappingSchema };
|
|
@@ -71,9 +71,12 @@ quickBooksVendorMappingSchema.index(
|
|
|
71
71
|
{ facilityId: 1, qbConfigId: 1, payserveSupplierId: 1 },
|
|
72
72
|
{ unique: true, partialFilterExpression: { payserveSupplierId: { $exists: true } } },
|
|
73
73
|
);
|
|
74
|
+
// sparse is a no-op on a compound index once facilityId/qbConfigId are
|
|
75
|
+
// always present - see quickbooks_invoice_mapping.js for the full
|
|
76
|
+
// explanation. partialFilterExpression is the correct null-safe fix.
|
|
74
77
|
quickBooksVendorMappingSchema.index(
|
|
75
78
|
{ facilityId: 1, qbConfigId: 1, qbVendorId: 1 },
|
|
76
|
-
{ unique: true,
|
|
79
|
+
{ unique: true, partialFilterExpression: { qbVendorId: { $type: "string" } } },
|
|
77
80
|
);
|
|
78
81
|
|
|
79
82
|
module.exports = { schema: quickBooksVendorMappingSchema };
|