repzo-sap-absjo 1.0.6 → 1.0.8
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/changelog.md +4 -0
- package/lib/actions/create_invoice.d.ts +13 -19
- package/lib/actions/create_invoice.js +216 -336
- package/lib/actions/create_payment.d.ts +1 -4
- package/lib/actions/create_payment.js +125 -171
- package/lib/actions/create_proforma.d.ts +1 -4
- package/lib/actions/create_proforma.js +165 -268
- package/lib/actions/create_return_invoice.d.ts +1 -4
- package/lib/actions/create_return_invoice.js +177 -295
- package/lib/actions/create_transfer.d.ts +1 -4
- package/lib/actions/create_transfer.js +143 -198
- package/lib/actions/index.js +15 -23
- package/lib/commands/adjust_inventory.d.ts +2 -4
- package/lib/commands/adjust_inventory.js +160 -290
- package/lib/commands/bank.d.ts +2 -4
- package/lib/commands/bank.js +157 -279
- package/lib/commands/basic.js +47 -66
- package/lib/commands/category.d.ts +1 -3
- package/lib/commands/category.js +104 -178
- package/lib/commands/channel.d.ts +1 -3
- package/lib/commands/channel.js +117 -198
- package/lib/commands/client.d.ts +32 -34
- package/lib/commands/client.js +244 -404
- package/lib/commands/client_disabled.d.ts +1 -3
- package/lib/commands/client_disabled.js +94 -163
- package/lib/commands/index.d.ts +11 -15
- package/lib/commands/index.js +60 -60
- package/lib/commands/join.js +66 -192
- package/lib/commands/measureunit.d.ts +14 -19
- package/lib/commands/measureunit.js +191 -289
- package/lib/commands/measureunit_family.d.ts +8 -10
- package/lib/commands/measureunit_family.js +138 -250
- package/lib/commands/payment_term.d.ts +1 -3
- package/lib/commands/payment_term.js +123 -202
- package/lib/commands/price_list.d.ts +15 -15
- package/lib/commands/price_list.js +327 -571
- package/lib/commands/product.d.ts +30 -32
- package/lib/commands/product.js +243 -425
- package/lib/commands/product_disabled.d.ts +1 -3
- package/lib/commands/product_disabled.js +94 -164
- package/lib/commands/rep.js +141 -221
- package/lib/commands/tag.js +109 -174
- package/lib/commands/tax.js +112 -177
- package/lib/commands/warehouse.d.ts +1 -3
- package/lib/commands/warehouse.js +119 -207
- package/lib/index.d.ts +12 -21
- package/lib/test/actions/create_invoice.js +188 -193
- package/lib/test/actions/create_payment.js +107 -112
- package/lib/test/actions/create_proforma.js +216 -220
- package/lib/test/actions/create_return_invoice.js +200 -205
- package/lib/test/actions/create_transfer.js +115 -120
- package/lib/test/commands/adjust_inventory.js +90 -90
- package/lib/test/commands/bank.js +90 -90
- package/lib/test/commands/basic.js +327 -328
- package/lib/test/commands/category.js +90 -90
- package/lib/test/commands/channel.js +90 -90
- package/lib/test/commands/client.js +353 -355
- package/lib/test/commands/client_disabled.js +90 -90
- package/lib/test/commands/join.js +327 -328
- 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 -90
- package/lib/test/commands/product.js +90 -90
- package/lib/test/commands/product_disabled.js +90 -90
- package/lib/test/commands/rep.js +344 -346
- 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 +60 -83
- package/lib/util.d.ts +19 -70
- package/lib/util.js +144 -170
- package/package.json +1 -1
- package/src/actions/create_invoice.ts +35 -0
- package/src/actions/create_payment.ts +35 -0
- package/src/actions/create_proforma.ts +35 -0
- package/src/actions/create_return_invoice.ts +35 -0
- package/src/actions/create_transfer.ts +34 -0
- package/src/commands/price_list.ts +40 -4
- package/src/test/commands/price_list.ts +263 -13
|
@@ -1,300 +1,202 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
2
|
import DataSet from "data-set-query";
|
|
3
|
-
import { _create, update_bench_time, set_error } from "../util.js";
|
|
3
|
+
import { _create, update_bench_time, set_error, } from "../util.js";
|
|
4
4
|
export const sync_measureunit = async (commandEvent) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
? void 0
|
|
9
|
-
: _a.repzoApiKey,
|
|
10
|
-
{
|
|
11
|
-
env: commandEvent.env,
|
|
12
|
-
}
|
|
13
|
-
);
|
|
14
|
-
const commandLog = new Repzo.CommandLog(
|
|
15
|
-
repzo,
|
|
16
|
-
commandEvent.app,
|
|
17
|
-
commandEvent.command
|
|
18
|
-
);
|
|
19
|
-
try {
|
|
20
|
-
// console.log("sync_measureunit");
|
|
21
|
-
const new_bench_time = new Date().toISOString();
|
|
22
|
-
const bench_time_key = "bench_time_measureunit";
|
|
23
|
-
await commandLog.load(commandEvent.sync_id);
|
|
24
|
-
await commandLog
|
|
25
|
-
.addDetail("Repzo SAP: Started Syncing Measure units")
|
|
26
|
-
.commit();
|
|
27
|
-
const nameSpace = commandEvent.nameSpace.join("_");
|
|
28
|
-
const result = {
|
|
29
|
-
sap_total: 0,
|
|
30
|
-
repzo_total: 0,
|
|
31
|
-
created: 0,
|
|
32
|
-
updated: 0,
|
|
33
|
-
failed: 0,
|
|
34
|
-
};
|
|
35
|
-
const failed_docs_report = [];
|
|
36
|
-
const sap_UoMs = await get_sap_UoMs(
|
|
37
|
-
commandEvent.app.formData.sapHostUrl,
|
|
38
|
-
{}
|
|
39
|
-
);
|
|
40
|
-
result.sap_total =
|
|
41
|
-
sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length;
|
|
42
|
-
await commandLog
|
|
43
|
-
.addDetail(`${result.sap_total} Unit of Measures in SAP`)
|
|
44
|
-
.commit();
|
|
45
|
-
// Get Repzo default measureunit
|
|
46
|
-
const repzo_UoM_parent = await repzo.measureunit.find({
|
|
47
|
-
parent: "nil",
|
|
48
|
-
disabled: false,
|
|
49
|
-
});
|
|
50
|
-
if (
|
|
51
|
-
!(repzo_UoM_parent === null || repzo_UoM_parent === void 0
|
|
52
|
-
? void 0
|
|
53
|
-
: repzo_UoM_parent.data) ||
|
|
54
|
-
((_b =
|
|
55
|
-
repzo_UoM_parent === null || repzo_UoM_parent === void 0
|
|
56
|
-
? void 0
|
|
57
|
-
: repzo_UoM_parent.data) === null || _b === void 0
|
|
58
|
-
? void 0
|
|
59
|
-
: _b.length) != 1
|
|
60
|
-
)
|
|
61
|
-
throw "the parent of measure unit is not found or the nameSpace has more than one";
|
|
62
|
-
const repzo_parent_id = repzo_UoM_parent.data[0]._id;
|
|
63
|
-
const repzo_UoMs = await repzo.measureunit.find({ per_page: 50000 });
|
|
64
|
-
result.repzo_total =
|
|
65
|
-
(_c =
|
|
66
|
-
repzo_UoMs === null || repzo_UoMs === void 0
|
|
67
|
-
? void 0
|
|
68
|
-
: repzo_UoMs.data) === null || _c === void 0
|
|
69
|
-
? void 0
|
|
70
|
-
: _c.length;
|
|
71
|
-
await commandLog
|
|
72
|
-
.addDetail(
|
|
73
|
-
`${
|
|
74
|
-
(_d =
|
|
75
|
-
repzo_UoMs === null || repzo_UoMs === void 0
|
|
76
|
-
? void 0
|
|
77
|
-
: repzo_UoMs.data) === null || _d === void 0
|
|
78
|
-
? void 0
|
|
79
|
-
: _d.length
|
|
80
|
-
} Measure Units in Repzo`
|
|
81
|
-
)
|
|
82
|
-
.commit();
|
|
83
|
-
const byProduct = {};
|
|
84
|
-
sap_UoMs.forEach((unit) => {
|
|
85
|
-
if (!byProduct[unit.ITEMCODE]) byProduct[unit.ITEMCODE] = [];
|
|
86
|
-
byProduct[unit.ITEMCODE].push(unit);
|
|
87
|
-
});
|
|
88
|
-
Object.values(byProduct).forEach((units) => {
|
|
89
|
-
var _a, _b, _c;
|
|
90
|
-
const max_unit = {
|
|
91
|
-
sap_product_UoMs: [],
|
|
92
|
-
value: null,
|
|
93
|
-
default_unit: null,
|
|
94
|
-
};
|
|
95
|
-
units.forEach((unit) => {
|
|
96
|
-
if (max_unit.value == null || unit.BASEQTY > max_unit.value) {
|
|
97
|
-
max_unit.value = unit.BASEQTY;
|
|
98
|
-
max_unit.sap_product_UoMs.push(unit);
|
|
99
|
-
} else if (unit.BASEQTY == max_unit.value) {
|
|
100
|
-
max_unit.sap_product_UoMs.push(unit);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
if (max_unit.sap_product_UoMs.length > 1) {
|
|
104
|
-
max_unit.default_unit = max_unit.sap_product_UoMs.find(
|
|
105
|
-
(u) => u.ALTUOMCODE == "PC"
|
|
106
|
-
);
|
|
107
|
-
if (!max_unit.default_unit) {
|
|
108
|
-
// console.log(
|
|
109
|
-
// "Create/Update Measure Unit Failed >> ",
|
|
110
|
-
// `${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit`,
|
|
111
|
-
// units
|
|
112
|
-
// );
|
|
113
|
-
failed_docs_report.push({
|
|
114
|
-
method: "create",
|
|
115
|
-
doc_id:
|
|
116
|
-
((_a =
|
|
117
|
-
max_unit === null || max_unit === void 0
|
|
118
|
-
? void 0
|
|
119
|
-
: max_unit.sap_product_UoMs[0]) === null || _a === void 0
|
|
120
|
-
? void 0
|
|
121
|
-
: _a.ITEMCODE) ||
|
|
122
|
-
((_b = units[0]) === null || _b === void 0
|
|
123
|
-
? void 0
|
|
124
|
-
: _b.ITEMCODE),
|
|
125
|
-
doc: units,
|
|
126
|
-
error_message: set_error(
|
|
127
|
-
`Create/Update Measure Unit Failed >> ${
|
|
128
|
-
(_c =
|
|
129
|
-
max_unit === null || max_unit === void 0
|
|
130
|
-
? void 0
|
|
131
|
-
: max_unit.sap_product_UoMs[0]) === null || _c === void 0
|
|
132
|
-
? void 0
|
|
133
|
-
: _c.ITEMCODE
|
|
134
|
-
} Could not found the base_unit`
|
|
135
|
-
),
|
|
136
|
-
});
|
|
137
|
-
result.failed++;
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
max_unit.default_unit = max_unit.sap_product_UoMs[0];
|
|
142
|
-
}
|
|
143
|
-
units.forEach((unit) => {
|
|
144
|
-
var _a;
|
|
145
|
-
if (
|
|
146
|
-
max_unit === null || max_unit === void 0
|
|
147
|
-
? void 0
|
|
148
|
-
: max_unit.default_unit
|
|
149
|
-
)
|
|
150
|
-
unit.repzo_factor =
|
|
151
|
-
(unit.ALTQTY / unit.BASEQTY) *
|
|
152
|
-
((_a =
|
|
153
|
-
max_unit === null || max_unit === void 0
|
|
154
|
-
? void 0
|
|
155
|
-
: max_unit.default_unit) === null || _a === void 0
|
|
156
|
-
? void 0
|
|
157
|
-
: _a.BASEQTY);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
let unique_UoMs = {};
|
|
161
|
-
for (
|
|
162
|
-
let i = 0;
|
|
163
|
-
i < (sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length);
|
|
164
|
-
i++
|
|
165
|
-
) {
|
|
166
|
-
const Uom = sap_UoMs[i];
|
|
167
|
-
const key = `${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
|
|
168
|
-
if (!unique_UoMs[key]) unique_UoMs[key] = Uom;
|
|
169
|
-
}
|
|
170
|
-
unique_UoMs = Object.values(unique_UoMs);
|
|
171
|
-
const db = new DataSet([], { autoIndex: false });
|
|
172
|
-
db.createIndex({
|
|
173
|
-
ALTUOMCODE: true,
|
|
174
|
-
repzo_factor: true,
|
|
175
|
-
UOMGROUPENTRY: true,
|
|
176
|
-
ALTUOMID: true,
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6
|
+
const repzo = new Repzo((_a = commandEvent.app.formData) === null || _a === void 0 ? void 0 : _a.repzoApiKey, {
|
|
7
|
+
env: commandEvent.env,
|
|
177
8
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
9
|
+
const commandLog = new Repzo.CommandLog(repzo, commandEvent.app, commandEvent.command);
|
|
10
|
+
try {
|
|
11
|
+
// console.log("sync_measureunit");
|
|
12
|
+
const new_bench_time = new Date().toISOString();
|
|
13
|
+
const bench_time_key = "bench_time_measureunit";
|
|
14
|
+
await commandLog.load(commandEvent.sync_id);
|
|
15
|
+
await commandLog
|
|
16
|
+
.addDetail("Repzo SAP: Started Syncing Measure units")
|
|
17
|
+
.commit();
|
|
18
|
+
const nameSpace = commandEvent.nameSpace.join("_");
|
|
19
|
+
const result = {
|
|
20
|
+
sap_total: 0,
|
|
21
|
+
repzo_total: 0,
|
|
22
|
+
created: 0,
|
|
23
|
+
updated: 0,
|
|
24
|
+
failed: 0,
|
|
25
|
+
};
|
|
26
|
+
const failed_docs_report = [];
|
|
27
|
+
const sap_UoMs = await get_sap_UoMs(commandEvent.app.formData.sapHostUrl, {});
|
|
28
|
+
result.sap_total = sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length;
|
|
29
|
+
await commandLog
|
|
30
|
+
.addDetail(`${result.sap_total} Unit of Measures in SAP`)
|
|
31
|
+
.commit();
|
|
32
|
+
// Get Repzo default measureunit
|
|
33
|
+
const repzo_UoM_parent = await repzo.measureunit.find({
|
|
34
|
+
parent: "nil",
|
|
35
|
+
disabled: false,
|
|
36
|
+
});
|
|
37
|
+
if (!(repzo_UoM_parent === null || repzo_UoM_parent === void 0 ? void 0 : repzo_UoM_parent.data) || ((_b = repzo_UoM_parent === null || repzo_UoM_parent === void 0 ? void 0 : repzo_UoM_parent.data) === null || _b === void 0 ? void 0 : _b.length) != 1)
|
|
38
|
+
throw "the parent of measure unit is not found or the nameSpace has more than one";
|
|
39
|
+
const repzo_parent_id = repzo_UoM_parent.data[0]._id;
|
|
40
|
+
const repzo_UoMs = await repzo.measureunit.find({ per_page: 50000 });
|
|
41
|
+
result.repzo_total = (_c = repzo_UoMs === null || repzo_UoMs === void 0 ? void 0 : repzo_UoMs.data) === null || _c === void 0 ? void 0 : _c.length;
|
|
42
|
+
await commandLog
|
|
43
|
+
.addDetail(`${(_d = repzo_UoMs === null || repzo_UoMs === void 0 ? void 0 : repzo_UoMs.data) === null || _d === void 0 ? void 0 : _d.length} Measure Units in Repzo`)
|
|
44
|
+
.commit();
|
|
45
|
+
const byProduct = {};
|
|
46
|
+
sap_UoMs.forEach((unit) => {
|
|
47
|
+
if (!byProduct[unit.ITEMCODE])
|
|
48
|
+
byProduct[unit.ITEMCODE] = [];
|
|
49
|
+
byProduct[unit.ITEMCODE].push(unit);
|
|
50
|
+
});
|
|
51
|
+
Object.values(byProduct).forEach((units) => {
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
const max_unit = {
|
|
54
|
+
sap_product_UoMs: [],
|
|
55
|
+
value: null,
|
|
56
|
+
default_unit: null,
|
|
57
|
+
};
|
|
58
|
+
units.forEach((unit) => {
|
|
59
|
+
if (max_unit.value == null || unit.BASEQTY > max_unit.value) {
|
|
60
|
+
max_unit.value = unit.BASEQTY;
|
|
61
|
+
max_unit.sap_product_UoMs.push(unit);
|
|
62
|
+
}
|
|
63
|
+
else if (unit.BASEQTY == max_unit.value) {
|
|
64
|
+
max_unit.sap_product_UoMs.push(unit);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (max_unit.sap_product_UoMs.length > 1) {
|
|
68
|
+
max_unit.default_unit = max_unit.sap_product_UoMs.find((u) => u.ALTUOMCODE == "PC");
|
|
69
|
+
if (!max_unit.default_unit) {
|
|
70
|
+
// console.log(
|
|
71
|
+
// "Create/Update Measure Unit Failed >> ",
|
|
72
|
+
// `${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit`,
|
|
73
|
+
// units
|
|
74
|
+
// );
|
|
75
|
+
failed_docs_report.push({
|
|
76
|
+
method: "create",
|
|
77
|
+
doc_id: ((_a = max_unit === null || max_unit === void 0 ? void 0 : max_unit.sap_product_UoMs[0]) === null || _a === void 0 ? void 0 : _a.ITEMCODE) || ((_b = units[0]) === null || _b === void 0 ? void 0 : _b.ITEMCODE),
|
|
78
|
+
doc: units,
|
|
79
|
+
error_message: set_error(`Create/Update Measure Unit Failed >> ${(_c = max_unit === null || max_unit === void 0 ? void 0 : max_unit.sap_product_UoMs[0]) === null || _c === void 0 ? void 0 : _c.ITEMCODE} Could not found the base_unit`),
|
|
80
|
+
});
|
|
81
|
+
result.failed++;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
max_unit.default_unit = max_unit.sap_product_UoMs[0];
|
|
87
|
+
}
|
|
88
|
+
units.forEach((unit) => {
|
|
89
|
+
var _a;
|
|
90
|
+
if (max_unit === null || max_unit === void 0 ? void 0 : max_unit.default_unit)
|
|
91
|
+
unit.repzo_factor =
|
|
92
|
+
(unit.ALTQTY / unit.BASEQTY) * ((_a = max_unit === null || max_unit === void 0 ? void 0 : max_unit.default_unit) === null || _a === void 0 ? void 0 : _a.BASEQTY);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
let unique_UoMs = {};
|
|
96
|
+
for (let i = 0; i < (sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length); i++) {
|
|
97
|
+
const Uom = sap_UoMs[i];
|
|
98
|
+
const key = `${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
|
|
99
|
+
if (!unique_UoMs[key])
|
|
100
|
+
unique_UoMs[key] = Uom;
|
|
222
101
|
}
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
: _e.UOMGROUPENTRY,
|
|
231
|
-
ALTUOMID:
|
|
232
|
-
(_f = repzo_UoM.integration_meta) === null || _f === void 0
|
|
233
|
-
? void 0
|
|
234
|
-
: _f.ALTUOMID,
|
|
102
|
+
unique_UoMs = Object.values(unique_UoMs);
|
|
103
|
+
const db = new DataSet([], { autoIndex: false });
|
|
104
|
+
db.createIndex({
|
|
105
|
+
ALTUOMCODE: true,
|
|
106
|
+
repzo_factor: true,
|
|
107
|
+
UOMGROUPENTRY: true,
|
|
108
|
+
ALTUOMID: true,
|
|
235
109
|
});
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
110
|
+
db.load(unique_UoMs);
|
|
111
|
+
for (let i = 0; i < (unique_UoMs === null || unique_UoMs === void 0 ? void 0 : unique_UoMs.length); i++) {
|
|
112
|
+
const sap_UoM = unique_UoMs[i];
|
|
113
|
+
const repzo_UoM = repzo_UoMs.data.find((r_UoM) => {
|
|
114
|
+
var _a;
|
|
115
|
+
return ((_a = r_UoM.integration_meta) === null || _a === void 0 ? void 0 : _a.id) ==
|
|
116
|
+
`${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`;
|
|
117
|
+
});
|
|
118
|
+
const body = {
|
|
119
|
+
parent: repzo_parent_id,
|
|
120
|
+
name: sap_UoM.ALTUOMCODE,
|
|
121
|
+
factor: sap_UoM.repzo_factor || 0,
|
|
122
|
+
disabled: false,
|
|
123
|
+
integration_meta: {
|
|
124
|
+
id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
|
|
125
|
+
UOMGROUPENTRY: sap_UoM.UOMGROUPENTRY,
|
|
126
|
+
ALTUOMID: sap_UoM.ALTUOMID,
|
|
127
|
+
},
|
|
128
|
+
company_namespace: [nameSpace],
|
|
129
|
+
};
|
|
130
|
+
if (!repzo_UoM) {
|
|
131
|
+
// Create
|
|
132
|
+
try {
|
|
133
|
+
const created_UoM = await repzo.measureunit.create(body);
|
|
134
|
+
result.created++;
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
// console.log("Create Measure Unit Failed >> ", e?.response, body);
|
|
138
|
+
failed_docs_report.push({
|
|
139
|
+
method: "create",
|
|
140
|
+
doc: body,
|
|
141
|
+
error_message: set_error(e),
|
|
142
|
+
});
|
|
143
|
+
result.failed++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const found_identical_docs = db.search({
|
|
148
|
+
ALTUOMCODE: repzo_UoM.name,
|
|
149
|
+
repzo_factor: repzo_UoM.factor,
|
|
150
|
+
UOMGROUPENTRY: (_e = repzo_UoM.integration_meta) === null || _e === void 0 ? void 0 : _e.UOMGROUPENTRY,
|
|
151
|
+
ALTUOMID: (_f = repzo_UoM.integration_meta) === null || _f === void 0 ? void 0 : _f.ALTUOMID,
|
|
152
|
+
});
|
|
153
|
+
if (found_identical_docs.length)
|
|
154
|
+
continue;
|
|
155
|
+
// Update
|
|
156
|
+
try {
|
|
157
|
+
const updated_UoM = await repzo.measureunit.update(repzo_UoM._id, body);
|
|
158
|
+
result.updated++;
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
// console.log(
|
|
162
|
+
// "Update Measure Unit Failed >> ",
|
|
163
|
+
// e?.response?.data,
|
|
164
|
+
// body
|
|
165
|
+
// );
|
|
166
|
+
failed_docs_report.push({
|
|
167
|
+
method: "update",
|
|
168
|
+
doc_id: repzo_UoM === null || repzo_UoM === void 0 ? void 0 : repzo_UoM._id,
|
|
169
|
+
doc: body,
|
|
170
|
+
error_message: set_error(e),
|
|
171
|
+
});
|
|
172
|
+
result.failed++;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
260
175
|
}
|
|
261
|
-
|
|
176
|
+
// console.log(result);
|
|
177
|
+
await update_bench_time(repzo, commandEvent.app._id, bench_time_key, new_bench_time);
|
|
178
|
+
await commandLog
|
|
179
|
+
.setStatus("success", failed_docs_report.length ? failed_docs_report : null)
|
|
180
|
+
.setBody(result)
|
|
181
|
+
.commit();
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
//@ts-ignore
|
|
186
|
+
console.error(((_g = e === null || e === void 0 ? void 0 : e.response) === null || _g === void 0 ? void 0 : _g.data) || e);
|
|
187
|
+
await commandLog.setStatus("fail", e).commit();
|
|
188
|
+
throw e;
|
|
262
189
|
}
|
|
263
|
-
// console.log(result);
|
|
264
|
-
await update_bench_time(
|
|
265
|
-
repzo,
|
|
266
|
-
commandEvent.app._id,
|
|
267
|
-
bench_time_key,
|
|
268
|
-
new_bench_time
|
|
269
|
-
);
|
|
270
|
-
await commandLog
|
|
271
|
-
.setStatus(
|
|
272
|
-
"success",
|
|
273
|
-
failed_docs_report.length ? failed_docs_report : null
|
|
274
|
-
)
|
|
275
|
-
.setBody(result)
|
|
276
|
-
.commit();
|
|
277
|
-
return result;
|
|
278
|
-
} catch (e) {
|
|
279
|
-
//@ts-ignore
|
|
280
|
-
console.error(
|
|
281
|
-
((_g = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
282
|
-
_g === void 0
|
|
283
|
-
? void 0
|
|
284
|
-
: _g.data) || e
|
|
285
|
-
);
|
|
286
|
-
await commandLog.setStatus("fail", e).commit();
|
|
287
|
-
throw e;
|
|
288
|
-
}
|
|
289
190
|
};
|
|
290
191
|
export const get_sap_UoMs = async (serviceEndPoint, query) => {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
192
|
+
try {
|
|
193
|
+
const sap_UoMs = await _create(serviceEndPoint, "/Uom", {
|
|
194
|
+
Inactive: "N",
|
|
195
|
+
Locked: "N",
|
|
196
|
+
});
|
|
197
|
+
return sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.UoM;
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
300
202
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { CommandEvent } from "../types";
|
|
2
|
-
export declare const sync_measureunit_family: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
updated: number;
|
|
11
|
-
failed: number;
|
|
2
|
+
export declare const sync_measureunit_family: (commandEvent: CommandEvent) => Promise<{
|
|
3
|
+
sap_total: number;
|
|
4
|
+
repzo_total: number;
|
|
5
|
+
sap_UoM_total: number;
|
|
6
|
+
repzo_UoM_total: number;
|
|
7
|
+
created: number;
|
|
8
|
+
updated: number;
|
|
9
|
+
failed: number;
|
|
12
10
|
}>;
|