repzo-sap-absjo 1.0.5 → 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 +5 -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/measureunit_family.js +1 -1
- 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/measureunit_family.ts +1 -1
- 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
|
|
@@ -11,6 +13,9 @@
|
|
|
11
13
|
|
|
12
14
|
### Fixed
|
|
13
15
|
|
|
16
|
+
- [command/measureunit-family] use _.xor instead or _.difference @maramalshen
|
|
17
|
+
- [command/price_list] fix bug in priceList-item @maramalshen
|
|
18
|
+
|
|
14
19
|
### Removed
|
|
15
20
|
|
|
16
21
|
## [v1.0.0 (2022-04-18)](https://github.com/Repzo/repzo-sap-absjo.git)
|
|
@@ -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",
|