@voyantjs/plugin-smartbill 0.81.9 → 0.81.12
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/sync.js +22 -3
- package/package.json +9 -9
package/dist/sync.js
CHANGED
|
@@ -269,8 +269,23 @@ async function recordSyncError(event, documentType, err, runtime, pluginOptions)
|
|
|
269
269
|
if (!db)
|
|
270
270
|
return;
|
|
271
271
|
const refs = await financeService.listInvoiceExternalRefs(db, event.id);
|
|
272
|
-
|
|
272
|
+
const matchingRef = refs.find((ref) => isMatchingSmartbillRef(ref, documentType));
|
|
273
|
+
if (matchingRef) {
|
|
274
|
+
await financeService.registerInvoiceExternalRef(db, event.id, {
|
|
275
|
+
provider: "smartbill",
|
|
276
|
+
externalId: matchingRef.externalId ?? null,
|
|
277
|
+
externalNumber: matchingRef.externalNumber ?? null,
|
|
278
|
+
externalUrl: matchingRef.externalUrl ?? null,
|
|
279
|
+
status: matchingRef.status ?? "error",
|
|
280
|
+
syncedAt: new Date().toISOString(),
|
|
281
|
+
syncError: errorMessage(err),
|
|
282
|
+
metadata: {
|
|
283
|
+
...(coerceMetadata(matchingRef.metadata) ?? {}),
|
|
284
|
+
documentType,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
273
287
|
return;
|
|
288
|
+
}
|
|
274
289
|
await financeService.registerInvoiceExternalRef(db, event.id, {
|
|
275
290
|
provider: "smartbill",
|
|
276
291
|
externalId: null,
|
|
@@ -332,7 +347,12 @@ async function resolveMaybe(value, context) {
|
|
|
332
347
|
: value;
|
|
333
348
|
}
|
|
334
349
|
function errorMessage(error) {
|
|
335
|
-
|
|
350
|
+
if (error instanceof Error) {
|
|
351
|
+
const maybeCode = error.code;
|
|
352
|
+
const code = typeof maybeCode === "string" ? maybeCode : null;
|
|
353
|
+
return code ? `${code}: ${error.message}` : error.message;
|
|
354
|
+
}
|
|
355
|
+
return String(error);
|
|
336
356
|
}
|
|
337
357
|
function coerceMetadata(value) {
|
|
338
358
|
return value && typeof value === "object" && !Array.isArray(value)
|
|
@@ -353,7 +373,6 @@ function formatExternalInvoiceNumber(seriesName, number) {
|
|
|
353
373
|
function isUsableSmartbillRef(ref) {
|
|
354
374
|
return (ref.provider === "smartbill" &&
|
|
355
375
|
ref.status !== "error" &&
|
|
356
|
-
!ref.syncError &&
|
|
357
376
|
Boolean(ref.externalNumber || ref.externalId));
|
|
358
377
|
}
|
|
359
378
|
function isMatchingSmartbillRef(ref, documentType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/plugin-smartbill",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -59,18 +59,18 @@
|
|
|
59
59
|
"drizzle-orm": "^0.45.2",
|
|
60
60
|
"hono": "^4.12.10",
|
|
61
61
|
"zod": "^4.3.6",
|
|
62
|
-
"@voyantjs/core": "0.81.
|
|
63
|
-
"@voyantjs/finance": "0.81.
|
|
64
|
-
"@voyantjs/hono": "0.81.
|
|
65
|
-
"@voyantjs/storage": "0.81.
|
|
62
|
+
"@voyantjs/core": "0.81.12",
|
|
63
|
+
"@voyantjs/finance": "0.81.12",
|
|
64
|
+
"@voyantjs/hono": "0.81.12",
|
|
65
|
+
"@voyantjs/storage": "0.81.12"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@tanstack/react-query": "^5.0.0",
|
|
69
69
|
"lucide-react": "^0.475.0",
|
|
70
70
|
"react": "^19.0.0",
|
|
71
71
|
"react-dom": "^19.0.0",
|
|
72
|
-
"@voyantjs/finance-react": "0.81.
|
|
73
|
-
"@voyantjs/ui": "0.81.
|
|
72
|
+
"@voyantjs/finance-react": "0.81.12",
|
|
73
|
+
"@voyantjs/ui": "0.81.12"
|
|
74
74
|
},
|
|
75
75
|
"peerDependenciesMeta": {
|
|
76
76
|
"@tanstack/react-query": {
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"react-dom": "^19.2.4",
|
|
102
102
|
"typescript": "^6.0.2",
|
|
103
103
|
"vitest": "^4.1.2",
|
|
104
|
-
"@voyantjs/finance-react": "0.81.
|
|
105
|
-
"@voyantjs/ui": "0.81.
|
|
104
|
+
"@voyantjs/finance-react": "0.81.12",
|
|
105
|
+
"@voyantjs/ui": "0.81.12",
|
|
106
106
|
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
107
107
|
},
|
|
108
108
|
"files": [
|