@classytic/ledger 0.12.0 → 0.12.1
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/dist/index.mjs +19 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1185,12 +1185,25 @@ function wireAccountMethods(repository, country, orgField, integrations = {}) {
|
|
|
1185
1185
|
});
|
|
1186
1186
|
try {
|
|
1187
1187
|
const inserted = await repository.createMany(docs, { ordered: false });
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1188
|
+
const insertedByNumber = /* @__PURE__ */ new Map();
|
|
1189
|
+
for (const doc of inserted) {
|
|
1190
|
+
const num = doc?.accountNumber;
|
|
1191
|
+
if (num) insertedByNumber.set(num, doc);
|
|
1192
|
+
}
|
|
1193
|
+
for (const item of toCreate) {
|
|
1194
|
+
const doc = insertedByNumber.get(item.accountNumber);
|
|
1195
|
+
if (doc) results.created.push({
|
|
1196
|
+
accountTypeCode: item.accountTypeCode,
|
|
1197
|
+
active: item.active,
|
|
1198
|
+
isCashAccount: item.isCashAccount,
|
|
1199
|
+
_id: doc._id
|
|
1200
|
+
});
|
|
1201
|
+
else results.skipped.push({
|
|
1202
|
+
index: item.index,
|
|
1203
|
+
accountTypeCode: item.accountTypeCode,
|
|
1204
|
+
reason: "Not returned by createMany (driver edge case)"
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1194
1207
|
} catch (err) {
|
|
1195
1208
|
if (!isDuplicateKeyBulkError(err)) throw err;
|
|
1196
1209
|
const insertedDocs = err.insertedDocs ?? [];
|
package/package.json
CHANGED