repzo-sap-absjo 1.0.8 → 1.0.9
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_invoice.d.ts +19 -13
- package/lib/actions/create_invoice.js +363 -214
- package/lib/actions/create_payment.d.ts +4 -1
- package/lib/actions/create_payment.js +200 -125
- package/lib/actions/create_proforma.d.ts +4 -1
- package/lib/actions/create_proforma.js +290 -165
- package/lib/actions/create_return_invoice.d.ts +4 -1
- package/lib/actions/create_return_invoice.js +321 -177
- package/lib/actions/create_transfer.d.ts +4 -1
- package/lib/actions/create_transfer.js +220 -143
- package/lib/actions/index.js +23 -15
- package/lib/commands/adjust_inventory.d.ts +4 -2
- package/lib/commands/adjust_inventory.js +290 -160
- package/lib/commands/bank.d.ts +4 -2
- package/lib/commands/bank.js +279 -157
- package/lib/commands/basic.js +66 -47
- package/lib/commands/category.d.ts +3 -1
- package/lib/commands/category.js +178 -104
- package/lib/commands/channel.d.ts +3 -1
- package/lib/commands/channel.js +198 -117
- package/lib/commands/client.d.ts +34 -32
- package/lib/commands/client.js +404 -244
- package/lib/commands/client_disabled.d.ts +3 -1
- package/lib/commands/client_disabled.js +163 -94
- package/lib/commands/index.d.ts +15 -11
- package/lib/commands/index.js +60 -60
- package/lib/commands/join.js +192 -66
- package/lib/commands/measureunit.d.ts +19 -14
- package/lib/commands/measureunit.js +289 -191
- package/lib/commands/measureunit_family.d.ts +10 -8
- package/lib/commands/measureunit_family.js +250 -138
- package/lib/commands/payment_term.d.ts +3 -1
- package/lib/commands/payment_term.js +202 -123
- package/lib/commands/price_list.d.ts +15 -15
- package/lib/commands/price_list.js +612 -326
- package/lib/commands/product.d.ts +32 -30
- package/lib/commands/product.js +425 -243
- package/lib/commands/product_disabled.d.ts +3 -1
- package/lib/commands/product_disabled.js +164 -94
- package/lib/commands/rep.js +221 -141
- package/lib/commands/tag.js +174 -109
- package/lib/commands/tax.js +177 -112
- package/lib/commands/warehouse.d.ts +3 -1
- package/lib/commands/warehouse.js +207 -119
- package/lib/index.d.ts +21 -12
- package/lib/test/actions/create_invoice.js +193 -188
- package/lib/test/actions/create_payment.js +112 -107
- package/lib/test/actions/create_proforma.js +220 -216
- package/lib/test/actions/create_return_invoice.js +205 -200
- package/lib/test/actions/create_transfer.js +120 -115
- package/lib/test/commands/adjust_inventory.js +90 -90
- package/lib/test/commands/bank.js +90 -90
- package/lib/test/commands/basic.js +328 -327
- package/lib/test/commands/category.js +90 -90
- package/lib/test/commands/channel.js +90 -90
- package/lib/test/commands/client.js +355 -353
- package/lib/test/commands/client_disabled.js +90 -90
- package/lib/test/commands/join.js +328 -327
- package/lib/test/commands/measureunit.js +90 -90
- package/lib/test/commands/measureunit_family.js +90 -90
- package/lib/test/commands/payment_term.js +90 -90
- package/lib/test/commands/price_list.js +337 -334
- package/lib/test/commands/product.js +90 -90
- package/lib/test/commands/product_disabled.js +90 -90
- package/lib/test/commands/rep.js +346 -344
- package/lib/test/commands/tag.js +90 -90
- package/lib/test/commands/tax.js +90 -90
- package/lib/test/commands/warehouse.js +90 -90
- package/lib/types.d.ts +83 -60
- package/lib/util.d.ts +70 -19
- package/lib/util.js +170 -144
- package/package.json +1 -1
- package/src/actions/create_invoice.ts +4 -13
- package/src/actions/create_payment.ts +4 -13
- package/src/actions/create_proforma.ts +28 -40
- package/src/actions/create_return_invoice.ts +4 -16
- package/src/actions/create_transfer.ts +24 -36
package/lib/commands/category.js
CHANGED
|
@@ -1,112 +1,186 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
|
-
import { _create, update_bench_time, set_error
|
|
2
|
+
import { _create, update_bench_time, set_error } from "../util.js";
|
|
3
3
|
export const sync_category = async (commandEvent) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5
|
+
const repzo = new Repzo(
|
|
6
|
+
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
7
|
+
? void 0
|
|
8
|
+
: _a.repzoApiKey,
|
|
9
|
+
{
|
|
10
|
+
env: commandEvent.env,
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
const commandLog = new Repzo.CommandLog(
|
|
14
|
+
repzo,
|
|
15
|
+
commandEvent.app,
|
|
16
|
+
commandEvent.command
|
|
17
|
+
);
|
|
18
|
+
try {
|
|
19
|
+
// console.log("sync_category");
|
|
20
|
+
const new_bench_time = new Date().toISOString();
|
|
21
|
+
const bench_time_key = "bench_time_category";
|
|
22
|
+
await commandLog.load(commandEvent.sync_id);
|
|
23
|
+
await commandLog
|
|
24
|
+
.addDetail("Repzo SAP: Started Syncing Product Categories")
|
|
25
|
+
.commit();
|
|
26
|
+
const nameSpace = commandEvent.nameSpace.join("_");
|
|
27
|
+
const result = {
|
|
28
|
+
sap_total: 0,
|
|
29
|
+
repzo_total: 0,
|
|
30
|
+
created: 0,
|
|
31
|
+
updated: 0,
|
|
32
|
+
failed: 0,
|
|
33
|
+
};
|
|
34
|
+
const failed_docs_report = [];
|
|
35
|
+
const sap_categories = await get_sap_categories(
|
|
36
|
+
commandEvent.app.formData.sapHostUrl,
|
|
37
|
+
{}
|
|
38
|
+
);
|
|
39
|
+
result.sap_total =
|
|
40
|
+
sap_categories === null || sap_categories === void 0
|
|
41
|
+
? void 0
|
|
42
|
+
: sap_categories.length;
|
|
43
|
+
await commandLog
|
|
44
|
+
.addDetail(`${result.sap_total} Item Groups in SAP`)
|
|
45
|
+
.commit();
|
|
46
|
+
const repzo_categories = await repzo.category.find({
|
|
47
|
+
per_page: 50000,
|
|
7
48
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else {
|
|
64
|
-
if (((_d = repzo_category === null || repzo_category === void 0 ? void 0 : repzo_category.integration_meta) === null || _d === void 0 ? void 0 : _d.id) == ((_e = body === null || body === void 0 ? void 0 : body.integration_meta) === null || _e === void 0 ? void 0 : _e.id) &&
|
|
65
|
-
(repzo_category === null || repzo_category === void 0 ? void 0 : repzo_category.name) == (body === null || body === void 0 ? void 0 : body.name)) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
// Update
|
|
69
|
-
try {
|
|
70
|
-
const updated_category = await repzo.category.update(repzo_category._id, body);
|
|
71
|
-
result.updated++;
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
// console.log(
|
|
75
|
-
// "Update Product Category Failed >> ",
|
|
76
|
-
// e?.response?.data,
|
|
77
|
-
// body
|
|
78
|
-
// );
|
|
79
|
-
failed_docs_report.push({
|
|
80
|
-
method: "update",
|
|
81
|
-
doc_id: repzo_category === null || repzo_category === void 0 ? void 0 : repzo_category._id,
|
|
82
|
-
doc: body,
|
|
83
|
-
error_message: set_error(e),
|
|
84
|
-
});
|
|
85
|
-
result.failed++;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
49
|
+
result.repzo_total =
|
|
50
|
+
(_b =
|
|
51
|
+
repzo_categories === null || repzo_categories === void 0
|
|
52
|
+
? void 0
|
|
53
|
+
: repzo_categories.data) === null || _b === void 0
|
|
54
|
+
? void 0
|
|
55
|
+
: _b.length;
|
|
56
|
+
await commandLog
|
|
57
|
+
.addDetail(
|
|
58
|
+
`${
|
|
59
|
+
(_c =
|
|
60
|
+
repzo_categories === null || repzo_categories === void 0
|
|
61
|
+
? void 0
|
|
62
|
+
: repzo_categories.data) === null || _c === void 0
|
|
63
|
+
? void 0
|
|
64
|
+
: _c.length
|
|
65
|
+
} Product Category in Repzo`
|
|
66
|
+
)
|
|
67
|
+
.commit();
|
|
68
|
+
for (
|
|
69
|
+
let i = 0;
|
|
70
|
+
i <
|
|
71
|
+
(sap_categories === null || sap_categories === void 0
|
|
72
|
+
? void 0
|
|
73
|
+
: sap_categories.length);
|
|
74
|
+
i++
|
|
75
|
+
) {
|
|
76
|
+
const sap_category = sap_categories[i];
|
|
77
|
+
const repzo_category = repzo_categories.data.find((r_cat) => {
|
|
78
|
+
var _a;
|
|
79
|
+
return (
|
|
80
|
+
((_a = r_cat.integration_meta) === null || _a === void 0
|
|
81
|
+
? void 0
|
|
82
|
+
: _a.id) == `${nameSpace}_${sap_category.GROUPCODE}`
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
const body = {
|
|
86
|
+
name: sap_category.GROUPDESC,
|
|
87
|
+
disabled: false,
|
|
88
|
+
integration_meta: { id: `${nameSpace}_${sap_category.GROUPCODE}` },
|
|
89
|
+
company_namespace: [nameSpace],
|
|
90
|
+
};
|
|
91
|
+
if (!repzo_category) {
|
|
92
|
+
// Create
|
|
93
|
+
try {
|
|
94
|
+
const created_category = await repzo.category.create(body);
|
|
95
|
+
result.created++;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
// console.log("Create Product Category Failed >> ", e?.response, body);
|
|
98
|
+
failed_docs_report.push({
|
|
99
|
+
method: "create",
|
|
100
|
+
doc: body,
|
|
101
|
+
error_message: set_error(e),
|
|
102
|
+
});
|
|
103
|
+
result.failed++;
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
} else {
|
|
106
|
+
if (
|
|
107
|
+
((_d =
|
|
108
|
+
repzo_category === null || repzo_category === void 0
|
|
109
|
+
? void 0
|
|
110
|
+
: repzo_category.integration_meta) === null || _d === void 0
|
|
111
|
+
? void 0
|
|
112
|
+
: _d.id) ==
|
|
113
|
+
((_e =
|
|
114
|
+
body === null || body === void 0
|
|
115
|
+
? void 0
|
|
116
|
+
: body.integration_meta) === null || _e === void 0
|
|
117
|
+
? void 0
|
|
118
|
+
: _e.id) &&
|
|
119
|
+
(repzo_category === null || repzo_category === void 0
|
|
120
|
+
? void 0
|
|
121
|
+
: repzo_category.name) ==
|
|
122
|
+
(body === null || body === void 0 ? void 0 : body.name)
|
|
123
|
+
) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
// Update
|
|
127
|
+
try {
|
|
128
|
+
const updated_category = await repzo.category.update(
|
|
129
|
+
repzo_category._id,
|
|
130
|
+
body
|
|
131
|
+
);
|
|
132
|
+
result.updated++;
|
|
133
|
+
} catch (e) {
|
|
134
|
+
// console.log(
|
|
135
|
+
// "Update Product Category Failed >> ",
|
|
136
|
+
// e?.response?.data,
|
|
137
|
+
// body
|
|
138
|
+
// );
|
|
139
|
+
failed_docs_report.push({
|
|
140
|
+
method: "update",
|
|
141
|
+
doc_id:
|
|
142
|
+
repzo_category === null || repzo_category === void 0
|
|
143
|
+
? void 0
|
|
144
|
+
: repzo_category._id,
|
|
145
|
+
doc: body,
|
|
146
|
+
error_message: set_error(e),
|
|
147
|
+
});
|
|
148
|
+
result.failed++;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
102
151
|
}
|
|
152
|
+
// console.log(result);
|
|
153
|
+
await update_bench_time(
|
|
154
|
+
repzo,
|
|
155
|
+
commandEvent.app._id,
|
|
156
|
+
bench_time_key,
|
|
157
|
+
new_bench_time
|
|
158
|
+
);
|
|
159
|
+
await commandLog
|
|
160
|
+
.setStatus(
|
|
161
|
+
"success",
|
|
162
|
+
failed_docs_report.length ? failed_docs_report : null
|
|
163
|
+
)
|
|
164
|
+
.setBody(result)
|
|
165
|
+
.commit();
|
|
166
|
+
return result;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
//@ts-ignore
|
|
169
|
+
console.error(
|
|
170
|
+
((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
171
|
+
_f === void 0
|
|
172
|
+
? void 0
|
|
173
|
+
: _f.data) || e
|
|
174
|
+
);
|
|
175
|
+
await commandLog.setStatus("fail", e).commit();
|
|
176
|
+
throw e;
|
|
177
|
+
}
|
|
103
178
|
};
|
|
104
179
|
const get_sap_categories = async (serviceEndPoint, query) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
180
|
+
try {
|
|
181
|
+
const sap_categories = await _create(serviceEndPoint, "/ItemGroup", {});
|
|
182
|
+
return sap_categories.ItemGroup;
|
|
183
|
+
} catch (e) {
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
112
186
|
};
|
package/lib/commands/channel.js
CHANGED
|
@@ -1,125 +1,206 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
_create,
|
|
4
|
+
update_bench_time,
|
|
5
|
+
date_formatting,
|
|
6
|
+
set_error,
|
|
7
|
+
} from "../util.js";
|
|
3
8
|
export const sync_channel = async (commandEvent) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
const repzo = new Repzo(
|
|
11
|
+
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
|
+
? void 0
|
|
13
|
+
: _a.repzoApiKey,
|
|
14
|
+
{
|
|
15
|
+
env: commandEvent.env,
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
const commandLog = new Repzo.CommandLog(
|
|
19
|
+
repzo,
|
|
20
|
+
commandEvent.app,
|
|
21
|
+
commandEvent.command
|
|
22
|
+
);
|
|
23
|
+
try {
|
|
24
|
+
// console.log("sync_channel");
|
|
25
|
+
const new_bench_time = new Date().toISOString();
|
|
26
|
+
const bench_time_key = "bench_time_channel";
|
|
27
|
+
await commandLog.load(commandEvent.sync_id);
|
|
28
|
+
await commandLog
|
|
29
|
+
.addDetail("Repzo SAP: Started Syncing Client Channels")
|
|
30
|
+
.commit();
|
|
31
|
+
const nameSpace = commandEvent.nameSpace.join("_");
|
|
32
|
+
const result = {
|
|
33
|
+
sap_total: 0,
|
|
34
|
+
repzo_total: 0,
|
|
35
|
+
created: 0,
|
|
36
|
+
updated: 0,
|
|
37
|
+
failed: 0,
|
|
38
|
+
};
|
|
39
|
+
const failed_docs_report = [];
|
|
40
|
+
const sap_clients = await get_sap_clients(
|
|
41
|
+
commandEvent.app.formData.sapHostUrl,
|
|
42
|
+
{
|
|
43
|
+
updateAt: commandEvent.app.options_formData[bench_time_key],
|
|
44
|
+
GroupCode: commandEvent.app.formData.GroupCode,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
const sap_unique_channels = {};
|
|
48
|
+
sap_clients === null || sap_clients === void 0
|
|
49
|
+
? void 0
|
|
50
|
+
: sap_clients.forEach((client) => {
|
|
51
|
+
const channel = client.CLIENTGROUP;
|
|
52
|
+
sap_unique_channels[channel] = true;
|
|
34
53
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
54
|
+
const sap_channels = Object.keys(sap_unique_channels);
|
|
55
|
+
result.sap_total =
|
|
56
|
+
sap_channels === null || sap_channels === void 0
|
|
57
|
+
? void 0
|
|
58
|
+
: sap_channels.length;
|
|
59
|
+
await commandLog
|
|
60
|
+
.addDetail(
|
|
61
|
+
`${result.sap_total} Client Channels in SAP changed since ${
|
|
62
|
+
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
63
|
+
}`
|
|
64
|
+
)
|
|
65
|
+
.commit();
|
|
66
|
+
const repzo_channels = await repzo.channel.find({ per_page: 50000 });
|
|
67
|
+
result.repzo_total =
|
|
68
|
+
(_b =
|
|
69
|
+
repzo_channels === null || repzo_channels === void 0
|
|
70
|
+
? void 0
|
|
71
|
+
: repzo_channels.data) === null || _b === void 0
|
|
72
|
+
? void 0
|
|
73
|
+
: _b.length;
|
|
74
|
+
await commandLog
|
|
75
|
+
.addDetail(
|
|
76
|
+
`${
|
|
77
|
+
(_c =
|
|
78
|
+
repzo_channels === null || repzo_channels === void 0
|
|
79
|
+
? void 0
|
|
80
|
+
: repzo_channels.data) === null || _c === void 0
|
|
81
|
+
? void 0
|
|
82
|
+
: _c.length
|
|
83
|
+
} Client Channels in Repzo`
|
|
84
|
+
)
|
|
85
|
+
.commit();
|
|
86
|
+
for (
|
|
87
|
+
let i = 0;
|
|
88
|
+
i <
|
|
89
|
+
(sap_channels === null || sap_channels === void 0
|
|
90
|
+
? void 0
|
|
91
|
+
: sap_channels.length);
|
|
92
|
+
i++
|
|
93
|
+
) {
|
|
94
|
+
const sap_channel = sap_channels[i];
|
|
95
|
+
const repzo_channel = repzo_channels.data.find((r_channel) => {
|
|
96
|
+
var _a;
|
|
97
|
+
return (
|
|
98
|
+
((_a = r_channel.integration_meta) === null || _a === void 0
|
|
99
|
+
? void 0
|
|
100
|
+
: _a.id) == `${nameSpace}_${sap_channel}`
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
const body = {
|
|
104
|
+
name: sap_channel,
|
|
105
|
+
disabled: false,
|
|
106
|
+
integration_meta: {
|
|
107
|
+
id: `${nameSpace}_${sap_channel}`,
|
|
108
|
+
},
|
|
109
|
+
company_namespace: [nameSpace],
|
|
110
|
+
};
|
|
111
|
+
if (!repzo_channel) {
|
|
112
|
+
// Create
|
|
113
|
+
try {
|
|
114
|
+
const created_channel = await repzo.channel.create(body);
|
|
115
|
+
result.created++;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
// console.log("Create Client Channel Failed >> ", e?.response, body);
|
|
118
|
+
failed_docs_report.push({
|
|
119
|
+
method: "create",
|
|
120
|
+
doc: body,
|
|
121
|
+
error_message: set_error(e),
|
|
122
|
+
});
|
|
123
|
+
result.failed++;
|
|
96
124
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
.
|
|
102
|
-
.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
} else {
|
|
126
|
+
if (
|
|
127
|
+
(repzo_channel === null || repzo_channel === void 0
|
|
128
|
+
? void 0
|
|
129
|
+
: repzo_channel.name) ==
|
|
130
|
+
(body === null || body === void 0 ? void 0 : body.name) &&
|
|
131
|
+
(repzo_channel === null || repzo_channel === void 0
|
|
132
|
+
? void 0
|
|
133
|
+
: repzo_channel.disabled) ==
|
|
134
|
+
(body === null || body === void 0 ? void 0 : body.disabled)
|
|
135
|
+
)
|
|
136
|
+
continue;
|
|
137
|
+
// Update
|
|
138
|
+
try {
|
|
139
|
+
const updated_channel = await repzo.channel.update(
|
|
140
|
+
repzo_channel._id,
|
|
141
|
+
body
|
|
142
|
+
);
|
|
143
|
+
result.updated++;
|
|
144
|
+
} catch (e) {
|
|
145
|
+
// console.log(
|
|
146
|
+
// "Update Client Channel Failed >> ",
|
|
147
|
+
// e?.response?.data,
|
|
148
|
+
// body
|
|
149
|
+
// );
|
|
150
|
+
failed_docs_report.push({
|
|
151
|
+
method: "update",
|
|
152
|
+
doc_id:
|
|
153
|
+
repzo_channel === null || repzo_channel === void 0
|
|
154
|
+
? void 0
|
|
155
|
+
: repzo_channel._id,
|
|
156
|
+
doc: body,
|
|
157
|
+
error_message: set_error(e),
|
|
158
|
+
});
|
|
159
|
+
result.failed++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
110
162
|
}
|
|
163
|
+
// console.log(result);
|
|
164
|
+
await update_bench_time(
|
|
165
|
+
repzo,
|
|
166
|
+
commandEvent.app._id,
|
|
167
|
+
bench_time_key,
|
|
168
|
+
new_bench_time
|
|
169
|
+
);
|
|
170
|
+
await commandLog
|
|
171
|
+
.setStatus(
|
|
172
|
+
"success",
|
|
173
|
+
failed_docs_report.length ? failed_docs_report : null
|
|
174
|
+
)
|
|
175
|
+
.setBody(result)
|
|
176
|
+
.commit();
|
|
177
|
+
return result;
|
|
178
|
+
} catch (e) {
|
|
179
|
+
//@ts-ignore
|
|
180
|
+
console.error(
|
|
181
|
+
((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
182
|
+
_d === void 0
|
|
183
|
+
? void 0
|
|
184
|
+
: _d.data) || e
|
|
185
|
+
);
|
|
186
|
+
await commandLog.setStatus("fail", e).commit();
|
|
187
|
+
throw e;
|
|
188
|
+
}
|
|
111
189
|
};
|
|
112
190
|
const get_sap_clients = async (serviceEndPoint, query) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
191
|
+
try {
|
|
192
|
+
const sap_clients = await _create(serviceEndPoint, "/Customers", {
|
|
193
|
+
Active: "Y",
|
|
194
|
+
Frozen: "N",
|
|
195
|
+
UpdateAt: date_formatting(
|
|
196
|
+
query === null || query === void 0 ? void 0 : query.updateAt,
|
|
197
|
+
"YYYYMMDD:HHmmss"
|
|
198
|
+
),
|
|
199
|
+
GroupCode:
|
|
200
|
+
(query === null || query === void 0 ? void 0 : query.GroupCode) || "",
|
|
201
|
+
});
|
|
202
|
+
return sap_clients.Customers;
|
|
203
|
+
} catch (e) {
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
125
206
|
};
|