repzo-sap-absjo 1.0.38 → 1.0.40
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/lib/actions/create_proforma.js +42 -3
- package/lib/commands/channel.js +17 -12
- package/lib/commands/client.js +29 -24
- package/lib/commands/client_disabled.js +15 -10
- package/lib/commands/measureunit_family.js +103 -30
- package/lib/commands/payment_term.js +17 -12
- package/lib/commands/price_list.js +65 -56
- package/lib/commands/product.js +63 -54
- package/lib/commands/product_disabled.js +13 -6
- package/lib/commands/rep.js +13 -5
- package/lib/commands/warehouse.js +25 -21
- package/lib/test/commands/test.d.ts +1 -0
- package/lib/test/commands/test.js +393 -0
- package/lib/types.d.ts +61 -1
- package/package.json +3 -3
- package/src/actions/create_proforma.ts +14 -1
- package/src/commands/channel.ts +2 -2
- package/src/commands/client.ts +2 -2
- package/src/commands/client_disabled.ts +2 -2
- package/src/commands/measureunit_family.ts +35 -1
- package/src/commands/payment_term.ts +2 -2
- package/src/commands/price_list.ts +2 -2
- package/src/commands/product.ts +2 -2
- package/src/commands/product_disabled.ts +2 -2
- package/src/commands/rep.ts +7 -1
- package/src/commands/warehouse.ts +2 -2
- package/src/test/commands/test.ts +396 -0
- package/src/types.ts +57 -1
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
|
-
import { _create, getUniqueConcatenatedValues } from "../util.js";
|
|
2
|
+
import { _create, getUniqueConcatenatedValues, set_error } from "../util.js";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import moment from "moment-timezone";
|
|
5
5
|
export const create_proforma = async (event, options) => {
|
|
6
|
-
var _a,
|
|
6
|
+
var _a,
|
|
7
|
+
_b,
|
|
8
|
+
_c,
|
|
9
|
+
_d,
|
|
10
|
+
_e,
|
|
11
|
+
_f,
|
|
12
|
+
_g,
|
|
13
|
+
_h,
|
|
14
|
+
_j,
|
|
15
|
+
_k,
|
|
16
|
+
_l,
|
|
17
|
+
_m,
|
|
18
|
+
_o,
|
|
19
|
+
_p,
|
|
20
|
+
_q,
|
|
21
|
+
_r,
|
|
22
|
+
_s,
|
|
23
|
+
_t,
|
|
24
|
+
_u,
|
|
25
|
+
_v,
|
|
26
|
+
_w;
|
|
7
27
|
const repzo = new Repzo(
|
|
8
28
|
(_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
|
|
9
29
|
{ env: options.env }
|
|
@@ -318,7 +338,26 @@ export const create_proforma = async (event, options) => {
|
|
|
318
338
|
`Repzo => SAP: SalesOrder - ${repzo_serial_number}`,
|
|
319
339
|
sap_invoice
|
|
320
340
|
); // .commit();
|
|
321
|
-
|
|
341
|
+
let result;
|
|
342
|
+
try {
|
|
343
|
+
result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
344
|
+
} catch (e) {
|
|
345
|
+
if (
|
|
346
|
+
typeof ((_u = set_error(e)) === null || _u === void 0
|
|
347
|
+
? void 0
|
|
348
|
+
: _u.message) === "string" &&
|
|
349
|
+
((_w =
|
|
350
|
+
(_v = set_error(e)) === null || _v === void 0
|
|
351
|
+
? void 0
|
|
352
|
+
: _v.message) === null || _w === void 0
|
|
353
|
+
? void 0
|
|
354
|
+
: _w.includes("this Sales Order is allready existed"))
|
|
355
|
+
) {
|
|
356
|
+
result = { success: true, message: "Sales Order already exists" };
|
|
357
|
+
} else {
|
|
358
|
+
throw e;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
322
361
|
// console.log(result);
|
|
323
362
|
try {
|
|
324
363
|
await repzo.updateIntegrationMeta.create(
|
package/lib/commands/channel.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
set_error,
|
|
7
7
|
} from "../util.js";
|
|
8
8
|
export const sync_channel = async (commandEvent) => {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -40,7 +40,10 @@ export const sync_channel = async (commandEvent) => {
|
|
|
40
40
|
const sap_clients = await get_sap_clients(
|
|
41
41
|
commandEvent.app.formData.sapHostUrl,
|
|
42
42
|
{
|
|
43
|
-
updateAt:
|
|
43
|
+
updateAt:
|
|
44
|
+
(_b = commandEvent.app.options_formData) === null || _b === void 0
|
|
45
|
+
? void 0
|
|
46
|
+
: _b[bench_time_key],
|
|
44
47
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
45
48
|
}
|
|
46
49
|
);
|
|
@@ -59,27 +62,29 @@ export const sync_channel = async (commandEvent) => {
|
|
|
59
62
|
await commandLog
|
|
60
63
|
.addDetail(
|
|
61
64
|
`${result.sap_total} Client Channels in SAP changed since ${
|
|
62
|
-
commandEvent.app.options_formData
|
|
65
|
+
((_c = commandEvent.app.options_formData) === null || _c === void 0
|
|
66
|
+
? void 0
|
|
67
|
+
: _c[bench_time_key]) || "ever"
|
|
63
68
|
}`
|
|
64
69
|
)
|
|
65
70
|
.commit();
|
|
66
71
|
const repzo_channels = await repzo.channel.find({ per_page: 50000 });
|
|
67
72
|
result.repzo_total =
|
|
68
|
-
(
|
|
73
|
+
(_d =
|
|
69
74
|
repzo_channels === null || repzo_channels === void 0
|
|
70
75
|
? void 0
|
|
71
|
-
: repzo_channels.data) === null ||
|
|
76
|
+
: repzo_channels.data) === null || _d === void 0
|
|
72
77
|
? void 0
|
|
73
|
-
:
|
|
78
|
+
: _d.length;
|
|
74
79
|
await commandLog
|
|
75
80
|
.addDetail(
|
|
76
81
|
`${
|
|
77
|
-
(
|
|
82
|
+
(_e =
|
|
78
83
|
repzo_channels === null || repzo_channels === void 0
|
|
79
84
|
? void 0
|
|
80
|
-
: repzo_channels.data) === null ||
|
|
85
|
+
: repzo_channels.data) === null || _e === void 0
|
|
81
86
|
? void 0
|
|
82
|
-
:
|
|
87
|
+
: _e.length
|
|
83
88
|
} Client Channels in Repzo`
|
|
84
89
|
)
|
|
85
90
|
.commit();
|
|
@@ -178,10 +183,10 @@ export const sync_channel = async (commandEvent) => {
|
|
|
178
183
|
} catch (e) {
|
|
179
184
|
//@ts-ignore
|
|
180
185
|
console.error(
|
|
181
|
-
((
|
|
182
|
-
|
|
186
|
+
((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
187
|
+
_f === void 0
|
|
183
188
|
? void 0
|
|
184
|
-
:
|
|
189
|
+
: _f.data) || e
|
|
185
190
|
);
|
|
186
191
|
await commandLog.setStatus("fail", e).commit();
|
|
187
192
|
throw e;
|
package/lib/commands/client.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
set_error,
|
|
7
7
|
} from "../util.js";
|
|
8
8
|
export const sync_client = async (commandEvent) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -39,7 +39,10 @@ export const sync_client = async (commandEvent) => {
|
|
|
39
39
|
const sap_clients = await get_sap_clients(
|
|
40
40
|
commandEvent.app.formData.sapHostUrl,
|
|
41
41
|
{
|
|
42
|
-
updateAt:
|
|
42
|
+
updateAt:
|
|
43
|
+
(_b = commandEvent.app.options_formData) === null || _b === void 0
|
|
44
|
+
? void 0
|
|
45
|
+
: _b[bench_time_key],
|
|
43
46
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
44
47
|
}
|
|
45
48
|
);
|
|
@@ -50,7 +53,9 @@ export const sync_client = async (commandEvent) => {
|
|
|
50
53
|
await commandLog
|
|
51
54
|
.addDetail(
|
|
52
55
|
`${result.sap_total} Customers in SAP changed since ${
|
|
53
|
-
commandEvent.app.options_formData
|
|
56
|
+
((_c = commandEvent.app.options_formData) === null || _c === void 0
|
|
57
|
+
? void 0
|
|
58
|
+
: _c[bench_time_key]) || "ever"
|
|
54
59
|
}`
|
|
55
60
|
)
|
|
56
61
|
.commit();
|
|
@@ -89,21 +94,21 @@ export const sync_client = async (commandEvent) => {
|
|
|
89
94
|
project: ["_id", "integration_meta"],
|
|
90
95
|
});
|
|
91
96
|
result.repzo_total =
|
|
92
|
-
(
|
|
97
|
+
(_d =
|
|
93
98
|
repzo_clients === null || repzo_clients === void 0
|
|
94
99
|
? void 0
|
|
95
|
-
: repzo_clients.data) === null ||
|
|
100
|
+
: repzo_clients.data) === null || _d === void 0
|
|
96
101
|
? void 0
|
|
97
|
-
:
|
|
102
|
+
: _d.length;
|
|
98
103
|
await commandLog
|
|
99
104
|
.addDetail(
|
|
100
105
|
`${
|
|
101
|
-
(
|
|
106
|
+
(_e =
|
|
102
107
|
repzo_clients === null || repzo_clients === void 0
|
|
103
108
|
? void 0
|
|
104
|
-
: repzo_clients.data) === null ||
|
|
109
|
+
: repzo_clients.data) === null || _e === void 0
|
|
105
110
|
? void 0
|
|
106
|
-
:
|
|
111
|
+
: _e.length
|
|
107
112
|
} Clients in Repzo`
|
|
108
113
|
)
|
|
109
114
|
.commit();
|
|
@@ -125,12 +130,12 @@ export const sync_client = async (commandEvent) => {
|
|
|
125
130
|
);
|
|
126
131
|
});
|
|
127
132
|
const tag =
|
|
128
|
-
(
|
|
133
|
+
(_f =
|
|
129
134
|
repzo_tags === null || repzo_tags === void 0
|
|
130
135
|
? void 0
|
|
131
|
-
: repzo_tags.data) === null ||
|
|
136
|
+
: repzo_tags.data) === null || _f === void 0
|
|
132
137
|
? void 0
|
|
133
|
-
:
|
|
138
|
+
: _f.find((tag) => {
|
|
134
139
|
var _a;
|
|
135
140
|
return (
|
|
136
141
|
((_a = tag.integration_meta) === null || _a === void 0
|
|
@@ -139,12 +144,12 @@ export const sync_client = async (commandEvent) => {
|
|
|
139
144
|
);
|
|
140
145
|
});
|
|
141
146
|
const channel =
|
|
142
|
-
(
|
|
147
|
+
(_g =
|
|
143
148
|
repzo_channels === null || repzo_channels === void 0
|
|
144
149
|
? void 0
|
|
145
|
-
: repzo_channels.data) === null ||
|
|
150
|
+
: repzo_channels.data) === null || _g === void 0
|
|
146
151
|
? void 0
|
|
147
|
-
:
|
|
152
|
+
: _g.find((channel) => {
|
|
148
153
|
var _a;
|
|
149
154
|
return (
|
|
150
155
|
((_a = channel.integration_meta) === null || _a === void 0
|
|
@@ -153,12 +158,12 @@ export const sync_client = async (commandEvent) => {
|
|
|
153
158
|
);
|
|
154
159
|
});
|
|
155
160
|
const paymentTerm =
|
|
156
|
-
(
|
|
161
|
+
(_h =
|
|
157
162
|
repzo_payment_terms === null || repzo_payment_terms === void 0
|
|
158
163
|
? void 0
|
|
159
|
-
: repzo_payment_terms.data) === null ||
|
|
164
|
+
: repzo_payment_terms.data) === null || _h === void 0
|
|
160
165
|
? void 0
|
|
161
|
-
:
|
|
166
|
+
: _h.find((paymentTerm) => {
|
|
162
167
|
var _a;
|
|
163
168
|
return (
|
|
164
169
|
((_a = paymentTerm.integration_meta) === null || _a === void 0
|
|
@@ -167,12 +172,12 @@ export const sync_client = async (commandEvent) => {
|
|
|
167
172
|
);
|
|
168
173
|
});
|
|
169
174
|
const priceList =
|
|
170
|
-
(
|
|
175
|
+
(_j =
|
|
171
176
|
repzo_price_lists === null || repzo_price_lists === void 0
|
|
172
177
|
? void 0
|
|
173
|
-
: repzo_price_lists.data) === null ||
|
|
178
|
+
: repzo_price_lists.data) === null || _j === void 0
|
|
174
179
|
? void 0
|
|
175
|
-
:
|
|
180
|
+
: _j.find((pricelist) => {
|
|
176
181
|
var _a;
|
|
177
182
|
return (
|
|
178
183
|
((_a = pricelist.integration_meta) === null || _a === void 0
|
|
@@ -313,10 +318,10 @@ export const sync_client = async (commandEvent) => {
|
|
|
313
318
|
} catch (e) {
|
|
314
319
|
//@ts-ignore
|
|
315
320
|
console.error(
|
|
316
|
-
((
|
|
317
|
-
|
|
321
|
+
((_k = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
322
|
+
_k === void 0
|
|
318
323
|
? void 0
|
|
319
|
-
:
|
|
324
|
+
: _k.data) || e
|
|
320
325
|
);
|
|
321
326
|
await commandLog.setStatus("fail", e).commit();
|
|
322
327
|
throw e;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
set_error,
|
|
7
7
|
} from "../util.js";
|
|
8
8
|
export const sync_disabled_client = async (commandEvent) => {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -40,7 +40,10 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
40
40
|
const sap_disabled_clients = await get_sap_clients(
|
|
41
41
|
commandEvent.app.formData.sapHostUrl,
|
|
42
42
|
{
|
|
43
|
-
updateAt:
|
|
43
|
+
updateAt:
|
|
44
|
+
(_b = commandEvent.app.options_formData) === null || _b === void 0
|
|
45
|
+
? void 0
|
|
46
|
+
: _b[bench_time_key],
|
|
44
47
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
45
48
|
}
|
|
46
49
|
);
|
|
@@ -51,7 +54,9 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
51
54
|
await commandLog
|
|
52
55
|
.addDetail(
|
|
53
56
|
`${result.sap_total} Disabled Clients in SAP changed since ${
|
|
54
|
-
commandEvent.app.options_formData
|
|
57
|
+
((_c = commandEvent.app.options_formData) === null || _c === void 0
|
|
58
|
+
? void 0
|
|
59
|
+
: _c[bench_time_key]) || "ever"
|
|
55
60
|
}`
|
|
56
61
|
)
|
|
57
62
|
.commit();
|
|
@@ -76,9 +81,9 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
76
81
|
{ per_page: 50000, project: ["_id", "integration_meta"] }
|
|
77
82
|
);
|
|
78
83
|
result.repzo_total =
|
|
79
|
-
(
|
|
84
|
+
(_d = repzo_disabled_clients.data) === null || _d === void 0
|
|
80
85
|
? void 0
|
|
81
|
-
:
|
|
86
|
+
: _d.length;
|
|
82
87
|
await commandLog
|
|
83
88
|
.addDetail(`${result.repzo_total} Matched Active Clients in Repzo`)
|
|
84
89
|
.commit();
|
|
@@ -92,9 +97,9 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
92
97
|
) {
|
|
93
98
|
const sap_client = sap_disabled_clients[i];
|
|
94
99
|
const repzo_client =
|
|
95
|
-
(
|
|
100
|
+
(_e = repzo_disabled_clients.data) === null || _e === void 0
|
|
96
101
|
? void 0
|
|
97
|
-
:
|
|
102
|
+
: _e.find((r_client) => {
|
|
98
103
|
var _a;
|
|
99
104
|
return (
|
|
100
105
|
((_a = r_client.integration_meta) === null || _a === void 0
|
|
@@ -142,10 +147,10 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
142
147
|
} catch (e) {
|
|
143
148
|
//@ts-ignore
|
|
144
149
|
console.error(
|
|
145
|
-
((
|
|
146
|
-
|
|
150
|
+
((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
151
|
+
_f === void 0
|
|
147
152
|
? void 0
|
|
148
|
-
:
|
|
153
|
+
: _f.data) || e
|
|
149
154
|
);
|
|
150
155
|
await commandLog.setStatus("fail", e).commit();
|
|
151
156
|
throw e;
|
|
@@ -3,7 +3,7 @@ import _ from "lodash";
|
|
|
3
3
|
import { update_bench_time, set_error } from "../util.js";
|
|
4
4
|
import { get_sap_UoMs } from "./measureunit.js";
|
|
5
5
|
export const sync_measureunit_family = async (commandEvent) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
7
7
|
const repzo = new Repzo(
|
|
8
8
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
9
9
|
? void 0
|
|
@@ -19,6 +19,34 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
19
19
|
);
|
|
20
20
|
try {
|
|
21
21
|
// console.log("sync_measureunit_family");
|
|
22
|
+
if (
|
|
23
|
+
(_b = commandEvent.app.formData) === null || _b === void 0
|
|
24
|
+
? void 0
|
|
25
|
+
: _b.measureUnitInjections
|
|
26
|
+
) {
|
|
27
|
+
try {
|
|
28
|
+
if (
|
|
29
|
+
typeof ((_c = commandEvent.app.formData) === null || _c === void 0
|
|
30
|
+
? void 0
|
|
31
|
+
: _c.measureUnitInjections) == "string"
|
|
32
|
+
)
|
|
33
|
+
commandEvent.app.formData.measureUnitInjections = JSON.parse(
|
|
34
|
+
commandEvent.app.formData.measureUnitInjections
|
|
35
|
+
);
|
|
36
|
+
if (
|
|
37
|
+
!Array.isArray(
|
|
38
|
+
(_d = commandEvent.app.formData) === null || _d === void 0
|
|
39
|
+
? void 0
|
|
40
|
+
: _d.measureUnitInjections
|
|
41
|
+
)
|
|
42
|
+
) {
|
|
43
|
+
delete commandEvent.app.formData.measureUnitInjections;
|
|
44
|
+
}
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(e);
|
|
47
|
+
delete commandEvent.app.formData.measureUnitInjections;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
22
50
|
const new_bench_time = new Date().toISOString();
|
|
23
51
|
const bench_time_key = "bench_time_measureunit_family";
|
|
24
52
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -50,58 +78,58 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
50
78
|
per_page: 50000,
|
|
51
79
|
});
|
|
52
80
|
result.repzo_UoM_total =
|
|
53
|
-
(
|
|
81
|
+
(_e =
|
|
54
82
|
repzo_UoMs === null || repzo_UoMs === void 0
|
|
55
83
|
? void 0
|
|
56
|
-
: repzo_UoMs.data) === null ||
|
|
84
|
+
: repzo_UoMs.data) === null || _e === void 0
|
|
57
85
|
? void 0
|
|
58
|
-
:
|
|
86
|
+
: _e.length;
|
|
59
87
|
await commandLog
|
|
60
88
|
.addDetail(
|
|
61
89
|
`${
|
|
62
|
-
(
|
|
90
|
+
(_f =
|
|
63
91
|
repzo_UoMs === null || repzo_UoMs === void 0
|
|
64
92
|
? void 0
|
|
65
|
-
: repzo_UoMs.data) === null ||
|
|
93
|
+
: repzo_UoMs.data) === null || _f === void 0
|
|
66
94
|
? void 0
|
|
67
|
-
:
|
|
95
|
+
: _f.length
|
|
68
96
|
} Measure Units in Repzo`
|
|
69
97
|
)
|
|
70
98
|
.commit();
|
|
71
99
|
if (
|
|
72
|
-
!((
|
|
100
|
+
!((_g =
|
|
73
101
|
repzo_UoMs === null || repzo_UoMs === void 0
|
|
74
102
|
? void 0
|
|
75
|
-
: repzo_UoMs.data) === null ||
|
|
103
|
+
: repzo_UoMs.data) === null || _g === void 0
|
|
76
104
|
? void 0
|
|
77
|
-
:
|
|
105
|
+
: _g.length)
|
|
78
106
|
) {
|
|
79
107
|
throw "measure units are not found or the nameSpace has more than one";
|
|
80
108
|
}
|
|
81
109
|
repzo_UoMs.data =
|
|
82
|
-
(
|
|
110
|
+
(_h = repzo_UoMs.data) === null || _h === void 0
|
|
83
111
|
? void 0
|
|
84
|
-
:
|
|
112
|
+
: _h.filter((UoM) => UoM.integration_meta);
|
|
85
113
|
const repzo_UoMs_family = await repzo.measureunitFamily.find({
|
|
86
114
|
disabled: false,
|
|
87
115
|
per_page: 50000,
|
|
88
116
|
});
|
|
89
117
|
result.repzo_total =
|
|
90
|
-
(
|
|
118
|
+
(_j =
|
|
91
119
|
repzo_UoMs_family === null || repzo_UoMs_family === void 0
|
|
92
120
|
? void 0
|
|
93
|
-
: repzo_UoMs_family.data) === null ||
|
|
121
|
+
: repzo_UoMs_family.data) === null || _j === void 0
|
|
94
122
|
? void 0
|
|
95
|
-
:
|
|
123
|
+
: _j.length;
|
|
96
124
|
await commandLog
|
|
97
125
|
.addDetail(
|
|
98
126
|
`${
|
|
99
|
-
(
|
|
127
|
+
(_k =
|
|
100
128
|
repzo_UoMs_family === null || repzo_UoMs_family === void 0
|
|
101
129
|
? void 0
|
|
102
|
-
: repzo_UoMs_family.data) === null ||
|
|
130
|
+
: repzo_UoMs_family.data) === null || _k === void 0
|
|
103
131
|
? void 0
|
|
104
|
-
:
|
|
132
|
+
: _k.length
|
|
105
133
|
} Measure Units Family in Repzo`
|
|
106
134
|
)
|
|
107
135
|
.commit();
|
|
@@ -118,9 +146,9 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
118
146
|
sap_unique_family[key][uom_key] = 1;
|
|
119
147
|
}
|
|
120
148
|
result.sap_total =
|
|
121
|
-
(
|
|
149
|
+
(_l = Object.keys(sap_unique_family)) === null || _l === void 0
|
|
122
150
|
? void 0
|
|
123
|
-
:
|
|
151
|
+
: _l.length;
|
|
124
152
|
await commandLog
|
|
125
153
|
.addDetail(`${result.sap_total} Measure Units Family in SAP`)
|
|
126
154
|
.commit();
|
|
@@ -134,7 +162,7 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
134
162
|
: _a.id) == `${nameSpace}_${key}`
|
|
135
163
|
);
|
|
136
164
|
});
|
|
137
|
-
|
|
165
|
+
const measureunits = [];
|
|
138
166
|
Object.keys(sap_family).forEach((unit) => {
|
|
139
167
|
var _a;
|
|
140
168
|
{
|
|
@@ -160,6 +188,51 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
160
188
|
}
|
|
161
189
|
}
|
|
162
190
|
});
|
|
191
|
+
if (
|
|
192
|
+
(_o =
|
|
193
|
+
(_m = commandEvent.app.formData) === null || _m === void 0
|
|
194
|
+
? void 0
|
|
195
|
+
: _m.measureUnitInjections) === null || _o === void 0
|
|
196
|
+
? void 0
|
|
197
|
+
: _o.length
|
|
198
|
+
) {
|
|
199
|
+
const related_uom_s =
|
|
200
|
+
commandEvent.app.formData.measureUnitInjections.filter(
|
|
201
|
+
(doc) =>
|
|
202
|
+
(doc === null || doc === void 0 ? void 0 : doc.itemCode) == key
|
|
203
|
+
);
|
|
204
|
+
related_uom_s.forEach((related_uom) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const UoM =
|
|
207
|
+
(_a =
|
|
208
|
+
repzo_UoMs === null || repzo_UoMs === void 0
|
|
209
|
+
? void 0
|
|
210
|
+
: repzo_UoMs.data) === null || _a === void 0
|
|
211
|
+
? void 0
|
|
212
|
+
: _a.find((repzo_uom) => {
|
|
213
|
+
var _a;
|
|
214
|
+
return (
|
|
215
|
+
(repzo_uom === null || repzo_uom === void 0
|
|
216
|
+
? void 0
|
|
217
|
+
: repzo_uom.name) ==
|
|
218
|
+
(related_uom === null || related_uom === void 0
|
|
219
|
+
? void 0
|
|
220
|
+
: related_uom.uom) &&
|
|
221
|
+
((_a =
|
|
222
|
+
repzo_uom === null || repzo_uom === void 0
|
|
223
|
+
? void 0
|
|
224
|
+
: repzo_uom.integration_meta) === null || _a === void 0
|
|
225
|
+
? void 0
|
|
226
|
+
: _a.ITEMCODE) == key
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
if (UoM) {
|
|
230
|
+
if (!measureunits.includes(UoM._id.toString())) {
|
|
231
|
+
measureunits.push(UoM._id.toString());
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
163
236
|
const body = {
|
|
164
237
|
name: key,
|
|
165
238
|
disabled: false,
|
|
@@ -188,20 +261,20 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
188
261
|
} else {
|
|
189
262
|
if (
|
|
190
263
|
repzo_family.name == body.name &&
|
|
191
|
-
!((
|
|
192
|
-
((
|
|
264
|
+
!((_q = _.xor(
|
|
265
|
+
((_p =
|
|
193
266
|
repzo_family === null || repzo_family === void 0
|
|
194
267
|
? void 0
|
|
195
|
-
: repzo_family.measureunits) === null ||
|
|
268
|
+
: repzo_family.measureunits) === null || _p === void 0
|
|
196
269
|
? void 0
|
|
197
|
-
:
|
|
270
|
+
: _p.map((m) =>
|
|
198
271
|
m === null || m === void 0 ? void 0 : m.toString()
|
|
199
272
|
)) || [],
|
|
200
273
|
(body === null || body === void 0 ? void 0 : body.measureunits) ||
|
|
201
274
|
[]
|
|
202
|
-
)) === null ||
|
|
275
|
+
)) === null || _q === void 0
|
|
203
276
|
? void 0
|
|
204
|
-
:
|
|
277
|
+
: _q.length)
|
|
205
278
|
) {
|
|
206
279
|
continue;
|
|
207
280
|
}
|
|
@@ -249,10 +322,10 @@ export const sync_measureunit_family = async (commandEvent) => {
|
|
|
249
322
|
} catch (e) {
|
|
250
323
|
//@ts-ignore
|
|
251
324
|
console.error(
|
|
252
|
-
((
|
|
253
|
-
|
|
325
|
+
((_r = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
326
|
+
_r === void 0
|
|
254
327
|
? void 0
|
|
255
|
-
:
|
|
328
|
+
: _r.data) || e
|
|
256
329
|
);
|
|
257
330
|
await commandLog.setStatus("fail", e).commit();
|
|
258
331
|
throw e;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
set_error,
|
|
7
7
|
} from "../util.js";
|
|
8
8
|
export const sync_payment_term = async (commandEvent) => {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -40,7 +40,10 @@ export const sync_payment_term = async (commandEvent) => {
|
|
|
40
40
|
const sap_clients = await get_sap_clients(
|
|
41
41
|
commandEvent.app.formData.sapHostUrl,
|
|
42
42
|
{
|
|
43
|
-
updateAt:
|
|
43
|
+
updateAt:
|
|
44
|
+
(_b = commandEvent.app.options_formData) === null || _b === void 0
|
|
45
|
+
? void 0
|
|
46
|
+
: _b[bench_time_key],
|
|
44
47
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
45
48
|
}
|
|
46
49
|
);
|
|
@@ -59,7 +62,9 @@ export const sync_payment_term = async (commandEvent) => {
|
|
|
59
62
|
await commandLog
|
|
60
63
|
.addDetail(
|
|
61
64
|
`${result.sap_total} Payments Term in SAP changed since ${
|
|
62
|
-
commandEvent.app.options_formData
|
|
65
|
+
((_c = commandEvent.app.options_formData) === null || _c === void 0
|
|
66
|
+
? void 0
|
|
67
|
+
: _c[bench_time_key]) || "ever"
|
|
63
68
|
}`
|
|
64
69
|
)
|
|
65
70
|
.commit();
|
|
@@ -67,21 +72,21 @@ export const sync_payment_term = async (commandEvent) => {
|
|
|
67
72
|
per_page: 50000,
|
|
68
73
|
});
|
|
69
74
|
result.repzo_total =
|
|
70
|
-
(
|
|
75
|
+
(_d =
|
|
71
76
|
repzo_payment_terms === null || repzo_payment_terms === void 0
|
|
72
77
|
? void 0
|
|
73
|
-
: repzo_payment_terms.data) === null ||
|
|
78
|
+
: repzo_payment_terms.data) === null || _d === void 0
|
|
74
79
|
? void 0
|
|
75
|
-
:
|
|
80
|
+
: _d.length;
|
|
76
81
|
await commandLog
|
|
77
82
|
.addDetail(
|
|
78
83
|
`${
|
|
79
|
-
(
|
|
84
|
+
(_e =
|
|
80
85
|
repzo_payment_terms === null || repzo_payment_terms === void 0
|
|
81
86
|
? void 0
|
|
82
|
-
: repzo_payment_terms.data) === null ||
|
|
87
|
+
: repzo_payment_terms.data) === null || _e === void 0
|
|
83
88
|
? void 0
|
|
84
|
-
:
|
|
89
|
+
: _e.length
|
|
85
90
|
} Payments Term in Repzo`
|
|
86
91
|
)
|
|
87
92
|
.commit();
|
|
@@ -182,10 +187,10 @@ export const sync_payment_term = async (commandEvent) => {
|
|
|
182
187
|
} catch (e) {
|
|
183
188
|
//@ts-ignore
|
|
184
189
|
console.error(
|
|
185
|
-
((
|
|
186
|
-
|
|
190
|
+
((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
191
|
+
_f === void 0
|
|
187
192
|
? void 0
|
|
188
|
-
:
|
|
193
|
+
: _f.data) || e
|
|
189
194
|
);
|
|
190
195
|
await commandLog.setStatus("fail", e).commit();
|
|
191
196
|
throw e;
|