repzo-sap-absjo 1.0.10 → 1.0.12
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 +2 -0
- package/lib/actions/create_invoice.d.ts +19 -13
- package/lib/actions/create_invoice.js +356 -208
- package/lib/actions/create_payment.d.ts +4 -1
- package/lib/actions/create_payment.js +191 -117
- package/lib/actions/create_proforma.d.ts +4 -1
- package/lib/actions/create_proforma.js +285 -155
- package/lib/actions/create_return_invoice.d.ts +4 -1
- package/lib/actions/create_return_invoice.js +312 -169
- package/lib/actions/create_transfer.d.ts +4 -1
- package/lib/actions/create_transfer.js +223 -136
- 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 +426 -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 +2 -2
- package/src/actions/create_invoice.ts +11 -16
- package/src/actions/create_payment.ts +11 -16
- package/src/actions/create_proforma.ts +19 -24
- package/src/actions/create_return_invoice.ts +11 -16
- package/src/actions/create_transfer.ts +23 -28
- package/src/commands/product.ts +1 -0
|
@@ -1,202 +1,300 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
2
|
import DataSet from "data-set-query";
|
|
3
|
-
import { _create, update_bench_time, set_error
|
|
3
|
+
import { _create, update_bench_time, set_error } from "../util.js";
|
|
4
4
|
export const sync_measureunit = async (commandEvent) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6
|
+
const repzo = new Repzo(
|
|
7
|
+
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
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,
|
|
8
49
|
});
|
|
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
|
-
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;
|
|
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
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
}
|
|
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;
|
|
175
139
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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;
|
|
183
169
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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,
|
|
177
|
+
});
|
|
178
|
+
db.load(unique_UoMs);
|
|
179
|
+
for (
|
|
180
|
+
let i = 0;
|
|
181
|
+
i <
|
|
182
|
+
(unique_UoMs === null || unique_UoMs === void 0
|
|
183
|
+
? void 0
|
|
184
|
+
: unique_UoMs.length);
|
|
185
|
+
i++
|
|
186
|
+
) {
|
|
187
|
+
const sap_UoM = unique_UoMs[i];
|
|
188
|
+
const repzo_UoM = repzo_UoMs.data.find((r_UoM) => {
|
|
189
|
+
var _a;
|
|
190
|
+
return (
|
|
191
|
+
((_a = r_UoM.integration_meta) === null || _a === void 0
|
|
192
|
+
? void 0
|
|
193
|
+
: _a.id) ==
|
|
194
|
+
`${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
const body = {
|
|
198
|
+
parent: repzo_parent_id,
|
|
199
|
+
name: sap_UoM.ALTUOMCODE,
|
|
200
|
+
factor: sap_UoM.repzo_factor || 0,
|
|
201
|
+
disabled: false,
|
|
202
|
+
integration_meta: {
|
|
203
|
+
id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
|
|
204
|
+
UOMGROUPENTRY: sap_UoM.UOMGROUPENTRY,
|
|
205
|
+
ALTUOMID: sap_UoM.ALTUOMID,
|
|
206
|
+
},
|
|
207
|
+
company_namespace: [nameSpace],
|
|
208
|
+
};
|
|
209
|
+
if (!repzo_UoM) {
|
|
210
|
+
// Create
|
|
211
|
+
try {
|
|
212
|
+
const created_UoM = await repzo.measureunit.create(body);
|
|
213
|
+
result.created++;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
// console.log("Create Measure Unit Failed >> ", e?.response, body);
|
|
216
|
+
failed_docs_report.push({
|
|
217
|
+
method: "create",
|
|
218
|
+
doc: body,
|
|
219
|
+
error_message: set_error(e),
|
|
220
|
+
});
|
|
221
|
+
result.failed++;
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
const found_identical_docs = db.search({
|
|
225
|
+
ALTUOMCODE: repzo_UoM.name,
|
|
226
|
+
repzo_factor: repzo_UoM.factor,
|
|
227
|
+
UOMGROUPENTRY:
|
|
228
|
+
(_e = repzo_UoM.integration_meta) === null || _e === void 0
|
|
229
|
+
? void 0
|
|
230
|
+
: _e.UOMGROUPENTRY,
|
|
231
|
+
ALTUOMID:
|
|
232
|
+
(_f = repzo_UoM.integration_meta) === null || _f === void 0
|
|
233
|
+
? void 0
|
|
234
|
+
: _f.ALTUOMID,
|
|
235
|
+
});
|
|
236
|
+
if (found_identical_docs.length) continue;
|
|
237
|
+
// Update
|
|
238
|
+
try {
|
|
239
|
+
const updated_UoM = await repzo.measureunit.update(
|
|
240
|
+
repzo_UoM._id,
|
|
241
|
+
body
|
|
242
|
+
);
|
|
243
|
+
result.updated++;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
// console.log(
|
|
246
|
+
// "Update Measure Unit Failed >> ",
|
|
247
|
+
// e?.response?.data,
|
|
248
|
+
// body
|
|
249
|
+
// );
|
|
250
|
+
failed_docs_report.push({
|
|
251
|
+
method: "update",
|
|
252
|
+
doc_id:
|
|
253
|
+
repzo_UoM === null || repzo_UoM === void 0
|
|
254
|
+
? void 0
|
|
255
|
+
: repzo_UoM._id,
|
|
256
|
+
doc: body,
|
|
257
|
+
error_message: set_error(e),
|
|
258
|
+
});
|
|
259
|
+
result.failed++;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
189
262
|
}
|
|
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
|
+
}
|
|
190
289
|
};
|
|
191
290
|
export const get_sap_UoMs = async (serviceEndPoint, query) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
291
|
+
try {
|
|
292
|
+
const sap_UoMs = await _create(serviceEndPoint, "/Uom", {
|
|
293
|
+
Inactive: "N",
|
|
294
|
+
Locked: "N",
|
|
295
|
+
});
|
|
296
|
+
return sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.UoM;
|
|
297
|
+
} catch (e) {
|
|
298
|
+
throw e;
|
|
299
|
+
}
|
|
202
300
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CommandEvent } from "../types";
|
|
2
|
-
export declare const sync_measureunit_family: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export declare const sync_measureunit_family: (
|
|
3
|
+
commandEvent: CommandEvent
|
|
4
|
+
) => Promise<{
|
|
5
|
+
sap_total: number;
|
|
6
|
+
repzo_total: number;
|
|
7
|
+
sap_UoM_total: number;
|
|
8
|
+
repzo_UoM_total: number;
|
|
9
|
+
created: number;
|
|
10
|
+
updated: number;
|
|
11
|
+
failed: number;
|
|
10
12
|
}>;
|