repzo-sap-absjo 1.0.41 → 1.0.42
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
|
-
import { _create, getUniqueConcatenatedValues } from "../util.js";
|
|
2
|
+
import { _create, set_error, getUniqueConcatenatedValues } from "../util.js";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import moment from "moment-timezone";
|
|
5
5
|
export const create_invoice = async (event, options) => {
|
|
@@ -21,7 +21,10 @@ export const create_invoice = async (event, options) => {
|
|
|
21
21
|
_r,
|
|
22
22
|
_s,
|
|
23
23
|
_t,
|
|
24
|
-
_u
|
|
24
|
+
_u,
|
|
25
|
+
_v,
|
|
26
|
+
_w,
|
|
27
|
+
_x;
|
|
25
28
|
const repzo = new Repzo(
|
|
26
29
|
(_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
|
|
27
30
|
{ env: options.env }
|
|
@@ -417,7 +420,28 @@ export const create_invoice = async (event, options) => {
|
|
|
417
420
|
`Repzo => SAP: Invoice - ${repzo_serial_number} - Treat Invoice as SalesOrder for eTax`,
|
|
418
421
|
sap_invoice
|
|
419
422
|
);
|
|
420
|
-
|
|
423
|
+
try {
|
|
424
|
+
result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
425
|
+
} catch (e) {
|
|
426
|
+
if (
|
|
427
|
+
typeof ((_v = set_error(e)) === null || _v === void 0
|
|
428
|
+
? void 0
|
|
429
|
+
: _v.message) === "string" &&
|
|
430
|
+
((_x =
|
|
431
|
+
(_w = set_error(e)) === null || _w === void 0
|
|
432
|
+
? void 0
|
|
433
|
+
: _w.message) === null || _x === void 0
|
|
434
|
+
? void 0
|
|
435
|
+
: _x.includes("this Sales Order is allready existed"))
|
|
436
|
+
) {
|
|
437
|
+
result = {
|
|
438
|
+
success: true,
|
|
439
|
+
message: `Sales Order ${repzo_serial_number} already exists`,
|
|
440
|
+
};
|
|
441
|
+
} else {
|
|
442
|
+
throw e;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
421
445
|
} else {
|
|
422
446
|
result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
423
447
|
}
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
_create,
|
|
6
6
|
_update,
|
|
7
7
|
_delete,
|
|
8
|
+
set_error,
|
|
8
9
|
getUniqueConcatenatedValues,
|
|
9
10
|
} from "../util.js";
|
|
10
11
|
import { Service } from "repzo/src/types";
|
|
@@ -336,7 +337,23 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
336
337
|
`Repzo => SAP: Invoice - ${repzo_serial_number} - Treat Invoice as SalesOrder for eTax`,
|
|
337
338
|
sap_invoice
|
|
338
339
|
);
|
|
339
|
-
|
|
340
|
+
try {
|
|
341
|
+
result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
342
|
+
} catch (e: any) {
|
|
343
|
+
if (
|
|
344
|
+
typeof set_error(e)?.message === "string" &&
|
|
345
|
+
set_error(e)?.message?.includes(
|
|
346
|
+
"this Sales Order is allready existed"
|
|
347
|
+
)
|
|
348
|
+
) {
|
|
349
|
+
result = {
|
|
350
|
+
success: true,
|
|
351
|
+
message: `Sales Order ${repzo_serial_number} already exists`,
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
throw e;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
340
357
|
} else {
|
|
341
358
|
result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
342
359
|
}
|