repzo-sap-absjo 1.0.16 → 1.0.19
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.
|
@@ -16,12 +16,14 @@ export const create_invoice = async (event, options) => {
|
|
|
16
16
|
const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
|
|
17
17
|
let body;
|
|
18
18
|
try {
|
|
19
|
-
|
|
19
|
+
console.log("create_invoice"); // Debug log added
|
|
20
20
|
await actionLog.load(action_sync_id);
|
|
21
21
|
body = event.body;
|
|
22
22
|
try {
|
|
23
23
|
if (body) body = JSON.parse(body);
|
|
24
|
-
} catch (e) {
|
|
24
|
+
} catch (e) {
|
|
25
|
+
console.error("Error parsing event body:", e); // Debug log added
|
|
26
|
+
}
|
|
25
27
|
const repzo_serial_number =
|
|
26
28
|
(_c = body === null || body === void 0 ? void 0 : body.serial_number) ===
|
|
27
29
|
null || _c === void 0
|
|
@@ -36,7 +38,7 @@ export const create_invoice = async (event, options) => {
|
|
|
36
38
|
{ _id: body._id, type: "fullinvoices" }
|
|
37
39
|
);
|
|
38
40
|
} catch (e) {
|
|
39
|
-
console.error(e);
|
|
41
|
+
console.error("Error updating integration meta:", e); // Debug log added
|
|
40
42
|
}
|
|
41
43
|
await actionLog
|
|
42
44
|
.addDetail(
|
|
@@ -332,14 +334,14 @@ export const create_invoice = async (event, options) => {
|
|
|
332
334
|
sap_invoice
|
|
333
335
|
);
|
|
334
336
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
335
|
-
|
|
337
|
+
console.log("SAP Result:", result); // Debug log added
|
|
336
338
|
try {
|
|
337
339
|
await repzo.updateIntegrationMeta.create(
|
|
338
340
|
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
339
341
|
{ _id: body._id, type: "fullinvoices" }
|
|
340
342
|
);
|
|
341
343
|
} catch (e) {
|
|
342
|
-
console.error(e);
|
|
344
|
+
console.error("Error updating integration meta:", e); // Debug log added
|
|
343
345
|
}
|
|
344
346
|
await actionLog
|
|
345
347
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -357,15 +359,20 @@ export const create_invoice = async (event, options) => {
|
|
|
357
359
|
};
|
|
358
360
|
export const get_invoice_from_sap = async (serviceEndPoint, query) => {
|
|
359
361
|
try {
|
|
362
|
+
console.log("Inside get_invoice_from_sap function"); // Debug log
|
|
363
|
+
console.log("Service End Point:", serviceEndPoint); // Debug log
|
|
364
|
+
console.log("Query:", query); // Debug log
|
|
360
365
|
const sap_openInvoices = await _create(serviceEndPoint, "/OpenInvoices", {
|
|
361
366
|
updatedAt: query === null || query === void 0 ? void 0 : query.updatedAt,
|
|
362
367
|
Status: query === null || query === void 0 ? void 0 : query.Status,
|
|
363
368
|
InvoiceId: query === null || query === void 0 ? void 0 : query.InvoiceId,
|
|
364
369
|
});
|
|
370
|
+
console.log("SAP Open Invoices:", sap_openInvoices); // Debug log
|
|
365
371
|
return sap_openInvoices === null || sap_openInvoices === void 0
|
|
366
372
|
? void 0
|
|
367
373
|
: sap_openInvoices.OpenInvoices;
|
|
368
374
|
} catch (e) {
|
|
375
|
+
console.error("Error in get_invoice_from_sap:", e); // Debug log
|
|
369
376
|
throw e;
|
|
370
377
|
}
|
|
371
378
|
};
|
|
@@ -373,8 +380,13 @@ function getUniqueConcatenatedValues(item, key, delimiter) {
|
|
|
373
380
|
item.general_promotions = item.general_promotions || [];
|
|
374
381
|
item.used_promotions = item.used_promotions || [];
|
|
375
382
|
const allPromotions = [...item.general_promotions, ...item.used_promotions];
|
|
383
|
+
console.log("Inside getUniqueConcatenatedValues function"); // Debug log
|
|
384
|
+
console.log("Item:", item); // Debug log
|
|
385
|
+
console.log("Key:", key); // Debug log
|
|
386
|
+
console.log("Delimiter:", delimiter); // Debug log
|
|
376
387
|
const uniqueValues = new Set(
|
|
377
388
|
allPromotions.map((promotion) => promotion[key]).filter((value) => value)
|
|
378
389
|
);
|
|
390
|
+
console.log("Unique Values:", uniqueValues); // Debug log
|
|
379
391
|
return [...uniqueValues].join(delimiter);
|
|
380
392
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
set_error,
|
|
7
7
|
} from "../util.js";
|
|
8
8
|
export const sync_disabled_product = async (commandEvent) => {
|
|
9
|
-
var _a, _b
|
|
9
|
+
var _a, _b;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -56,25 +56,21 @@ export const sync_disabled_product = async (commandEvent) => {
|
|
|
56
56
|
sap_products === null || sap_products === void 0
|
|
57
57
|
? void 0
|
|
58
58
|
: sap_products.map((product) => `${nameSpace}_${product.ITEMCODE}`);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
: _b.length
|
|
75
|
-
)
|
|
76
|
-
repzo_products.push(...repzo_product_per_page.data);
|
|
77
|
-
}
|
|
59
|
+
const repzo_product_per_page = await repzo.patchAction.create(
|
|
60
|
+
{
|
|
61
|
+
slug: "product",
|
|
62
|
+
readQuery: [
|
|
63
|
+
{ key: "active", value: [true], operator: "eq" },
|
|
64
|
+
{
|
|
65
|
+
key: "integration_meta.id",
|
|
66
|
+
value: sap_product_query,
|
|
67
|
+
operator: "in",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{ per_page: 50000 }
|
|
72
|
+
);
|
|
73
|
+
const repzo_products = repzo_product_per_page.data;
|
|
78
74
|
result.repzo_total =
|
|
79
75
|
repzo_products === null || repzo_products === void 0
|
|
80
76
|
? void 0
|
|
@@ -146,10 +142,10 @@ export const sync_disabled_product = async (commandEvent) => {
|
|
|
146
142
|
} catch (e) {
|
|
147
143
|
//@ts-ignore
|
|
148
144
|
console.error(
|
|
149
|
-
((
|
|
150
|
-
|
|
145
|
+
((_b = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
146
|
+
_b === void 0
|
|
151
147
|
? void 0
|
|
152
|
-
:
|
|
148
|
+
: _b.data) || e
|
|
153
149
|
);
|
|
154
150
|
await commandLog.setStatus("fail", e).commit();
|
|
155
151
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repzo-sap-absjo",
|
|
3
3
|
"description": "repzo SAP ABS jo integration",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"jsonwebtoken": "^8.5.1",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"moment-timezone": "^0.5.34",
|
|
48
|
-
"repzo": "^1.0.
|
|
48
|
+
"repzo": "^1.0.29",
|
|
49
49
|
"uuid": "^8.3.2"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -55,13 +55,16 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
55
55
|
const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
|
|
56
56
|
let body: Service.FullInvoice.InvoiceSchema | any;
|
|
57
57
|
try {
|
|
58
|
-
|
|
58
|
+
console.log("create_invoice"); // Debug log added
|
|
59
|
+
|
|
59
60
|
await actionLog.load(action_sync_id);
|
|
60
61
|
|
|
61
62
|
body = event.body;
|
|
62
63
|
try {
|
|
63
64
|
if (body) body = JSON.parse(body);
|
|
64
|
-
} catch (e) {
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error("Error parsing event body:", e); // Debug log added
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
67
70
|
try {
|
|
@@ -73,7 +76,7 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
73
76
|
{ _id: body._id, type: "fullinvoices" }
|
|
74
77
|
);
|
|
75
78
|
} catch (e) {
|
|
76
|
-
console.error(e);
|
|
79
|
+
console.error("Error updating integration meta:", e); // Debug log added
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
await actionLog
|
|
@@ -280,7 +283,7 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
280
283
|
|
|
281
284
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
282
285
|
|
|
283
|
-
|
|
286
|
+
console.log("SAP Result:", result); // Debug log added
|
|
284
287
|
|
|
285
288
|
try {
|
|
286
289
|
await repzo.updateIntegrationMeta.create(
|
|
@@ -288,7 +291,7 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
288
291
|
{ _id: body._id, type: "fullinvoices" }
|
|
289
292
|
);
|
|
290
293
|
} catch (e) {
|
|
291
|
-
console.error(e);
|
|
294
|
+
console.error("Error updating integration meta:", e); // Debug log added
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
await actionLog
|
|
@@ -311,6 +314,10 @@ export const get_invoice_from_sap = async (
|
|
|
311
314
|
query?: { updatedAt: string; Status: string; InvoiceId: string }
|
|
312
315
|
): Promise<SAPOpenInvoice[]> => {
|
|
313
316
|
try {
|
|
317
|
+
console.log("Inside get_invoice_from_sap function"); // Debug log
|
|
318
|
+
console.log("Service End Point:", serviceEndPoint); // Debug log
|
|
319
|
+
console.log("Query:", query); // Debug log
|
|
320
|
+
|
|
314
321
|
const sap_openInvoices: SAPOpenInvoices = await _create(
|
|
315
322
|
serviceEndPoint,
|
|
316
323
|
"/OpenInvoices",
|
|
@@ -320,8 +327,12 @@ export const get_invoice_from_sap = async (
|
|
|
320
327
|
InvoiceId: query?.InvoiceId,
|
|
321
328
|
}
|
|
322
329
|
);
|
|
330
|
+
|
|
331
|
+
console.log("SAP Open Invoices:", sap_openInvoices); // Debug log
|
|
332
|
+
|
|
323
333
|
return sap_openInvoices?.OpenInvoices;
|
|
324
334
|
} catch (e: any) {
|
|
335
|
+
console.error("Error in get_invoice_from_sap:", e); // Debug log
|
|
325
336
|
throw e;
|
|
326
337
|
}
|
|
327
338
|
};
|
|
@@ -333,9 +344,21 @@ function getUniqueConcatenatedValues(
|
|
|
333
344
|
): string {
|
|
334
345
|
item.general_promotions = item.general_promotions || [];
|
|
335
346
|
item.used_promotions = item.used_promotions || [];
|
|
336
|
-
const allPromotions
|
|
347
|
+
const allPromotions: { name: string; ref?: string; [key: string]: any }[] = [
|
|
348
|
+
...item.general_promotions,
|
|
349
|
+
...item.used_promotions,
|
|
350
|
+
];
|
|
351
|
+
|
|
352
|
+
console.log("Inside getUniqueConcatenatedValues function"); // Debug log
|
|
353
|
+
console.log("Item:", item); // Debug log
|
|
354
|
+
console.log("Key:", key); // Debug log
|
|
355
|
+
console.log("Delimiter:", delimiter); // Debug log
|
|
356
|
+
|
|
337
357
|
const uniqueValues = new Set(
|
|
338
358
|
allPromotions.map((promotion) => promotion[key]).filter((value) => value)
|
|
339
359
|
);
|
|
360
|
+
|
|
361
|
+
console.log("Unique Values:", uniqueValues); // Debug log
|
|
362
|
+
|
|
340
363
|
return [...uniqueValues].join(delimiter);
|
|
341
364
|
}
|
|
@@ -62,18 +62,21 @@ export const sync_disabled_product = async (commandEvent: CommandEvent) => {
|
|
|
62
62
|
(product) => `${nameSpace}_${product.ITEMCODE}`
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
const repzo_product_per_page = await repzo.patchAction.create(
|
|
66
|
+
{
|
|
67
|
+
slug: "product",
|
|
68
|
+
readQuery: [
|
|
69
|
+
{ key: "active", value: [true], operator: "eq" },
|
|
70
|
+
{
|
|
71
|
+
key: "integration_meta.id",
|
|
72
|
+
value: sap_product_query,
|
|
73
|
+
operator: "in",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{ per_page: 50000 }
|
|
78
|
+
);
|
|
79
|
+
const repzo_products = repzo_product_per_page.data;
|
|
77
80
|
|
|
78
81
|
result.repzo_total = repzo_products?.length;
|
|
79
82
|
await commandLog
|