repzo-sap-absjo 1.0.6 → 1.0.7
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 +3 -0
- package/lib/actions/create_invoice.js +37 -0
- package/lib/actions/create_payment.js +37 -0
- package/lib/actions/create_proforma.js +37 -0
- package/lib/actions/create_return_invoice.js +37 -0
- package/lib/actions/create_transfer.js +37 -0
- package/lib/commands/price_list.js +54 -12
- package/lib/test/commands/price_list.js +263 -13
- package/package.json +1 -1
- package/src/actions/create_invoice.ts +34 -0
- package/src/actions/create_payment.ts +34 -0
- package/src/actions/create_proforma.ts +34 -0
- package/src/actions/create_return_invoice.ts +34 -0
- package/src/actions/create_transfer.ts +33 -0
- package/src/commands/price_list.ts +40 -4
- package/src/test/commands/price_list.ts +263 -13
package/changelog.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
- [actions/***] add 2 keys in integration_meta: sync_to_sap_started & sync_to_sap_succeeded @maramalshen
|
|
8
|
+
|
|
7
9
|
### Changed
|
|
8
10
|
|
|
9
11
|
- [commands/rep] delete hard code of rep.warehouse for reps start with: [WS, RET, MT] @maramalshen
|
|
@@ -12,6 +14,7 @@
|
|
|
12
14
|
### Fixed
|
|
13
15
|
|
|
14
16
|
- [command/measureunit-family] use _.xor instead or _.difference @maramalshen
|
|
17
|
+
- [command/price_list] fix bug in priceList-item @maramalshen
|
|
15
18
|
|
|
16
19
|
### Removed
|
|
17
20
|
|
|
@@ -27,6 +27,25 @@ export const create_invoice = async (event, options) => {
|
|
|
27
27
|
null || _c === void 0
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
|
+
try {
|
|
31
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
32
|
+
body.integration_meta =
|
|
33
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
34
|
+
{};
|
|
35
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
36
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
37
|
+
await repzo.invoice.update(body._id, {
|
|
38
|
+
integration_meta: body.integration_meta,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e);
|
|
43
|
+
await actionLog
|
|
44
|
+
.addDetail(
|
|
45
|
+
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
46
|
+
)
|
|
47
|
+
.commit();
|
|
48
|
+
}
|
|
30
49
|
await actionLog
|
|
31
50
|
.addDetail(
|
|
32
51
|
`Invoice - ${repzo_serial_number} => ${
|
|
@@ -319,6 +338,24 @@ export const create_invoice = async (event, options) => {
|
|
|
319
338
|
.commit();
|
|
320
339
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
321
340
|
// console.log(result);
|
|
341
|
+
try {
|
|
342
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
343
|
+
body.integration_meta =
|
|
344
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
345
|
+
{};
|
|
346
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
347
|
+
await repzo.invoice.update(body._id, {
|
|
348
|
+
integration_meta: body.integration_meta,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
} catch (e) {
|
|
352
|
+
console.error(e);
|
|
353
|
+
await actionLog
|
|
354
|
+
.addDetail(
|
|
355
|
+
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
356
|
+
)
|
|
357
|
+
.commit();
|
|
358
|
+
}
|
|
322
359
|
await actionLog
|
|
323
360
|
.addDetail(`SAP Responded with `, result)
|
|
324
361
|
.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`)
|
|
@@ -28,6 +28,25 @@ export const create_payment = async (event, options) => {
|
|
|
28
28
|
null || _c === void 0
|
|
29
29
|
? void 0
|
|
30
30
|
: _c.formatted;
|
|
31
|
+
try {
|
|
32
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
33
|
+
body.integration_meta =
|
|
34
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
35
|
+
{};
|
|
36
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
37
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
38
|
+
await repzo.payment.update(body._id, {
|
|
39
|
+
integration_meta: body.integration_meta,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(e);
|
|
44
|
+
await actionLog
|
|
45
|
+
.addDetail(
|
|
46
|
+
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
47
|
+
)
|
|
48
|
+
.commit();
|
|
49
|
+
}
|
|
31
50
|
await actionLog
|
|
32
51
|
.addDetail(
|
|
33
52
|
`Payment - ${repzo_serial_number} => ${
|
|
@@ -166,6 +185,24 @@ export const create_payment = async (event, options) => {
|
|
|
166
185
|
.commit();
|
|
167
186
|
const result = await _create(SAP_HOST_URL, "/AddPayment", sap_payment);
|
|
168
187
|
// console.log(result);
|
|
188
|
+
try {
|
|
189
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
190
|
+
body.integration_meta =
|
|
191
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
192
|
+
{};
|
|
193
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
194
|
+
await repzo.payment.update(body._id, {
|
|
195
|
+
integration_meta: body.integration_meta,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
} catch (e) {
|
|
199
|
+
console.error(e);
|
|
200
|
+
await actionLog
|
|
201
|
+
.addDetail(
|
|
202
|
+
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
203
|
+
)
|
|
204
|
+
.commit();
|
|
205
|
+
}
|
|
169
206
|
await actionLog
|
|
170
207
|
.addDetail(`SAP Responded with `, result)
|
|
171
208
|
.addDetail(`Repzo => SAP: Payment - ${repzo_serial_number}`)
|
|
@@ -27,6 +27,25 @@ export const create_proforma = async (event, options) => {
|
|
|
27
27
|
null || _c === void 0
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
|
+
try {
|
|
31
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
32
|
+
body.integration_meta =
|
|
33
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
34
|
+
{};
|
|
35
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
36
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
37
|
+
await repzo.proforma.update(body._id, {
|
|
38
|
+
integration_meta: body.integration_meta,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e);
|
|
43
|
+
await actionLog
|
|
44
|
+
.addDetail(
|
|
45
|
+
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
46
|
+
)
|
|
47
|
+
.commit();
|
|
48
|
+
}
|
|
30
49
|
await actionLog
|
|
31
50
|
.addDetail(
|
|
32
51
|
`SalesOrder - ${repzo_serial_number} => ${
|
|
@@ -263,6 +282,24 @@ export const create_proforma = async (event, options) => {
|
|
|
263
282
|
.commit();
|
|
264
283
|
const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
265
284
|
// console.log(result);
|
|
285
|
+
try {
|
|
286
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
287
|
+
body.integration_meta =
|
|
288
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
289
|
+
{};
|
|
290
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
291
|
+
await repzo.proforma.update(body._id, {
|
|
292
|
+
integration_meta: body.integration_meta,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
} catch (e) {
|
|
296
|
+
console.error(e);
|
|
297
|
+
await actionLog
|
|
298
|
+
.addDetail(
|
|
299
|
+
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
300
|
+
)
|
|
301
|
+
.commit();
|
|
302
|
+
}
|
|
266
303
|
await actionLog
|
|
267
304
|
.addDetail(`SAP Responded with `, result)
|
|
268
305
|
.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
|
|
@@ -27,6 +27,25 @@ export const create_return_invoice = async (event, options) => {
|
|
|
27
27
|
null || _c === void 0
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
|
+
try {
|
|
31
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
32
|
+
body.integration_meta =
|
|
33
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
34
|
+
{};
|
|
35
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
36
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
37
|
+
await repzo.invoice.update(body._id, {
|
|
38
|
+
integration_meta: body.integration_meta,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e);
|
|
43
|
+
await actionLog
|
|
44
|
+
.addDetail(
|
|
45
|
+
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
46
|
+
)
|
|
47
|
+
.commit();
|
|
48
|
+
}
|
|
30
49
|
await actionLog
|
|
31
50
|
.addDetail(
|
|
32
51
|
`Return Invoice - ${repzo_serial_number} => ${
|
|
@@ -290,6 +309,24 @@ export const create_return_invoice = async (event, options) => {
|
|
|
290
309
|
sap_return_invoice
|
|
291
310
|
);
|
|
292
311
|
// console.log(result);
|
|
312
|
+
try {
|
|
313
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
314
|
+
body.integration_meta =
|
|
315
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
316
|
+
{};
|
|
317
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
318
|
+
await repzo.invoice.update(body._id, {
|
|
319
|
+
integration_meta: body.integration_meta,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
} catch (e) {
|
|
323
|
+
console.error(e);
|
|
324
|
+
await actionLog
|
|
325
|
+
.addDetail(
|
|
326
|
+
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
327
|
+
)
|
|
328
|
+
.commit();
|
|
329
|
+
}
|
|
293
330
|
await actionLog
|
|
294
331
|
.addDetail(`SAP Responded with `, result)
|
|
295
332
|
.addDetail(`Repzo => SAP: Return Invoice - ${repzo_serial_number}`)
|
|
@@ -26,6 +26,25 @@ export const create_transfer = async (event, options) => {
|
|
|
26
26
|
null || _c === void 0
|
|
27
27
|
? void 0
|
|
28
28
|
: _c.formatted;
|
|
29
|
+
try {
|
|
30
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
31
|
+
body.integration_meta =
|
|
32
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
33
|
+
{};
|
|
34
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
35
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
36
|
+
await repzo.transfer.update(body._id, {
|
|
37
|
+
integration_meta: body.integration_meta,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error(e);
|
|
42
|
+
await actionLog
|
|
43
|
+
.addDetail(
|
|
44
|
+
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
45
|
+
)
|
|
46
|
+
.commit();
|
|
47
|
+
}
|
|
29
48
|
await actionLog
|
|
30
49
|
.addDetail(
|
|
31
50
|
`Transfer - ${repzo_serial_number} => ${
|
|
@@ -170,6 +189,24 @@ export const create_transfer = async (event, options) => {
|
|
|
170
189
|
sap_transfer
|
|
171
190
|
);
|
|
172
191
|
// console.log(result);
|
|
192
|
+
try {
|
|
193
|
+
if (body === null || body === void 0 ? void 0 : body._id) {
|
|
194
|
+
body.integration_meta =
|
|
195
|
+
(body === null || body === void 0 ? void 0 : body.integration_meta) ||
|
|
196
|
+
{};
|
|
197
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
198
|
+
await repzo.transfer.update(body._id, {
|
|
199
|
+
integration_meta: body.integration_meta,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
} catch (e) {
|
|
203
|
+
console.error(e);
|
|
204
|
+
await actionLog
|
|
205
|
+
.addDetail(
|
|
206
|
+
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
207
|
+
)
|
|
208
|
+
.commit();
|
|
209
|
+
}
|
|
173
210
|
await actionLog
|
|
174
211
|
.addDetail(`SAP Responded with `, result)
|
|
175
212
|
.addDetail(`Repzo => SAP: Transfer - ${repzo_serial_number}`)
|
|
@@ -163,6 +163,24 @@ export const sync_price_list = async (commandEvent) => {
|
|
|
163
163
|
const key = `${doc.ITEMCODE}__${doc.ALTUOMCODE}`;
|
|
164
164
|
sap_unique_UoMs[key] = doc.ALTQTY;
|
|
165
165
|
});
|
|
166
|
+
// Get Repzo {Product_sku : product_default_measureunit_name}
|
|
167
|
+
const repzo_product_default_measureunit = {};
|
|
168
|
+
repzo_products.data.forEach((product) => {
|
|
169
|
+
if (!product.sku) return;
|
|
170
|
+
if (!product.sv_measureUnit) {
|
|
171
|
+
repzo_product_default_measureunit[product.sku] = null;
|
|
172
|
+
} else {
|
|
173
|
+
const default_measureunit = repzo_UoMs.data.find(
|
|
174
|
+
(m) => m._id == product.sv_measureUnit
|
|
175
|
+
);
|
|
176
|
+
if (default_measureunit) {
|
|
177
|
+
repzo_product_default_measureunit[product.sku] =
|
|
178
|
+
default_measureunit.name;
|
|
179
|
+
} else {
|
|
180
|
+
repzo_product_default_measureunit[product.sku] = null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
166
184
|
// sort the data
|
|
167
185
|
const priceLists_withItems = {};
|
|
168
186
|
sap_price_lists.forEach((doc) => {
|
|
@@ -338,12 +356,22 @@ export const sync_price_list = async (commandEvent) => {
|
|
|
338
356
|
} else {
|
|
339
357
|
const current_doc = priceList_items[key];
|
|
340
358
|
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
: current_doc.factor) >
|
|
344
|
-
(doc === null || doc === void 0 ? void 0 : doc.factor)
|
|
359
|
+
current_doc.PLITEMUNIT !=
|
|
360
|
+
repzo_product_default_measureunit[current_doc.PLITEMID]
|
|
345
361
|
) {
|
|
346
|
-
|
|
362
|
+
if (
|
|
363
|
+
doc.PLITEMUNIT ==
|
|
364
|
+
repzo_product_default_measureunit[current_doc.PLITEMID]
|
|
365
|
+
) {
|
|
366
|
+
priceList_items[key] = doc;
|
|
367
|
+
} else if (
|
|
368
|
+
(current_doc === null || current_doc === void 0
|
|
369
|
+
? void 0
|
|
370
|
+
: current_doc.factor) >
|
|
371
|
+
(doc === null || doc === void 0 ? void 0 : doc.factor)
|
|
372
|
+
) {
|
|
373
|
+
priceList_items[key] = doc;
|
|
374
|
+
}
|
|
347
375
|
}
|
|
348
376
|
}
|
|
349
377
|
});
|
|
@@ -389,27 +417,41 @@ export const sync_price_list = async (commandEvent) => {
|
|
|
389
417
|
result.PL_items.failed++;
|
|
390
418
|
continue;
|
|
391
419
|
}
|
|
392
|
-
const
|
|
420
|
+
const repzo_product_uoms =
|
|
393
421
|
(_q =
|
|
394
422
|
repzo_UoMs === null || repzo_UoMs === void 0
|
|
395
423
|
? void 0
|
|
396
424
|
: repzo_UoMs.data) === null || _q === void 0
|
|
397
425
|
? void 0
|
|
398
|
-
: _q.
|
|
399
|
-
var _a, _b;
|
|
426
|
+
: _q.filter((uom) => {
|
|
427
|
+
var _a, _b, _c, _d;
|
|
400
428
|
return (
|
|
401
429
|
((_a = uom === null || uom === void 0 ? void 0 : uom._id) ===
|
|
402
430
|
null || _a === void 0
|
|
403
431
|
? void 0
|
|
404
432
|
: _a.toString()) ==
|
|
405
|
-
|
|
406
|
-
|
|
433
|
+
((_b =
|
|
434
|
+
repzo_product === null || repzo_product === void 0
|
|
435
|
+
? void 0
|
|
436
|
+
: repzo_product.sv_measureUnit) === null ||
|
|
437
|
+
_b === void 0
|
|
407
438
|
? void 0
|
|
408
|
-
:
|
|
439
|
+
: _b.toString()) ||
|
|
440
|
+
((_c = repzo_product.measureunit_family) === null ||
|
|
441
|
+
_c === void 0
|
|
409
442
|
? void 0
|
|
410
|
-
:
|
|
443
|
+
: _c.includes(
|
|
444
|
+
(_d =
|
|
445
|
+
uom === null || uom === void 0 ? void 0 : uom._id) ===
|
|
446
|
+
null || _d === void 0
|
|
447
|
+
? void 0
|
|
448
|
+
: _d.toString()
|
|
449
|
+
))
|
|
411
450
|
);
|
|
412
451
|
});
|
|
452
|
+
const repzo_product_uom = repzo_product_uoms.find(
|
|
453
|
+
(uom) => uom.name == item.PLITEMUNIT
|
|
454
|
+
);
|
|
413
455
|
if (!repzo_product_uom) {
|
|
414
456
|
failed_docs_report.push({
|
|
415
457
|
method: "create",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Commands } from "../../index.js";
|
|
2
2
|
let commandEvent = {
|
|
3
3
|
app: {
|
|
4
|
-
_id: "
|
|
4
|
+
_id: "639f0bf52070c5be595e955c",
|
|
5
5
|
name: "SAP",
|
|
6
6
|
disabled: false,
|
|
7
7
|
available_app: {
|
|
8
8
|
_id: "6391a268db71ef64357195da",
|
|
9
9
|
name: "repzo-sap-absjo",
|
|
10
10
|
title: "SAP ABS JO",
|
|
11
|
-
logo: "https://
|
|
12
|
-
description:
|
|
11
|
+
logo: "https://prod-repzo-media-service.s3.us-east-1.amazonaws.com/repzo/image/2022/12/18/3f73de7d-1920-4786-90db-57c76d18acci-SAP_EBS_JO.png",
|
|
12
|
+
description:
|
|
13
|
+
"SAP Jordan. We provide real value to SMEs by understanding their business and driving their vision forward with SAP Business One",
|
|
13
14
|
disabled: false,
|
|
14
15
|
JSONSchema: {
|
|
15
16
|
title: "SAP Integration Settings",
|
|
@@ -29,11 +30,95 @@ let commandEvent = {
|
|
|
29
30
|
format: "email",
|
|
30
31
|
title: "Email in case of error",
|
|
31
32
|
},
|
|
33
|
+
GroupCode: {
|
|
34
|
+
type: "string",
|
|
35
|
+
format: "string",
|
|
36
|
+
title: "Customers GroupCode",
|
|
37
|
+
},
|
|
32
38
|
warehouseDefaultUpdateDate: {
|
|
33
39
|
type: "string",
|
|
34
40
|
format: "date",
|
|
35
41
|
title: "Warehouse: Default Update Date",
|
|
36
42
|
},
|
|
43
|
+
DepartmentCode: {
|
|
44
|
+
type: "string",
|
|
45
|
+
format: "string",
|
|
46
|
+
title: "Invoice/Return Department Code",
|
|
47
|
+
},
|
|
48
|
+
return_reason: {
|
|
49
|
+
type: "string",
|
|
50
|
+
format: "string",
|
|
51
|
+
title: "Return Reason Array",
|
|
52
|
+
},
|
|
53
|
+
SalPersCode: {
|
|
54
|
+
type: "string",
|
|
55
|
+
format: "string",
|
|
56
|
+
title: "Default Sales Person Code For Sales Orders",
|
|
57
|
+
},
|
|
58
|
+
SalesPersonCode: {
|
|
59
|
+
type: "string",
|
|
60
|
+
format: "string",
|
|
61
|
+
title: "Default Sales Person Code For Transfer",
|
|
62
|
+
},
|
|
63
|
+
invoices: {
|
|
64
|
+
type: "object",
|
|
65
|
+
title: "Invoices",
|
|
66
|
+
required: ["createInvoiceHook", "createReturnInvoiceHook"],
|
|
67
|
+
properties: {
|
|
68
|
+
createInvoiceHook: {
|
|
69
|
+
type: "boolean",
|
|
70
|
+
title: "Live Sync Invoices from Repzo to SAP",
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
createReturnInvoiceHook: {
|
|
74
|
+
type: "boolean",
|
|
75
|
+
title: "Live Sync Return Invoice from Repzo to SAP",
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
payments: {
|
|
81
|
+
type: "object",
|
|
82
|
+
title: "Payments",
|
|
83
|
+
required: ["createPaymentHook"],
|
|
84
|
+
properties: {
|
|
85
|
+
createPaymentHook: {
|
|
86
|
+
type: "boolean",
|
|
87
|
+
title: "Live Sync Payments from Repzo to SAP",
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
proformas: {
|
|
93
|
+
type: "object",
|
|
94
|
+
title: "Sales Orders",
|
|
95
|
+
required: ["createApprovedProformaHook"],
|
|
96
|
+
properties: {
|
|
97
|
+
createApprovedProformaHook: {
|
|
98
|
+
type: "boolean",
|
|
99
|
+
title: "Live Sync Approved Sales Orders from Repzo to SAP",
|
|
100
|
+
default: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
transfers: {
|
|
105
|
+
type: "object",
|
|
106
|
+
title: "Transfers",
|
|
107
|
+
required: ["createApprovedTransferHook"],
|
|
108
|
+
properties: {
|
|
109
|
+
createApprovedTransferHook: {
|
|
110
|
+
type: "boolean",
|
|
111
|
+
title: "Live Sync Approved Transfers from Repzo to SAP",
|
|
112
|
+
default: false,
|
|
113
|
+
},
|
|
114
|
+
adjustInventoryInFailedTransfer: {
|
|
115
|
+
type: "boolean",
|
|
116
|
+
title:
|
|
117
|
+
"Adjust Inventories in Repzo if creation Transfer Failed in SAP",
|
|
118
|
+
default: false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
37
122
|
},
|
|
38
123
|
},
|
|
39
124
|
options_JSONSchema: {
|
|
@@ -46,6 +131,41 @@ let commandEvent = {
|
|
|
46
131
|
type: "string",
|
|
47
132
|
format: "date",
|
|
48
133
|
},
|
|
134
|
+
bench_time_channel: {
|
|
135
|
+
title: "Bench Time: Channels",
|
|
136
|
+
type: "string",
|
|
137
|
+
format: "date-time",
|
|
138
|
+
},
|
|
139
|
+
bench_time_payment_term: {
|
|
140
|
+
title: "Bench Time: Payment Terms",
|
|
141
|
+
type: "string",
|
|
142
|
+
format: "date-time",
|
|
143
|
+
},
|
|
144
|
+
bench_time_product: {
|
|
145
|
+
title: "Bench Time: Products",
|
|
146
|
+
type: "string",
|
|
147
|
+
format: "date-time",
|
|
148
|
+
},
|
|
149
|
+
bench_time_product_disabled: {
|
|
150
|
+
title: "Bench Time: Inactive Products",
|
|
151
|
+
type: "string",
|
|
152
|
+
format: "date-time",
|
|
153
|
+
},
|
|
154
|
+
bench_time_price_list: {
|
|
155
|
+
title: "Bench Time: Price List",
|
|
156
|
+
type: "string",
|
|
157
|
+
format: "date-time",
|
|
158
|
+
},
|
|
159
|
+
bench_time_client: {
|
|
160
|
+
title: "Bench Time: Clients",
|
|
161
|
+
type: "string",
|
|
162
|
+
format: "date-time",
|
|
163
|
+
},
|
|
164
|
+
bench_time_disabled_client: {
|
|
165
|
+
title: "Bench Time: Inactive Clients",
|
|
166
|
+
type: "string",
|
|
167
|
+
format: "date-time",
|
|
168
|
+
},
|
|
49
169
|
},
|
|
50
170
|
},
|
|
51
171
|
app_settings: {
|
|
@@ -67,31 +187,161 @@ let commandEvent = {
|
|
|
67
187
|
description: "",
|
|
68
188
|
_id: "6391a268db71ef64357195dd",
|
|
69
189
|
},
|
|
190
|
+
{
|
|
191
|
+
command: "warehouse",
|
|
192
|
+
name: "Sync Warehouse",
|
|
193
|
+
description: "Sync Warehouses From SAP to Repzo",
|
|
194
|
+
_id: "6391c42a1b0f4f7a30e40f40",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
command: "rep",
|
|
198
|
+
name: "Sync Representatives",
|
|
199
|
+
description: "Sync Representatives From SAP to Repzo",
|
|
200
|
+
_id: "639715c2bee5dd4b6b11e129",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
command: "tax",
|
|
204
|
+
name: "Sync Taxes",
|
|
205
|
+
description: "Sync Taxes From SAP to Repzo",
|
|
206
|
+
_id: "639715c2bee5dd4b6b11e12a",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
command: "tag",
|
|
210
|
+
name: "Sync Area Tags",
|
|
211
|
+
description: "Sync Area Tags From SAP to Repzo",
|
|
212
|
+
_id: "639715c2bee5dd4b6b11e12b",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
command: "measureunit",
|
|
216
|
+
name: "Sync Measure Units",
|
|
217
|
+
description: "Sync Measure Units From SAP to Repzo",
|
|
218
|
+
_id: "639817eaedafde008af0ad0e",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
command: "measureunit_family",
|
|
222
|
+
name: "Sync Measure Units Family",
|
|
223
|
+
description: "Sync Measure Units Family From SAP to Repzo",
|
|
224
|
+
_id: "63982d09edafde008af0f698",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
command: "category",
|
|
228
|
+
name: "Sync Product Category",
|
|
229
|
+
description: "Sync Product Categories From SAP to Repzo",
|
|
230
|
+
_id: "63984085edafde008af2f689",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
command: "channel",
|
|
234
|
+
name: "Sync Client's Channels",
|
|
235
|
+
description: "Sync Client's Channels From SAP to Repzo",
|
|
236
|
+
_id: "63984085edafde008af2f689",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
command: "payment_term",
|
|
240
|
+
name: "Sync Payments Term",
|
|
241
|
+
description: "Sync Payments Term From SAP to Repzo",
|
|
242
|
+
_id: "63984085edafde008af2f68a",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
command: "bank",
|
|
246
|
+
name: "Sync Banks",
|
|
247
|
+
description: "Sync Banks From SAP to Repzo",
|
|
248
|
+
_id: "63986018333b84929c538570",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
command: "product",
|
|
252
|
+
name: "Sync Products",
|
|
253
|
+
description: "Sync Active Products From SAP to Repzo",
|
|
254
|
+
_id: "63987139333b84929c53a293",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
command: "disabled_product",
|
|
258
|
+
name: "Sync Inactive Products",
|
|
259
|
+
description: "Sync Inactive Products From SAP to Repzo",
|
|
260
|
+
_id: "6399714d0242db686d496466",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
command: "price_list",
|
|
264
|
+
name: "Sync Price Lists",
|
|
265
|
+
description: "Sync Price Lists From SAP to Repzo",
|
|
266
|
+
_id: "639972d6e8a1cfdd26deaa7e",
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
command: "client",
|
|
270
|
+
name: "Sync Clients",
|
|
271
|
+
description: "Sync Clients From SAP to Repzo",
|
|
272
|
+
_id: "63997615e8a1cfdd26ded7d1",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
command: "disabled_client",
|
|
276
|
+
name: "Sync Inactive Clients",
|
|
277
|
+
description: "Sync Inactive Clients From SAP to Repzo",
|
|
278
|
+
_id: "639ac554e157f1c63770c1bc",
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
command: "adjust_inventory",
|
|
282
|
+
name: "Adjust Inventories",
|
|
283
|
+
description: "Adjust Inventories From SAP to Repzo",
|
|
284
|
+
_id: "639ac56fe157f1c63770c2eb",
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
actions: [
|
|
288
|
+
{
|
|
289
|
+
action: "create_invoice",
|
|
290
|
+
name: "Sync Invoices",
|
|
291
|
+
description: "Sync Invoices From Repzo to SAP",
|
|
292
|
+
_id: "639ebeacdbba64d7af94520c",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
action: "create_return_invoice",
|
|
296
|
+
name: "Sync Return Invoices",
|
|
297
|
+
description: "Sync Return Invoices From Repzo to SAP",
|
|
298
|
+
_id: "639ebeacdbba64d7af94520d",
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
action: "create_proforma",
|
|
302
|
+
name: "Sync Approved Sales Orders",
|
|
303
|
+
description: "Sync Approved Sales Orders From Repzo to SAP",
|
|
304
|
+
_id: "639ebeacdbba64d7af94520e",
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
action: "create_payment",
|
|
308
|
+
name: "Sync Paymants",
|
|
309
|
+
description: "Sync Paymants From Repzo to SAP",
|
|
310
|
+
_id: "639ebeacdbba64d7af94520f",
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
action: "create_transfer",
|
|
314
|
+
name: "Sync Approved Transfers",
|
|
315
|
+
description: "Sync Approved Transfers From Repzo to SAP",
|
|
316
|
+
_id: "639ebeacdbba64d7af945210",
|
|
317
|
+
},
|
|
70
318
|
],
|
|
71
|
-
actions: [],
|
|
72
319
|
createdAt: "2022-12-08T08:38:00.915Z",
|
|
73
|
-
updatedAt: "2022-12-
|
|
320
|
+
updatedAt: "2022-12-20T11:09:00.384Z",
|
|
74
321
|
__v: 0,
|
|
75
322
|
},
|
|
76
|
-
company_namespace: ["
|
|
323
|
+
company_namespace: ["unipaljo"],
|
|
77
324
|
formData: {
|
|
78
|
-
repzoApiKey: "
|
|
325
|
+
repzoApiKey: "mUOvoIBiv9uIg4ur7-nVdVP4m21EXto4EnlgWgDqP2c",
|
|
79
326
|
sapHostUrl: "http://unipal.b1pro.com:8083/api",
|
|
80
|
-
errorEmail: "maram.alshen@repzoapp.com",
|
|
81
|
-
serviceApiKey: "awdas",
|
|
82
327
|
warehouseDefaultUpdateDate: "2015-01-01",
|
|
328
|
+
DepartmentCode: "D2",
|
|
329
|
+
return_reason:
|
|
330
|
+
'[{sap_id:1,sap_name:"BarcodeIssue",repzo_name:"Barcodeissue",repzo_id:"62b074972b332895edf114fc"},{sap_id:2,sap_name:"Damaged",repzo_name:"Damaged",repzo_id:"62b074ace96258fb745982e4"},{sap_id:3,sap_name:"Nearexpiry",repzo_name:"Nearexpiry",repzo_id:"62b074c0a066173bd1c1ea0d"},{sap_id:4,sap_name:"Wrongprinting",repzo_name:"Wrongprinting",repzo_id:"62b074d79e7f41f306a4cb42"},{sap_id:5,sap_name:"experied",repzo_name:"Experied",repzo_id:"62b074faa066173bd1c1eec0"}]',
|
|
331
|
+
SalPersCode: "111",
|
|
332
|
+
SalesPersonCode: "111",
|
|
83
333
|
},
|
|
84
334
|
options_formData: {},
|
|
85
|
-
createdAt: "2022-12-
|
|
86
|
-
updatedAt: "2022-12-
|
|
335
|
+
createdAt: "2022-12-18T12:47:49.096Z",
|
|
336
|
+
updatedAt: "2022-12-21T09:04:34.538Z",
|
|
87
337
|
__v: 0,
|
|
88
338
|
},
|
|
89
339
|
end_of_day: "04:00",
|
|
90
|
-
nameSpace: ["
|
|
340
|
+
nameSpace: ["unipaljo"],
|
|
91
341
|
timezone: "Asia/Amman",
|
|
92
342
|
meta: "",
|
|
93
343
|
env: "staging",
|
|
94
|
-
sync_id: "
|
|
344
|
+
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767",
|
|
95
345
|
command: "price_list",
|
|
96
346
|
};
|
|
97
347
|
Commands(commandEvent);
|
package/package.json
CHANGED
|
@@ -62,6 +62,23 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
62
62
|
} catch (e) {}
|
|
63
63
|
|
|
64
64
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
65
|
+
try {
|
|
66
|
+
if (body?._id) {
|
|
67
|
+
body.integration_meta = body?.integration_meta || {};
|
|
68
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
69
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
70
|
+
await repzo.invoice.update(body._id, {
|
|
71
|
+
integration_meta: body.integration_meta,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.error(e);
|
|
76
|
+
await actionLog
|
|
77
|
+
.addDetail(
|
|
78
|
+
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
79
|
+
)
|
|
80
|
+
.commit();
|
|
81
|
+
}
|
|
65
82
|
|
|
66
83
|
await actionLog
|
|
67
84
|
.addDetail(`Invoice - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -266,6 +283,23 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
266
283
|
|
|
267
284
|
// console.log(result);
|
|
268
285
|
|
|
286
|
+
try {
|
|
287
|
+
if (body?._id) {
|
|
288
|
+
body.integration_meta = body?.integration_meta || {};
|
|
289
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
290
|
+
await repzo.invoice.update(body._id, {
|
|
291
|
+
integration_meta: body.integration_meta,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
console.error(e);
|
|
296
|
+
await actionLog
|
|
297
|
+
.addDetail(
|
|
298
|
+
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
299
|
+
)
|
|
300
|
+
.commit();
|
|
301
|
+
}
|
|
302
|
+
|
|
269
303
|
await actionLog
|
|
270
304
|
.addDetail(`SAP Responded with `, result)
|
|
271
305
|
.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`)
|
|
@@ -37,6 +37,23 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
37
37
|
} catch (e) {}
|
|
38
38
|
|
|
39
39
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
40
|
+
try {
|
|
41
|
+
if (body?._id) {
|
|
42
|
+
body.integration_meta = body?.integration_meta || {};
|
|
43
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
44
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
45
|
+
await repzo.payment.update(body._id, {
|
|
46
|
+
integration_meta: body.integration_meta,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error(e);
|
|
51
|
+
await actionLog
|
|
52
|
+
.addDetail(
|
|
53
|
+
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
54
|
+
)
|
|
55
|
+
.commit();
|
|
56
|
+
}
|
|
40
57
|
|
|
41
58
|
await actionLog
|
|
42
59
|
.addDetail(`Payment - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -123,6 +140,23 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
123
140
|
|
|
124
141
|
// console.log(result);
|
|
125
142
|
|
|
143
|
+
try {
|
|
144
|
+
if (body?._id) {
|
|
145
|
+
body.integration_meta = body?.integration_meta || {};
|
|
146
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
147
|
+
await repzo.payment.update(body._id, {
|
|
148
|
+
integration_meta: body.integration_meta,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
} catch (e) {
|
|
152
|
+
console.error(e);
|
|
153
|
+
await actionLog
|
|
154
|
+
.addDetail(
|
|
155
|
+
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
156
|
+
)
|
|
157
|
+
.commit();
|
|
158
|
+
}
|
|
159
|
+
|
|
126
160
|
await actionLog
|
|
127
161
|
.addDetail(`SAP Responded with `, result)
|
|
128
162
|
.addDetail(`Repzo => SAP: Payment - ${repzo_serial_number}`)
|
|
@@ -44,6 +44,23 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
44
44
|
} catch (e) {}
|
|
45
45
|
|
|
46
46
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
47
|
+
try {
|
|
48
|
+
if (body?._id) {
|
|
49
|
+
body.integration_meta = body?.integration_meta || {};
|
|
50
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
51
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
52
|
+
await repzo.proforma.update(body._id, {
|
|
53
|
+
integration_meta: body.integration_meta,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
await actionLog
|
|
59
|
+
.addDetail(
|
|
60
|
+
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
61
|
+
)
|
|
62
|
+
.commit();
|
|
63
|
+
}
|
|
47
64
|
|
|
48
65
|
await actionLog
|
|
49
66
|
.addDetail(`SalesOrder - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -197,6 +214,23 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
197
214
|
|
|
198
215
|
// console.log(result);
|
|
199
216
|
|
|
217
|
+
try {
|
|
218
|
+
if (body?._id) {
|
|
219
|
+
body.integration_meta = body?.integration_meta || {};
|
|
220
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
221
|
+
await repzo.proforma.update(body._id, {
|
|
222
|
+
integration_meta: body.integration_meta,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
} catch (e) {
|
|
226
|
+
console.error(e);
|
|
227
|
+
await actionLog
|
|
228
|
+
.addDetail(
|
|
229
|
+
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
230
|
+
)
|
|
231
|
+
.commit();
|
|
232
|
+
}
|
|
233
|
+
|
|
200
234
|
await actionLog
|
|
201
235
|
.addDetail(`SAP Responded with `, result)
|
|
202
236
|
.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
|
|
@@ -52,6 +52,23 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
52
52
|
} catch (e) {}
|
|
53
53
|
|
|
54
54
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
55
|
+
try {
|
|
56
|
+
if (body?._id) {
|
|
57
|
+
body.integration_meta = body?.integration_meta || {};
|
|
58
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
59
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
60
|
+
await repzo.invoice.update(body._id, {
|
|
61
|
+
integration_meta: body.integration_meta,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error(e);
|
|
66
|
+
await actionLog
|
|
67
|
+
.addDetail(
|
|
68
|
+
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
69
|
+
)
|
|
70
|
+
.commit();
|
|
71
|
+
}
|
|
55
72
|
|
|
56
73
|
await actionLog
|
|
57
74
|
.addDetail(`Return Invoice - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -228,6 +245,23 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
228
245
|
|
|
229
246
|
// console.log(result);
|
|
230
247
|
|
|
248
|
+
try {
|
|
249
|
+
if (body?._id) {
|
|
250
|
+
body.integration_meta = body?.integration_meta || {};
|
|
251
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
252
|
+
await repzo.invoice.update(body._id, {
|
|
253
|
+
integration_meta: body.integration_meta,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
} catch (e) {
|
|
257
|
+
console.error(e);
|
|
258
|
+
await actionLog
|
|
259
|
+
.addDetail(
|
|
260
|
+
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
261
|
+
)
|
|
262
|
+
.commit();
|
|
263
|
+
}
|
|
264
|
+
|
|
231
265
|
await actionLog
|
|
232
266
|
.addDetail(`SAP Responded with `, result)
|
|
233
267
|
.addDetail(`Repzo => SAP: Return Invoice - ${repzo_serial_number}`)
|
|
@@ -41,6 +41,23 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
41
41
|
} catch (e) {}
|
|
42
42
|
|
|
43
43
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
44
|
+
try {
|
|
45
|
+
if (body?._id) {
|
|
46
|
+
body.integration_meta = body?.integration_meta || {};
|
|
47
|
+
body.integration_meta.sync_to_sap_started = true;
|
|
48
|
+
body.integration_meta.sync_to_sap_succeeded = false;
|
|
49
|
+
await repzo.transfer.update(body._id, {
|
|
50
|
+
integration_meta: body.integration_meta,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error(e);
|
|
55
|
+
await actionLog
|
|
56
|
+
.addDetail(
|
|
57
|
+
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
58
|
+
)
|
|
59
|
+
.commit();
|
|
60
|
+
}
|
|
44
61
|
|
|
45
62
|
await actionLog
|
|
46
63
|
.addDetail(`Transfer - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -157,6 +174,22 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
157
174
|
);
|
|
158
175
|
|
|
159
176
|
// console.log(result);
|
|
177
|
+
try {
|
|
178
|
+
if (body?._id) {
|
|
179
|
+
body.integration_meta = body?.integration_meta || {};
|
|
180
|
+
body.integration_meta.sync_to_sap_succeeded = true;
|
|
181
|
+
await repzo.transfer.update(body._id, {
|
|
182
|
+
integration_meta: body.integration_meta,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} catch (e) {
|
|
186
|
+
console.error(e);
|
|
187
|
+
await actionLog
|
|
188
|
+
.addDetail(
|
|
189
|
+
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
190
|
+
)
|
|
191
|
+
.commit();
|
|
192
|
+
}
|
|
160
193
|
|
|
161
194
|
await actionLog
|
|
162
195
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -123,6 +123,27 @@ export const sync_price_list = async (commandEvent: CommandEvent) => {
|
|
|
123
123
|
sap_unique_UoMs[key] = doc.ALTQTY;
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
// Get Repzo {Product_sku : product_default_measureunit_name}
|
|
127
|
+
const repzo_product_default_measureunit: {
|
|
128
|
+
[productSKU: string]: string | null;
|
|
129
|
+
} = {};
|
|
130
|
+
repzo_products.data.forEach((product) => {
|
|
131
|
+
if (!product.sku) return;
|
|
132
|
+
if (!product.sv_measureUnit) {
|
|
133
|
+
repzo_product_default_measureunit[product.sku] = null;
|
|
134
|
+
} else {
|
|
135
|
+
const default_measureunit = repzo_UoMs.data.find(
|
|
136
|
+
(m) => m._id == product.sv_measureUnit
|
|
137
|
+
);
|
|
138
|
+
if (default_measureunit) {
|
|
139
|
+
repzo_product_default_measureunit[product.sku] =
|
|
140
|
+
default_measureunit.name;
|
|
141
|
+
} else {
|
|
142
|
+
repzo_product_default_measureunit[product.sku] = null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
126
147
|
// sort the data
|
|
127
148
|
const priceLists_withItems: { [key: string]: SAPPriceListItem[] } = {};
|
|
128
149
|
sap_price_lists.forEach((doc) => {
|
|
@@ -249,8 +270,18 @@ export const sync_price_list = async (commandEvent: CommandEvent) => {
|
|
|
249
270
|
priceList_items[key] = doc;
|
|
250
271
|
} else {
|
|
251
272
|
const current_doc = priceList_items[key];
|
|
252
|
-
if (
|
|
253
|
-
|
|
273
|
+
if (
|
|
274
|
+
current_doc.PLITEMUNIT !=
|
|
275
|
+
repzo_product_default_measureunit[current_doc.PLITEMID]
|
|
276
|
+
) {
|
|
277
|
+
if (
|
|
278
|
+
doc.PLITEMUNIT ==
|
|
279
|
+
repzo_product_default_measureunit[current_doc.PLITEMID]
|
|
280
|
+
) {
|
|
281
|
+
priceList_items[key] = doc;
|
|
282
|
+
} else if (current_doc?.factor > doc?.factor) {
|
|
283
|
+
priceList_items[key] = doc;
|
|
284
|
+
}
|
|
254
285
|
}
|
|
255
286
|
}
|
|
256
287
|
});
|
|
@@ -287,9 +318,14 @@ export const sync_price_list = async (commandEvent: CommandEvent) => {
|
|
|
287
318
|
continue;
|
|
288
319
|
}
|
|
289
320
|
|
|
290
|
-
const
|
|
321
|
+
const repzo_product_uoms = repzo_UoMs?.data?.filter(
|
|
291
322
|
(uom) =>
|
|
292
|
-
uom?._id?.toString() == repzo_product?.sv_measureUnit?.toString()
|
|
323
|
+
uom?._id?.toString() == repzo_product?.sv_measureUnit?.toString() ||
|
|
324
|
+
repzo_product.measureunit_family?.includes(uom?._id?.toString())
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
const repzo_product_uom = repzo_product_uoms.find(
|
|
328
|
+
(uom) => uom.name == item.PLITEMUNIT
|
|
293
329
|
);
|
|
294
330
|
|
|
295
331
|
if (!repzo_product_uom) {
|
|
@@ -3,15 +3,16 @@ import { Commands } from "../../index.js";
|
|
|
3
3
|
|
|
4
4
|
let commandEvent: CommandEvent | any = {
|
|
5
5
|
app: {
|
|
6
|
-
_id: "
|
|
6
|
+
_id: "639f0bf52070c5be595e955c",
|
|
7
7
|
name: "SAP",
|
|
8
8
|
disabled: false,
|
|
9
9
|
available_app: {
|
|
10
10
|
_id: "6391a268db71ef64357195da",
|
|
11
11
|
name: "repzo-sap-absjo",
|
|
12
12
|
title: "SAP ABS JO",
|
|
13
|
-
logo: "https://
|
|
14
|
-
description:
|
|
13
|
+
logo: "https://prod-repzo-media-service.s3.us-east-1.amazonaws.com/repzo/image/2022/12/18/3f73de7d-1920-4786-90db-57c76d18acci-SAP_EBS_JO.png",
|
|
14
|
+
description:
|
|
15
|
+
"SAP Jordan. We provide real value to SMEs by understanding their business and driving their vision forward with SAP Business One",
|
|
15
16
|
disabled: false,
|
|
16
17
|
JSONSchema: {
|
|
17
18
|
title: "SAP Integration Settings",
|
|
@@ -31,11 +32,95 @@ let commandEvent: CommandEvent | any = {
|
|
|
31
32
|
format: "email",
|
|
32
33
|
title: "Email in case of error",
|
|
33
34
|
},
|
|
35
|
+
GroupCode: {
|
|
36
|
+
type: "string",
|
|
37
|
+
format: "string",
|
|
38
|
+
title: "Customers GroupCode",
|
|
39
|
+
},
|
|
34
40
|
warehouseDefaultUpdateDate: {
|
|
35
41
|
type: "string",
|
|
36
42
|
format: "date",
|
|
37
43
|
title: "Warehouse: Default Update Date",
|
|
38
44
|
},
|
|
45
|
+
DepartmentCode: {
|
|
46
|
+
type: "string",
|
|
47
|
+
format: "string",
|
|
48
|
+
title: "Invoice/Return Department Code",
|
|
49
|
+
},
|
|
50
|
+
return_reason: {
|
|
51
|
+
type: "string",
|
|
52
|
+
format: "string",
|
|
53
|
+
title: "Return Reason Array",
|
|
54
|
+
},
|
|
55
|
+
SalPersCode: {
|
|
56
|
+
type: "string",
|
|
57
|
+
format: "string",
|
|
58
|
+
title: "Default Sales Person Code For Sales Orders",
|
|
59
|
+
},
|
|
60
|
+
SalesPersonCode: {
|
|
61
|
+
type: "string",
|
|
62
|
+
format: "string",
|
|
63
|
+
title: "Default Sales Person Code For Transfer",
|
|
64
|
+
},
|
|
65
|
+
invoices: {
|
|
66
|
+
type: "object",
|
|
67
|
+
title: "Invoices",
|
|
68
|
+
required: ["createInvoiceHook", "createReturnInvoiceHook"],
|
|
69
|
+
properties: {
|
|
70
|
+
createInvoiceHook: {
|
|
71
|
+
type: "boolean",
|
|
72
|
+
title: "Live Sync Invoices from Repzo to SAP",
|
|
73
|
+
default: false,
|
|
74
|
+
},
|
|
75
|
+
createReturnInvoiceHook: {
|
|
76
|
+
type: "boolean",
|
|
77
|
+
title: "Live Sync Return Invoice from Repzo to SAP",
|
|
78
|
+
default: false,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
payments: {
|
|
83
|
+
type: "object",
|
|
84
|
+
title: "Payments",
|
|
85
|
+
required: ["createPaymentHook"],
|
|
86
|
+
properties: {
|
|
87
|
+
createPaymentHook: {
|
|
88
|
+
type: "boolean",
|
|
89
|
+
title: "Live Sync Payments from Repzo to SAP",
|
|
90
|
+
default: false,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
proformas: {
|
|
95
|
+
type: "object",
|
|
96
|
+
title: "Sales Orders",
|
|
97
|
+
required: ["createApprovedProformaHook"],
|
|
98
|
+
properties: {
|
|
99
|
+
createApprovedProformaHook: {
|
|
100
|
+
type: "boolean",
|
|
101
|
+
title: "Live Sync Approved Sales Orders from Repzo to SAP",
|
|
102
|
+
default: false,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
transfers: {
|
|
107
|
+
type: "object",
|
|
108
|
+
title: "Transfers",
|
|
109
|
+
required: ["createApprovedTransferHook"],
|
|
110
|
+
properties: {
|
|
111
|
+
createApprovedTransferHook: {
|
|
112
|
+
type: "boolean",
|
|
113
|
+
title: "Live Sync Approved Transfers from Repzo to SAP",
|
|
114
|
+
default: false,
|
|
115
|
+
},
|
|
116
|
+
adjustInventoryInFailedTransfer: {
|
|
117
|
+
type: "boolean",
|
|
118
|
+
title:
|
|
119
|
+
"Adjust Inventories in Repzo if creation Transfer Failed in SAP",
|
|
120
|
+
default: false,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
39
124
|
},
|
|
40
125
|
},
|
|
41
126
|
options_JSONSchema: {
|
|
@@ -48,6 +133,41 @@ let commandEvent: CommandEvent | any = {
|
|
|
48
133
|
type: "string",
|
|
49
134
|
format: "date",
|
|
50
135
|
},
|
|
136
|
+
bench_time_channel: {
|
|
137
|
+
title: "Bench Time: Channels",
|
|
138
|
+
type: "string",
|
|
139
|
+
format: "date-time",
|
|
140
|
+
},
|
|
141
|
+
bench_time_payment_term: {
|
|
142
|
+
title: "Bench Time: Payment Terms",
|
|
143
|
+
type: "string",
|
|
144
|
+
format: "date-time",
|
|
145
|
+
},
|
|
146
|
+
bench_time_product: {
|
|
147
|
+
title: "Bench Time: Products",
|
|
148
|
+
type: "string",
|
|
149
|
+
format: "date-time",
|
|
150
|
+
},
|
|
151
|
+
bench_time_product_disabled: {
|
|
152
|
+
title: "Bench Time: Inactive Products",
|
|
153
|
+
type: "string",
|
|
154
|
+
format: "date-time",
|
|
155
|
+
},
|
|
156
|
+
bench_time_price_list: {
|
|
157
|
+
title: "Bench Time: Price List",
|
|
158
|
+
type: "string",
|
|
159
|
+
format: "date-time",
|
|
160
|
+
},
|
|
161
|
+
bench_time_client: {
|
|
162
|
+
title: "Bench Time: Clients",
|
|
163
|
+
type: "string",
|
|
164
|
+
format: "date-time",
|
|
165
|
+
},
|
|
166
|
+
bench_time_disabled_client: {
|
|
167
|
+
title: "Bench Time: Inactive Clients",
|
|
168
|
+
type: "string",
|
|
169
|
+
format: "date-time",
|
|
170
|
+
},
|
|
51
171
|
},
|
|
52
172
|
},
|
|
53
173
|
app_settings: {
|
|
@@ -69,31 +189,161 @@ let commandEvent: CommandEvent | any = {
|
|
|
69
189
|
description: "",
|
|
70
190
|
_id: "6391a268db71ef64357195dd",
|
|
71
191
|
},
|
|
192
|
+
{
|
|
193
|
+
command: "warehouse",
|
|
194
|
+
name: "Sync Warehouse",
|
|
195
|
+
description: "Sync Warehouses From SAP to Repzo",
|
|
196
|
+
_id: "6391c42a1b0f4f7a30e40f40",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
command: "rep",
|
|
200
|
+
name: "Sync Representatives",
|
|
201
|
+
description: "Sync Representatives From SAP to Repzo",
|
|
202
|
+
_id: "639715c2bee5dd4b6b11e129",
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
command: "tax",
|
|
206
|
+
name: "Sync Taxes",
|
|
207
|
+
description: "Sync Taxes From SAP to Repzo",
|
|
208
|
+
_id: "639715c2bee5dd4b6b11e12a",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
command: "tag",
|
|
212
|
+
name: "Sync Area Tags",
|
|
213
|
+
description: "Sync Area Tags From SAP to Repzo",
|
|
214
|
+
_id: "639715c2bee5dd4b6b11e12b",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
command: "measureunit",
|
|
218
|
+
name: "Sync Measure Units",
|
|
219
|
+
description: "Sync Measure Units From SAP to Repzo",
|
|
220
|
+
_id: "639817eaedafde008af0ad0e",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
command: "measureunit_family",
|
|
224
|
+
name: "Sync Measure Units Family",
|
|
225
|
+
description: "Sync Measure Units Family From SAP to Repzo",
|
|
226
|
+
_id: "63982d09edafde008af0f698",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
command: "category",
|
|
230
|
+
name: "Sync Product Category",
|
|
231
|
+
description: "Sync Product Categories From SAP to Repzo",
|
|
232
|
+
_id: "63984085edafde008af2f689",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
command: "channel",
|
|
236
|
+
name: "Sync Client's Channels",
|
|
237
|
+
description: "Sync Client's Channels From SAP to Repzo",
|
|
238
|
+
_id: "63984085edafde008af2f689",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
command: "payment_term",
|
|
242
|
+
name: "Sync Payments Term",
|
|
243
|
+
description: "Sync Payments Term From SAP to Repzo",
|
|
244
|
+
_id: "63984085edafde008af2f68a",
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
command: "bank",
|
|
248
|
+
name: "Sync Banks",
|
|
249
|
+
description: "Sync Banks From SAP to Repzo",
|
|
250
|
+
_id: "63986018333b84929c538570",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
command: "product",
|
|
254
|
+
name: "Sync Products",
|
|
255
|
+
description: "Sync Active Products From SAP to Repzo",
|
|
256
|
+
_id: "63987139333b84929c53a293",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
command: "disabled_product",
|
|
260
|
+
name: "Sync Inactive Products",
|
|
261
|
+
description: "Sync Inactive Products From SAP to Repzo",
|
|
262
|
+
_id: "6399714d0242db686d496466",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
command: "price_list",
|
|
266
|
+
name: "Sync Price Lists",
|
|
267
|
+
description: "Sync Price Lists From SAP to Repzo",
|
|
268
|
+
_id: "639972d6e8a1cfdd26deaa7e",
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
command: "client",
|
|
272
|
+
name: "Sync Clients",
|
|
273
|
+
description: "Sync Clients From SAP to Repzo",
|
|
274
|
+
_id: "63997615e8a1cfdd26ded7d1",
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
command: "disabled_client",
|
|
278
|
+
name: "Sync Inactive Clients",
|
|
279
|
+
description: "Sync Inactive Clients From SAP to Repzo",
|
|
280
|
+
_id: "639ac554e157f1c63770c1bc",
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
command: "adjust_inventory",
|
|
284
|
+
name: "Adjust Inventories",
|
|
285
|
+
description: "Adjust Inventories From SAP to Repzo",
|
|
286
|
+
_id: "639ac56fe157f1c63770c2eb",
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
actions: [
|
|
290
|
+
{
|
|
291
|
+
action: "create_invoice",
|
|
292
|
+
name: "Sync Invoices",
|
|
293
|
+
description: "Sync Invoices From Repzo to SAP",
|
|
294
|
+
_id: "639ebeacdbba64d7af94520c",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
action: "create_return_invoice",
|
|
298
|
+
name: "Sync Return Invoices",
|
|
299
|
+
description: "Sync Return Invoices From Repzo to SAP",
|
|
300
|
+
_id: "639ebeacdbba64d7af94520d",
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
action: "create_proforma",
|
|
304
|
+
name: "Sync Approved Sales Orders",
|
|
305
|
+
description: "Sync Approved Sales Orders From Repzo to SAP",
|
|
306
|
+
_id: "639ebeacdbba64d7af94520e",
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
action: "create_payment",
|
|
310
|
+
name: "Sync Paymants",
|
|
311
|
+
description: "Sync Paymants From Repzo to SAP",
|
|
312
|
+
_id: "639ebeacdbba64d7af94520f",
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
action: "create_transfer",
|
|
316
|
+
name: "Sync Approved Transfers",
|
|
317
|
+
description: "Sync Approved Transfers From Repzo to SAP",
|
|
318
|
+
_id: "639ebeacdbba64d7af945210",
|
|
319
|
+
},
|
|
72
320
|
],
|
|
73
|
-
actions: [],
|
|
74
321
|
createdAt: "2022-12-08T08:38:00.915Z",
|
|
75
|
-
updatedAt: "2022-12-
|
|
322
|
+
updatedAt: "2022-12-20T11:09:00.384Z",
|
|
76
323
|
__v: 0,
|
|
77
324
|
},
|
|
78
|
-
company_namespace: ["
|
|
325
|
+
company_namespace: ["unipaljo"],
|
|
79
326
|
formData: {
|
|
80
|
-
repzoApiKey: "
|
|
327
|
+
repzoApiKey: "mUOvoIBiv9uIg4ur7-nVdVP4m21EXto4EnlgWgDqP2c",
|
|
81
328
|
sapHostUrl: "http://unipal.b1pro.com:8083/api",
|
|
82
|
-
errorEmail: "maram.alshen@repzoapp.com",
|
|
83
|
-
serviceApiKey: "awdas",
|
|
84
329
|
warehouseDefaultUpdateDate: "2015-01-01",
|
|
330
|
+
DepartmentCode: "D2",
|
|
331
|
+
return_reason:
|
|
332
|
+
'[{sap_id:1,sap_name:"BarcodeIssue",repzo_name:"Barcodeissue",repzo_id:"62b074972b332895edf114fc"},{sap_id:2,sap_name:"Damaged",repzo_name:"Damaged",repzo_id:"62b074ace96258fb745982e4"},{sap_id:3,sap_name:"Nearexpiry",repzo_name:"Nearexpiry",repzo_id:"62b074c0a066173bd1c1ea0d"},{sap_id:4,sap_name:"Wrongprinting",repzo_name:"Wrongprinting",repzo_id:"62b074d79e7f41f306a4cb42"},{sap_id:5,sap_name:"experied",repzo_name:"Experied",repzo_id:"62b074faa066173bd1c1eec0"}]',
|
|
333
|
+
SalPersCode: "111",
|
|
334
|
+
SalesPersonCode: "111",
|
|
85
335
|
},
|
|
86
336
|
options_formData: {},
|
|
87
|
-
createdAt: "2022-12-
|
|
88
|
-
updatedAt: "2022-12-
|
|
337
|
+
createdAt: "2022-12-18T12:47:49.096Z",
|
|
338
|
+
updatedAt: "2022-12-21T09:04:34.538Z",
|
|
89
339
|
__v: 0,
|
|
90
340
|
},
|
|
91
341
|
end_of_day: "04:00",
|
|
92
|
-
nameSpace: ["
|
|
342
|
+
nameSpace: ["unipaljo"],
|
|
93
343
|
timezone: "Asia/Amman",
|
|
94
344
|
meta: "",
|
|
95
345
|
env: "staging",
|
|
96
|
-
sync_id: "
|
|
346
|
+
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767", // should change
|
|
97
347
|
command: "price_list",
|
|
98
348
|
};
|
|
99
349
|
|