repzo-sap-absjo 1.0.2 → 1.0.3
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 +5 -7
- package/lib/actions/create_invoice.js +5 -0
- package/lib/actions/create_payment.js +5 -0
- package/lib/actions/create_proforma.js +5 -0
- package/lib/actions/create_return_invoice.js +5 -0
- package/lib/actions/create_transfer.js +39 -18
- package/lib/commands/adjust_inventory.js +8 -8
- package/lib/commands/bank.js +24 -35
- package/lib/commands/basic.js +1 -2
- package/lib/commands/category.js +11 -18
- package/lib/commands/channel.js +11 -18
- package/lib/commands/client.js +31 -20
- package/lib/commands/client_disabled.js +8 -15
- package/lib/commands/join.js +101 -45
- package/lib/commands/measureunit.d.ts +3 -5
- package/lib/commands/measureunit.js +25 -39
- package/lib/commands/measureunit_family.js +15 -18
- package/lib/commands/payment_term.js +11 -18
- package/lib/commands/price_list.js +48 -72
- package/lib/commands/product.js +8 -19
- package/lib/commands/product_disabled.js +8 -15
- package/lib/commands/rep.js +7 -18
- package/lib/commands/tag.js +7 -18
- package/lib/commands/tax.js +7 -18
- package/lib/commands/warehouse.js +3 -7
- package/lib/test/actions/create_invoice.js +1 -0
- package/lib/test/actions/create_payment.js +1 -0
- package/lib/test/actions/create_proforma.js +1 -0
- package/lib/test/actions/create_return_invoice.js +1 -0
- package/lib/test/actions/create_transfer.js +1 -0
- package/lib/types.d.ts +36 -10
- package/lib/util.d.ts +22 -10
- package/lib/util.js +30 -0
- package/package.json +2 -2
- package/src/actions/create_invoice.ts +1 -0
- package/src/actions/create_payment.ts +1 -0
- package/src/actions/create_proforma.ts +1 -0
- package/src/actions/create_return_invoice.ts +1 -0
- package/src/actions/create_transfer.ts +23 -7
- package/src/commands/adjust_inventory.ts +8 -8
- package/src/commands/bank.ts +3 -3
- package/src/commands/basic.ts +3 -4
- package/src/commands/category.ts +7 -7
- package/src/commands/channel.ts +7 -7
- package/src/commands/client.ts +10 -4
- package/src/commands/client_disabled.ts +4 -4
- package/src/commands/join.ts +11 -6
- package/src/commands/measureunit.ts +12 -12
- package/src/commands/measureunit_family.ts +11 -11
- package/src/commands/payment_term.ts +7 -7
- package/src/commands/price_list.ts +18 -18
- package/src/commands/product.ts +4 -4
- package/src/commands/product_disabled.ts +4 -4
- package/src/commands/rep.ts +3 -3
- package/src/commands/tag.ts +3 -3
- package/src/commands/tax.ts +3 -3
- package/src/commands/warehouse.ts +3 -3
- package/src/test/actions/create_invoice.ts +1 -0
- package/src/test/actions/create_payment.ts +1 -0
- package/src/test/actions/create_proforma.ts +1 -0
- package/src/test/actions/create_return_invoice.ts +1 -0
- package/src/test/actions/create_transfer.ts +1 -0
- package/src/types.ts +31 -3
- package/src/util.ts +38 -0
package/changelog.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
- New Commands: [warehouse, rep, tag, tax, measureunit, measureunit-family, category, channel, paymentTerm, bank, priceList, priceListItem, product, disabled_product, client, disabled_client, adjust_inventory] @maramalshen
|
|
9
9
|
- New Actions: [invoice, return_invoice, proforma, payment, transfer] @maramalshen
|
|
10
10
|
- fix bug in sync_client @maramalshen
|
|
11
|
+
- add detail with the action.sync_id
|
|
12
|
+
- if create transfer was failed then send command: Adjust Inventory (optionals)
|
|
11
13
|
|
|
12
14
|
### Changed
|
|
13
15
|
|
|
@@ -17,12 +17,10 @@ export declare const create_invoice: (
|
|
|
17
17
|
) => Promise<any>;
|
|
18
18
|
export declare const get_invoice_from_sap: (
|
|
19
19
|
serviceEndPoint: string,
|
|
20
|
-
query?:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
| undefined
|
|
20
|
+
query?: {
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
Status: string;
|
|
23
|
+
InvoiceId: string;
|
|
24
|
+
}
|
|
27
25
|
) => Promise<SAPOpenInvoice[]>;
|
|
28
26
|
export {};
|
|
@@ -28,6 +28,11 @@ export const create_invoice = async (event, options) => {
|
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
30
|
await actionLog
|
|
31
|
+
.addDetail(
|
|
32
|
+
`Invoice - ${repzo_serial_number} => ${
|
|
33
|
+
body === null || body === void 0 ? void 0 : body.sync_id
|
|
34
|
+
}`
|
|
35
|
+
)
|
|
31
36
|
.addDetail(
|
|
32
37
|
`Repzo => SAP: Started Create Invoice - ${repzo_serial_number}`
|
|
33
38
|
)
|
|
@@ -29,6 +29,11 @@ export const create_payment = async (event, options) => {
|
|
|
29
29
|
? void 0
|
|
30
30
|
: _c.formatted;
|
|
31
31
|
await actionLog
|
|
32
|
+
.addDetail(
|
|
33
|
+
`Payment - ${repzo_serial_number} => ${
|
|
34
|
+
body === null || body === void 0 ? void 0 : body.sync_id
|
|
35
|
+
}`
|
|
36
|
+
)
|
|
32
37
|
.addDetail(
|
|
33
38
|
`Repzo => SAP: Started Create Payment - ${repzo_serial_number}`
|
|
34
39
|
)
|
|
@@ -28,6 +28,11 @@ export const create_proforma = async (event, options) => {
|
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
30
|
await actionLog
|
|
31
|
+
.addDetail(
|
|
32
|
+
`SalesOrder - ${repzo_serial_number} => ${
|
|
33
|
+
body === null || body === void 0 ? void 0 : body.sync_id
|
|
34
|
+
}`
|
|
35
|
+
)
|
|
31
36
|
.addDetail(
|
|
32
37
|
`Repzo => SAP: Started Create SalesOrder - ${repzo_serial_number}`
|
|
33
38
|
)
|
|
@@ -28,6 +28,11 @@ export const create_return_invoice = async (event, options) => {
|
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
30
|
await actionLog
|
|
31
|
+
.addDetail(
|
|
32
|
+
`Return Invoice - ${repzo_serial_number} => ${
|
|
33
|
+
body === null || body === void 0 ? void 0 : body.sync_id
|
|
34
|
+
}`
|
|
35
|
+
)
|
|
31
36
|
.addDetail(
|
|
32
37
|
`Repzo => SAP: Started Create Return Invoice - ${repzo_serial_number}`
|
|
33
38
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
|
-
import { _create, get_data } from "../util.js";
|
|
2
|
+
import { _create, get_data, send_command_to_marketplace } from "../util.js";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
export const create_transfer = async (event, options) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
6
6
|
const repzo = new Repzo(
|
|
7
7
|
(_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
|
|
8
8
|
{ env: options.env }
|
|
@@ -27,6 +27,11 @@ export const create_transfer = async (event, options) => {
|
|
|
27
27
|
? void 0
|
|
28
28
|
: _c.formatted;
|
|
29
29
|
await actionLog
|
|
30
|
+
.addDetail(
|
|
31
|
+
`Transfer - ${repzo_serial_number} => ${
|
|
32
|
+
body === null || body === void 0 ? void 0 : body.sync_id
|
|
33
|
+
}`
|
|
34
|
+
)
|
|
30
35
|
.addDetail(
|
|
31
36
|
`Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`
|
|
32
37
|
)
|
|
@@ -89,9 +94,9 @@ export const create_transfer = async (event, options) => {
|
|
|
89
94
|
}
|
|
90
95
|
);
|
|
91
96
|
if (!repzo_product) {
|
|
92
|
-
console.log(
|
|
93
|
-
|
|
94
|
-
);
|
|
97
|
+
// console.log(
|
|
98
|
+
// `Product with _id: ${repzo_transfer_item.product_id} was not found In Repzo`,
|
|
99
|
+
// );
|
|
95
100
|
throw new Error(
|
|
96
101
|
`Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo`
|
|
97
102
|
);
|
|
@@ -102,20 +107,16 @@ export const create_transfer = async (event, options) => {
|
|
|
102
107
|
? void 0
|
|
103
108
|
: repzo_measure_unit._id)
|
|
104
109
|
) {
|
|
105
|
-
console.log(
|
|
110
|
+
// console.log(
|
|
111
|
+
// `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
|
|
112
|
+
// );
|
|
113
|
+
throw new Error(
|
|
106
114
|
`Measureunit with _id: ${
|
|
107
115
|
(_h = repzo_product.sv_measureUnit) === null || _h === void 0
|
|
108
116
|
? void 0
|
|
109
117
|
: _h.toString()
|
|
110
118
|
} was not found`
|
|
111
119
|
);
|
|
112
|
-
throw new Error(
|
|
113
|
-
`Measureunit with _id: ${
|
|
114
|
-
(_j = repzo_product.sv_measureUnit) === null || _j === void 0
|
|
115
|
-
? void 0
|
|
116
|
-
: _j.toString()
|
|
117
|
-
} was not found`
|
|
118
|
-
);
|
|
119
120
|
}
|
|
120
121
|
variants.push({
|
|
121
122
|
//@ts-ignore
|
|
@@ -123,21 +124,21 @@ export const create_transfer = async (event, options) => {
|
|
|
123
124
|
Quantity: repzo_transfer_item.qty / Number(repzo_measure_unit.factor),
|
|
124
125
|
//@ts-ignore
|
|
125
126
|
FromWarehouse:
|
|
126
|
-
(
|
|
127
|
+
(_j = repzo_transfer.from) === null || _j === void 0
|
|
127
128
|
? void 0
|
|
128
|
-
:
|
|
129
|
+
: _j.code,
|
|
129
130
|
//@ts-ignore
|
|
130
131
|
ToWarehouse:
|
|
131
|
-
(
|
|
132
|
+
(_k = repzo_transfer.to) === null || _k === void 0 ? void 0 : _k.code,
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
const sap_transfer = {
|
|
135
136
|
StockTransferID: body.serial_number.formatted,
|
|
136
137
|
SalesPersonCode: repzo_rep
|
|
137
138
|
? repzo_rep.integration_id
|
|
138
|
-
: (
|
|
139
|
+
: (_l = options.data) === null || _l === void 0
|
|
139
140
|
? void 0
|
|
140
|
-
:
|
|
141
|
+
: _l.SalesPersonCode,
|
|
141
142
|
FromWarehouse: body.from.code,
|
|
142
143
|
ToWarehouse: body.to.code,
|
|
143
144
|
RepzoStockTransferLines: variants,
|
|
@@ -166,6 +167,26 @@ export const create_transfer = async (event, options) => {
|
|
|
166
167
|
//@ts-ignore
|
|
167
168
|
console.error((e === null || e === void 0 ? void 0 : e.response) || e);
|
|
168
169
|
await actionLog.setStatus("fail", e).setBody(body).commit();
|
|
170
|
+
if (
|
|
171
|
+
(_o =
|
|
172
|
+
(_m =
|
|
173
|
+
options === null || options === void 0 ? void 0 : options.data) ===
|
|
174
|
+
null || _m === void 0
|
|
175
|
+
? void 0
|
|
176
|
+
: _m.transfers) === null || _o === void 0
|
|
177
|
+
? void 0
|
|
178
|
+
: _o.adjustInventoryInFailedTransfer
|
|
179
|
+
) {
|
|
180
|
+
send_command_to_marketplace({
|
|
181
|
+
command: "adjust_inventory",
|
|
182
|
+
app_id: options.app_id,
|
|
183
|
+
env: options.env,
|
|
184
|
+
repzoApiKey:
|
|
185
|
+
(_p = options.data) === null || _p === void 0
|
|
186
|
+
? void 0
|
|
187
|
+
: _p.repzoApiKey,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
169
190
|
throw e;
|
|
170
191
|
}
|
|
171
192
|
};
|
|
@@ -17,7 +17,7 @@ export const adjust_inventory = async (commandEvent) => {
|
|
|
17
17
|
commandEvent.command
|
|
18
18
|
);
|
|
19
19
|
try {
|
|
20
|
-
console.log("adjust_inventory");
|
|
20
|
+
// console.log("adjust_inventory");
|
|
21
21
|
await commandLog.load(commandEvent.sync_id);
|
|
22
22
|
await commandLog
|
|
23
23
|
.addDetail("Repzo SAP: Started Adjusting Inventories")
|
|
@@ -165,9 +165,9 @@ export const adjust_inventory = async (commandEvent) => {
|
|
|
165
165
|
);
|
|
166
166
|
});
|
|
167
167
|
if (!variant) {
|
|
168
|
-
console.log(
|
|
169
|
-
|
|
170
|
-
);
|
|
168
|
+
// console.log(
|
|
169
|
+
// `Variant with ITEMCODE: ${sap_item.ITEMID} was not found`
|
|
170
|
+
// );
|
|
171
171
|
throw `Variant with ITEMCODE: ${sap_item.ITEMID} was not found`;
|
|
172
172
|
}
|
|
173
173
|
const measureUnit =
|
|
@@ -189,9 +189,9 @@ export const adjust_inventory = async (commandEvent) => {
|
|
|
189
189
|
);
|
|
190
190
|
});
|
|
191
191
|
if (!measureUnit) {
|
|
192
|
-
console.log(
|
|
193
|
-
|
|
194
|
-
);
|
|
192
|
+
// console.log(
|
|
193
|
+
// `MeasureUnit with UNITNAME: ${sap_item.UNITNAME} & ALTUOMID: ${sap_item.UNITID} was not found`
|
|
194
|
+
// );
|
|
195
195
|
throw `MeasureUnit with UNITNAME: ${sap_item.UNITNAME} & ALTUOMID: ${sap_item.UNITID} was not found`;
|
|
196
196
|
}
|
|
197
197
|
const qty = measureUnit.factor * sap_item.QTY;
|
|
@@ -215,7 +215,7 @@ export const adjust_inventory = async (commandEvent) => {
|
|
|
215
215
|
: qty;
|
|
216
216
|
return { variant: variant._id, qty: diff_qty };
|
|
217
217
|
} catch (e) {
|
|
218
|
-
console.log(e);
|
|
218
|
+
// console.log(e);
|
|
219
219
|
failed_docs_report.push({
|
|
220
220
|
method: "fetchingData",
|
|
221
221
|
doc_id: sap_item.UNITNAME,
|
package/lib/commands/bank.js
CHANGED
|
@@ -2,7 +2,7 @@ import Repzo from "repzo";
|
|
|
2
2
|
import DataSet from "data-set-query";
|
|
3
3
|
import { _create, update_bench_time, set_error } from "../util.js";
|
|
4
4
|
export const sync_bank = async (commandEvent) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
6
6
|
const repzo = new Repzo(
|
|
7
7
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
8
8
|
? void 0
|
|
@@ -17,7 +17,7 @@ export const sync_bank = async (commandEvent) => {
|
|
|
17
17
|
commandEvent.command
|
|
18
18
|
);
|
|
19
19
|
try {
|
|
20
|
-
console.log("sync_bank");
|
|
20
|
+
// console.log("sync_bank");
|
|
21
21
|
const new_bench_time = new Date().toISOString();
|
|
22
22
|
const bench_time_key = "bench_time_bank";
|
|
23
23
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -113,11 +113,7 @@ export const sync_bank = async (commandEvent) => {
|
|
|
113
113
|
const created_bank = await repzo.bank.create(body);
|
|
114
114
|
result.created++;
|
|
115
115
|
} catch (e) {
|
|
116
|
-
console.log(
|
|
117
|
-
"Create Bank Failed >> ",
|
|
118
|
-
e === null || e === void 0 ? void 0 : e.response,
|
|
119
|
-
body
|
|
120
|
-
);
|
|
116
|
+
// console.log("Create Bank Failed >> ", e?.response, body);
|
|
121
117
|
failed_docs_report.push({
|
|
122
118
|
method: "create",
|
|
123
119
|
doc: body,
|
|
@@ -162,14 +158,7 @@ export const sync_bank = async (commandEvent) => {
|
|
|
162
158
|
const updated_bank = await repzo.bank.update(repzo_bank._id, body);
|
|
163
159
|
result.updated++;
|
|
164
160
|
} catch (e) {
|
|
165
|
-
console.log(
|
|
166
|
-
"Update Bank Failed >> ",
|
|
167
|
-
(_h = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
168
|
-
_h === void 0
|
|
169
|
-
? void 0
|
|
170
|
-
: _h.data,
|
|
171
|
-
body
|
|
172
|
-
);
|
|
161
|
+
// console.log("Update Bank Failed >> ", e?.response?.data, body);
|
|
173
162
|
failed_docs_report.push({
|
|
174
163
|
method: "update",
|
|
175
164
|
doc_id:
|
|
@@ -195,34 +184,34 @@ export const sync_bank = async (commandEvent) => {
|
|
|
195
184
|
per_page: 50000,
|
|
196
185
|
});
|
|
197
186
|
result.repzo_bank_list_total =
|
|
198
|
-
(
|
|
187
|
+
(_h =
|
|
199
188
|
repzo_banks === null || repzo_banks === void 0
|
|
200
189
|
? void 0
|
|
201
|
-
: repzo_banks.data) === null ||
|
|
190
|
+
: repzo_banks.data) === null || _h === void 0
|
|
202
191
|
? void 0
|
|
203
|
-
:
|
|
192
|
+
: _h.length;
|
|
204
193
|
if (
|
|
205
|
-
((
|
|
194
|
+
((_j = repzo_bankLists.data) === null || _j === void 0
|
|
206
195
|
? void 0
|
|
207
|
-
:
|
|
196
|
+
: _j.length) > 1
|
|
208
197
|
) {
|
|
209
198
|
throw `Each nameSpace should have One Bank List but nameSpace: ${nameSpace} more than one Bank List`;
|
|
210
199
|
}
|
|
211
200
|
const repzo_bank_list =
|
|
212
|
-
(
|
|
201
|
+
(_k =
|
|
213
202
|
repzo_bankLists === null || repzo_bankLists === void 0
|
|
214
203
|
? void 0
|
|
215
|
-
: repzo_bankLists.data) === null ||
|
|
204
|
+
: repzo_bankLists.data) === null || _k === void 0
|
|
216
205
|
? void 0
|
|
217
|
-
:
|
|
206
|
+
: _k[0];
|
|
218
207
|
if (repzo_bank_list) {
|
|
219
208
|
const ids = {};
|
|
220
|
-
(
|
|
209
|
+
(_l =
|
|
221
210
|
repzo_bank_list === null || repzo_bank_list === void 0
|
|
222
211
|
? void 0
|
|
223
|
-
: repzo_bank_list.banks) === null ||
|
|
212
|
+
: repzo_bank_list.banks) === null || _l === void 0
|
|
224
213
|
? void 0
|
|
225
|
-
:
|
|
214
|
+
: _l.forEach((bank) => {
|
|
226
215
|
var _a;
|
|
227
216
|
ids[
|
|
228
217
|
(_a = bank === null || bank === void 0 ? void 0 : bank.bank) ===
|
|
@@ -231,12 +220,12 @@ export const sync_bank = async (commandEvent) => {
|
|
|
231
220
|
: _a.toString()
|
|
232
221
|
] = true;
|
|
233
222
|
});
|
|
234
|
-
(
|
|
223
|
+
(_m =
|
|
235
224
|
all_nameSpace_banks === null || all_nameSpace_banks === void 0
|
|
236
225
|
? void 0
|
|
237
|
-
: all_nameSpace_banks.data) === null ||
|
|
226
|
+
: all_nameSpace_banks.data) === null || _m === void 0
|
|
238
227
|
? void 0
|
|
239
|
-
:
|
|
228
|
+
: _m.forEach((bank) => {
|
|
240
229
|
var _a;
|
|
241
230
|
ids[
|
|
242
231
|
(_a = bank === null || bank === void 0 ? void 0 : bank._id) ===
|
|
@@ -249,12 +238,12 @@ export const sync_bank = async (commandEvent) => {
|
|
|
249
238
|
return { bank: bank_id };
|
|
250
239
|
});
|
|
251
240
|
const repzo_bankList_updated = await repzo.bank_list.update(
|
|
252
|
-
(
|
|
241
|
+
(_o =
|
|
253
242
|
repzo_bank_list === null || repzo_bank_list === void 0
|
|
254
243
|
? void 0
|
|
255
|
-
: repzo_bank_list._id) === null ||
|
|
244
|
+
: repzo_bank_list._id) === null || _o === void 0
|
|
256
245
|
? void 0
|
|
257
|
-
:
|
|
246
|
+
: _o.toString(),
|
|
258
247
|
{
|
|
259
248
|
...repzo_bank_list,
|
|
260
249
|
banks: new_banks,
|
|
@@ -282,10 +271,10 @@ export const sync_bank = async (commandEvent) => {
|
|
|
282
271
|
} catch (e) {
|
|
283
272
|
//@ts-ignore
|
|
284
273
|
console.error(
|
|
285
|
-
((
|
|
286
|
-
|
|
274
|
+
((_p = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
275
|
+
_p === void 0
|
|
287
276
|
? void 0
|
|
288
|
-
:
|
|
277
|
+
: _p.data) || e
|
|
289
278
|
);
|
|
290
279
|
await commandLog.setStatus("fail", e).commit();
|
|
291
280
|
throw e;
|
package/lib/commands/basic.js
CHANGED
|
@@ -16,11 +16,10 @@ export const basic = async (commandEvent) => {
|
|
|
16
16
|
commandEvent.command
|
|
17
17
|
);
|
|
18
18
|
try {
|
|
19
|
-
console.log("basic sync");
|
|
19
|
+
// console.log("basic sync");
|
|
20
20
|
await commandLog.load(commandEvent.sync_id);
|
|
21
21
|
await commandLog.addDetail("Repzo SAP: Basic Sync").commit();
|
|
22
22
|
const required_syncing_commands = [
|
|
23
|
-
"join",
|
|
24
23
|
"warehouse",
|
|
25
24
|
"rep",
|
|
26
25
|
"tax",
|
package/lib/commands/category.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Repzo from "repzo";
|
|
2
2
|
import { _create, update_bench_time, set_error } from "../util.js";
|
|
3
3
|
export const sync_category = async (commandEvent) => {
|
|
4
|
-
var _a, _b, _c, _d, _e, _f
|
|
4
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5
5
|
const repzo = new Repzo(
|
|
6
6
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
7
7
|
? void 0
|
|
@@ -16,7 +16,7 @@ export const sync_category = async (commandEvent) => {
|
|
|
16
16
|
commandEvent.command
|
|
17
17
|
);
|
|
18
18
|
try {
|
|
19
|
-
console.log("sync_category");
|
|
19
|
+
// console.log("sync_category");
|
|
20
20
|
const new_bench_time = new Date().toISOString();
|
|
21
21
|
const bench_time_key = "bench_time_category";
|
|
22
22
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -94,11 +94,7 @@ export const sync_category = async (commandEvent) => {
|
|
|
94
94
|
const created_category = await repzo.category.create(body);
|
|
95
95
|
result.created++;
|
|
96
96
|
} catch (e) {
|
|
97
|
-
console.log(
|
|
98
|
-
"Create Product Category Failed >> ",
|
|
99
|
-
e === null || e === void 0 ? void 0 : e.response,
|
|
100
|
-
body
|
|
101
|
-
);
|
|
97
|
+
// console.log("Create Product Category Failed >> ", e?.response, body);
|
|
102
98
|
failed_docs_report.push({
|
|
103
99
|
method: "create",
|
|
104
100
|
doc: body,
|
|
@@ -135,14 +131,11 @@ export const sync_category = async (commandEvent) => {
|
|
|
135
131
|
);
|
|
136
132
|
result.updated++;
|
|
137
133
|
} catch (e) {
|
|
138
|
-
console.log(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
: _f.data,
|
|
144
|
-
body
|
|
145
|
-
);
|
|
134
|
+
// console.log(
|
|
135
|
+
// "Update Product Category Failed >> ",
|
|
136
|
+
// e?.response?.data,
|
|
137
|
+
// body
|
|
138
|
+
// );
|
|
146
139
|
failed_docs_report.push({
|
|
147
140
|
method: "update",
|
|
148
141
|
doc_id:
|
|
@@ -174,10 +167,10 @@ export const sync_category = async (commandEvent) => {
|
|
|
174
167
|
} catch (e) {
|
|
175
168
|
//@ts-ignore
|
|
176
169
|
console.error(
|
|
177
|
-
((
|
|
178
|
-
|
|
170
|
+
((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
171
|
+
_f === void 0
|
|
179
172
|
? void 0
|
|
180
|
-
:
|
|
173
|
+
: _f.data) || e
|
|
181
174
|
);
|
|
182
175
|
await commandLog.setStatus("fail", e).commit();
|
|
183
176
|
throw e;
|
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;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -21,7 +21,7 @@ export const sync_channel = async (commandEvent) => {
|
|
|
21
21
|
commandEvent.command
|
|
22
22
|
);
|
|
23
23
|
try {
|
|
24
|
-
console.log("sync_channel");
|
|
24
|
+
// console.log("sync_channel");
|
|
25
25
|
const new_bench_time = new Date().toISOString();
|
|
26
26
|
const bench_time_key = "bench_time_channel";
|
|
27
27
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -114,11 +114,7 @@ export const sync_channel = async (commandEvent) => {
|
|
|
114
114
|
const created_channel = await repzo.channel.create(body);
|
|
115
115
|
result.created++;
|
|
116
116
|
} catch (e) {
|
|
117
|
-
console.log(
|
|
118
|
-
"Create Client Channel Failed >> ",
|
|
119
|
-
e === null || e === void 0 ? void 0 : e.response,
|
|
120
|
-
body
|
|
121
|
-
);
|
|
117
|
+
// console.log("Create Client Channel Failed >> ", e?.response, body);
|
|
122
118
|
failed_docs_report.push({
|
|
123
119
|
method: "create",
|
|
124
120
|
doc: body,
|
|
@@ -146,14 +142,11 @@ export const sync_channel = async (commandEvent) => {
|
|
|
146
142
|
);
|
|
147
143
|
result.updated++;
|
|
148
144
|
} catch (e) {
|
|
149
|
-
console.log(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
: _d.data,
|
|
155
|
-
body
|
|
156
|
-
);
|
|
145
|
+
// console.log(
|
|
146
|
+
// "Update Client Channel Failed >> ",
|
|
147
|
+
// e?.response?.data,
|
|
148
|
+
// body
|
|
149
|
+
// );
|
|
157
150
|
failed_docs_report.push({
|
|
158
151
|
method: "update",
|
|
159
152
|
doc_id:
|
|
@@ -185,10 +178,10 @@ export const sync_channel = async (commandEvent) => {
|
|
|
185
178
|
} catch (e) {
|
|
186
179
|
//@ts-ignore
|
|
187
180
|
console.error(
|
|
188
|
-
((
|
|
189
|
-
|
|
181
|
+
((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
182
|
+
_d === void 0
|
|
190
183
|
? void 0
|
|
191
|
-
:
|
|
184
|
+
: _d.data) || e
|
|
192
185
|
);
|
|
193
186
|
await commandLog.setStatus("fail", e).commit();
|
|
194
187
|
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;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -21,7 +21,7 @@ export const sync_client = async (commandEvent) => {
|
|
|
21
21
|
commandEvent.command
|
|
22
22
|
);
|
|
23
23
|
try {
|
|
24
|
-
console.log("sync_client");
|
|
24
|
+
// console.log("sync_client");
|
|
25
25
|
const new_bench_time = new Date().toISOString();
|
|
26
26
|
const bench_time_key = "bench_time_client";
|
|
27
27
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -243,11 +243,7 @@ export const sync_client = async (commandEvent) => {
|
|
|
243
243
|
const created_client = await repzo.client.create(body);
|
|
244
244
|
result.created++;
|
|
245
245
|
} catch (e) {
|
|
246
|
-
console.log(
|
|
247
|
-
"Create Client Failed >> ",
|
|
248
|
-
e === null || e === void 0 ? void 0 : e.response,
|
|
249
|
-
body
|
|
250
|
-
);
|
|
246
|
+
// console.log("Create Client Failed >> ", e?.response, body);
|
|
251
247
|
failed_docs_report.push({
|
|
252
248
|
method: "create",
|
|
253
249
|
doc: body,
|
|
@@ -269,14 +265,7 @@ export const sync_client = async (commandEvent) => {
|
|
|
269
265
|
);
|
|
270
266
|
result.updated++;
|
|
271
267
|
} catch (e) {
|
|
272
|
-
console.log(
|
|
273
|
-
"Update Client Failed >> ",
|
|
274
|
-
(_h = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
275
|
-
_h === void 0
|
|
276
|
-
? void 0
|
|
277
|
-
: _h.data,
|
|
278
|
-
body
|
|
279
|
-
);
|
|
268
|
+
// console.log("Update Client Failed >> ", e?.response?.data, body);
|
|
280
269
|
failed_docs_report.push({
|
|
281
270
|
method: "update",
|
|
282
271
|
doc_id:
|
|
@@ -308,10 +297,10 @@ export const sync_client = async (commandEvent) => {
|
|
|
308
297
|
} catch (e) {
|
|
309
298
|
//@ts-ignore
|
|
310
299
|
console.error(
|
|
311
|
-
((
|
|
312
|
-
|
|
300
|
+
((_h = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
301
|
+
_h === void 0
|
|
313
302
|
? void 0
|
|
314
|
-
:
|
|
303
|
+
: _h.data) || e
|
|
315
304
|
);
|
|
316
305
|
await commandLog.setStatus("fail", e).commit();
|
|
317
306
|
throw e;
|
|
@@ -335,7 +324,7 @@ const get_sap_clients = async (serviceEndPoint, query) => {
|
|
|
335
324
|
}
|
|
336
325
|
};
|
|
337
326
|
const is_matched = (body_1, body_2) => {
|
|
338
|
-
var _a, _b, _c, _d, _e, _f;
|
|
327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
339
328
|
try {
|
|
340
329
|
const keys = [
|
|
341
330
|
"client_code",
|
|
@@ -351,7 +340,7 @@ const is_matched = (body_1, body_2) => {
|
|
|
351
340
|
"formatted_address",
|
|
352
341
|
"tags",
|
|
353
342
|
"credit_limit",
|
|
354
|
-
"financials",
|
|
343
|
+
// "financials",
|
|
355
344
|
"channel",
|
|
356
345
|
"paymentTerm",
|
|
357
346
|
"sv_priceList",
|
|
@@ -403,6 +392,28 @@ const is_matched = (body_1, body_2) => {
|
|
|
403
392
|
return false;
|
|
404
393
|
}
|
|
405
394
|
}
|
|
395
|
+
if (
|
|
396
|
+
((_h =
|
|
397
|
+
(_g =
|
|
398
|
+
body_1 === null || body_1 === void 0
|
|
399
|
+
? void 0
|
|
400
|
+
: body_1.integration_meta) === null || _g === void 0
|
|
401
|
+
? void 0
|
|
402
|
+
: _g["financials"]) === null || _h === void 0
|
|
403
|
+
? void 0
|
|
404
|
+
: _h.credit_limit) !==
|
|
405
|
+
((_k =
|
|
406
|
+
(_j =
|
|
407
|
+
body_2 === null || body_2 === void 0
|
|
408
|
+
? void 0
|
|
409
|
+
: body_2.integration_meta) === null || _j === void 0
|
|
410
|
+
? void 0
|
|
411
|
+
: _j["financials"]) === null || _k === void 0
|
|
412
|
+
? void 0
|
|
413
|
+
: _k.credit_limit)
|
|
414
|
+
) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
406
417
|
return true;
|
|
407
418
|
} catch (e) {
|
|
408
419
|
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
|
|
9
|
+
var _a, _b, _c;
|
|
10
10
|
const repzo = new Repzo(
|
|
11
11
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
12
12
|
? void 0
|
|
@@ -21,7 +21,7 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
21
21
|
commandEvent.command
|
|
22
22
|
);
|
|
23
23
|
try {
|
|
24
|
-
console.log("sync_disabled_client");
|
|
24
|
+
// console.log("sync_disabled_client");
|
|
25
25
|
const new_bench_time = new Date().toISOString();
|
|
26
26
|
const bench_time_key = "bench_time_disabled_client";
|
|
27
27
|
await commandLog.load(commandEvent.sync_id);
|
|
@@ -114,16 +114,9 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
114
114
|
const disabled_client = await repzo.client.remove(repzo_client._id);
|
|
115
115
|
result.updated++;
|
|
116
116
|
} catch (e) {
|
|
117
|
-
console.log(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
_c === void 0
|
|
121
|
-
? void 0
|
|
122
|
-
: _c.data,
|
|
123
|
-
{
|
|
124
|
-
CLIENTID: sap_client.CLIENTID,
|
|
125
|
-
}
|
|
126
|
-
);
|
|
117
|
+
// console.log("Disable Client Failed >> ", e?.response?.data, {
|
|
118
|
+
// CLIENTID: sap_client.CLIENTID,
|
|
119
|
+
// });
|
|
127
120
|
failed_docs_report.push({
|
|
128
121
|
method: "delete",
|
|
129
122
|
doc_id:
|
|
@@ -155,10 +148,10 @@ export const sync_disabled_client = async (commandEvent) => {
|
|
|
155
148
|
} catch (e) {
|
|
156
149
|
//@ts-ignore
|
|
157
150
|
console.error(
|
|
158
|
-
((
|
|
159
|
-
|
|
151
|
+
((_c = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
152
|
+
_c === void 0
|
|
160
153
|
? void 0
|
|
161
|
-
:
|
|
154
|
+
: _c.data) || e
|
|
162
155
|
);
|
|
163
156
|
await commandLog.setStatus("fail", e).commit();
|
|
164
157
|
throw e;
|