repzo-sap-absjo 1.0.11 → 1.0.13
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.js +11 -20
- package/lib/actions/create_payment.js +15 -20
- package/lib/actions/create_proforma.js +19 -24
- package/lib/actions/create_return_invoice.js +11 -20
- package/lib/actions/create_transfer.js +15 -20
- package/lib/commands/product.js +1 -0
- package/package.json +2 -2
- package/src/actions/create_invoice.ts +11 -16
- package/src/actions/create_payment.ts +13 -16
- package/src/actions/create_proforma.ts +19 -24
- package/src/actions/create_return_invoice.ts +11 -16
- package/src/actions/create_transfer.ts +23 -28
- package/src/commands/product.ts +1 -0
package/changelog.md
CHANGED
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
- [actions/***] add 2 keys in integration_meta: sync_to_sap_started & sync_to_sap_succeeded @maramalshen
|
|
8
8
|
- [commands/product] assign Foreign Name (ITEMDESCF) in SAP to local_name in Repzo @maramalshen
|
|
9
|
+
- [actions/payment] add the field UserId where it equals USERID of the SAP API REP @maramalshen
|
|
9
10
|
|
|
10
11
|
### Changed
|
|
11
12
|
|
|
12
13
|
- [commands/rep] delete hard code of rep.warehouse for reps start with: [WS, RET, MT] @maramalshen
|
|
13
14
|
- [commands/client] decide if client is cash or credit depend on PAYMENTTERM instead of CLIENTGROUP @maramalshen
|
|
15
|
+
- [actions/**] update integration_meta using repzo.updateIntegrationMeta instead of using service.update method to avoid infinity looping @maramalshen
|
|
14
16
|
|
|
15
17
|
### Fixed
|
|
16
18
|
|
|
@@ -28,17 +28,13 @@ export const create_invoice = async (event, options) => {
|
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{}
|
|
35
|
-
|
|
36
|
-
body.
|
|
37
|
-
|
|
38
|
-
await repzo.invoice.update(body._id, {
|
|
39
|
-
integration_meta: body.integration_meta,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
31
|
+
await repzo.updateIntegrationMeta.create(
|
|
32
|
+
[
|
|
33
|
+
{ key: "sync_to_sap_started", value: true },
|
|
34
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
35
|
+
],
|
|
36
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
37
|
+
);
|
|
42
38
|
} catch (e) {
|
|
43
39
|
console.error(e);
|
|
44
40
|
}
|
|
@@ -336,15 +332,10 @@ export const create_invoice = async (event, options) => {
|
|
|
336
332
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
337
333
|
// console.log(result);
|
|
338
334
|
try {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
body.integration_meta.sync_to_sap_succeeded = true;
|
|
344
|
-
await repzo.invoice.update(body._id, {
|
|
345
|
-
integration_meta: body.integration_meta,
|
|
346
|
-
});
|
|
347
|
-
}
|
|
335
|
+
await repzo.updateIntegrationMeta.create(
|
|
336
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
337
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
338
|
+
);
|
|
348
339
|
} catch (e) {
|
|
349
340
|
console.error(e);
|
|
350
341
|
}
|
|
@@ -29,17 +29,13 @@ export const create_payment = async (event, options) => {
|
|
|
29
29
|
? void 0
|
|
30
30
|
: _c.formatted;
|
|
31
31
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{}
|
|
36
|
-
|
|
37
|
-
body.
|
|
38
|
-
|
|
39
|
-
await repzo.payment.update(body._id, {
|
|
40
|
-
integration_meta: body.integration_meta,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
32
|
+
await repzo.updateIntegrationMeta.create(
|
|
33
|
+
[
|
|
34
|
+
{ key: "sync_to_sap_started", value: true },
|
|
35
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
36
|
+
],
|
|
37
|
+
{ _id: body._id, type: "payments" }
|
|
38
|
+
);
|
|
43
39
|
} catch (e) {
|
|
44
40
|
console.error(e);
|
|
45
41
|
}
|
|
@@ -81,6 +77,10 @@ export const create_payment = async (event, options) => {
|
|
|
81
77
|
if (!repzo_client)
|
|
82
78
|
throw `Client with _id: ${repzo_payment.client_id} not found in Repzo`;
|
|
83
79
|
const sap_payment = {
|
|
80
|
+
UserId:
|
|
81
|
+
repzo_rep === null || repzo_rep === void 0
|
|
82
|
+
? void 0
|
|
83
|
+
: repzo_rep.integration_id,
|
|
84
84
|
PaymentID: repzo_serial_number,
|
|
85
85
|
ClientCode:
|
|
86
86
|
repzo_client === null || repzo_client === void 0
|
|
@@ -183,15 +183,10 @@ export const create_payment = async (event, options) => {
|
|
|
183
183
|
const result = await _create(SAP_HOST_URL, "/AddPayment", sap_payment);
|
|
184
184
|
// console.log(result);
|
|
185
185
|
try {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
body.integration_meta.sync_to_sap_succeeded = true;
|
|
191
|
-
await repzo.payment.update(body._id, {
|
|
192
|
-
integration_meta: body.integration_meta,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
186
|
+
await repzo.updateIntegrationMeta.create(
|
|
187
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
188
|
+
{ _id: body._id, type: "payments" }
|
|
189
|
+
);
|
|
195
190
|
} catch (e) {
|
|
196
191
|
console.error(e);
|
|
197
192
|
}
|
|
@@ -27,19 +27,17 @@ export const create_proforma = async (event, options) => {
|
|
|
27
27
|
null || _c === void 0
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// console.error(e);
|
|
42
|
-
// }
|
|
30
|
+
try {
|
|
31
|
+
await repzo.updateIntegrationMeta.create(
|
|
32
|
+
[
|
|
33
|
+
{ key: "sync_to_sap_started", value: true },
|
|
34
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
35
|
+
],
|
|
36
|
+
{ _id: body._id, type: "proformas" }
|
|
37
|
+
);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(e);
|
|
40
|
+
}
|
|
43
41
|
await actionLog
|
|
44
42
|
.addDetail(
|
|
45
43
|
`SalesOrder - ${repzo_serial_number} => ${
|
|
@@ -274,17 +272,14 @@ export const create_proforma = async (event, options) => {
|
|
|
274
272
|
); // .commit();
|
|
275
273
|
const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
276
274
|
// console.log(result);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// } catch (e) {
|
|
286
|
-
// console.error(e);
|
|
287
|
-
// }
|
|
275
|
+
try {
|
|
276
|
+
await repzo.updateIntegrationMeta.create(
|
|
277
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
278
|
+
{ _id: body._id, type: "proformas" }
|
|
279
|
+
);
|
|
280
|
+
} catch (e) {
|
|
281
|
+
console.error(e);
|
|
282
|
+
}
|
|
288
283
|
await actionLog
|
|
289
284
|
.addDetail(`SAP Responded with `, result)
|
|
290
285
|
.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
|
|
@@ -28,17 +28,13 @@ export const create_return_invoice = async (event, options) => {
|
|
|
28
28
|
? void 0
|
|
29
29
|
: _c.formatted;
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{}
|
|
35
|
-
|
|
36
|
-
body.
|
|
37
|
-
|
|
38
|
-
await repzo.invoice.update(body._id, {
|
|
39
|
-
integration_meta: body.integration_meta,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
31
|
+
await repzo.updateIntegrationMeta.create(
|
|
32
|
+
[
|
|
33
|
+
{ key: "sync_to_sap_started", value: true },
|
|
34
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
35
|
+
],
|
|
36
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
37
|
+
);
|
|
42
38
|
} catch (e) {
|
|
43
39
|
console.error(e);
|
|
44
40
|
}
|
|
@@ -304,15 +300,10 @@ export const create_return_invoice = async (event, options) => {
|
|
|
304
300
|
);
|
|
305
301
|
// console.log(result);
|
|
306
302
|
try {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
body.integration_meta.sync_to_sap_succeeded = true;
|
|
312
|
-
await repzo.invoice.update(body._id, {
|
|
313
|
-
integration_meta: body.integration_meta,
|
|
314
|
-
});
|
|
315
|
-
}
|
|
303
|
+
await repzo.updateIntegrationMeta.create(
|
|
304
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
305
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
306
|
+
);
|
|
316
307
|
} catch (e) {
|
|
317
308
|
console.error(e);
|
|
318
309
|
}
|
|
@@ -34,19 +34,17 @@ export const create_transfer = async (event, options) => {
|
|
|
34
34
|
null || _d === void 0
|
|
35
35
|
? void 0
|
|
36
36
|
: _d.formatted;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// console.error(e);
|
|
49
|
-
// }
|
|
37
|
+
try {
|
|
38
|
+
await repzo.updateIntegrationMeta.create(
|
|
39
|
+
[
|
|
40
|
+
{ key: "sync_to_sap_started", value: true },
|
|
41
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
42
|
+
],
|
|
43
|
+
{ _id: body._id, type: "transfers" }
|
|
44
|
+
);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(e);
|
|
47
|
+
}
|
|
50
48
|
await actionLog
|
|
51
49
|
.addDetail(
|
|
52
50
|
`Transfer - ${repzo_serial_number} => ${
|
|
@@ -190,13 +188,10 @@ export const create_transfer = async (event, options) => {
|
|
|
190
188
|
);
|
|
191
189
|
// console.log(result);
|
|
192
190
|
try {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// integration_meta: body.integration_meta,
|
|
198
|
-
// });
|
|
199
|
-
// }
|
|
191
|
+
await repzo.updateIntegrationMeta.create(
|
|
192
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
193
|
+
{ _id: body._id, type: "transfers" }
|
|
194
|
+
);
|
|
200
195
|
} catch (e) {
|
|
201
196
|
console.error(e);
|
|
202
197
|
}
|
package/lib/commands/product.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repzo-sap-absjo",
|
|
3
3
|
"description": "repzo SAP ABS jo integration",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"jsonwebtoken": "^8.5.1",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"moment-timezone": "^0.5.34",
|
|
48
|
-
"repzo": "^1.0.
|
|
48
|
+
"repzo": "^1.0.24",
|
|
49
49
|
"uuid": "^8.3.2"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -63,15 +63,13 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
63
63
|
|
|
64
64
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
}
|
|
66
|
+
await repzo.updateIntegrationMeta.create(
|
|
67
|
+
[
|
|
68
|
+
{ key: "sync_to_sap_started", value: true },
|
|
69
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
70
|
+
],
|
|
71
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
72
|
+
);
|
|
75
73
|
} catch (e) {
|
|
76
74
|
console.error(e);
|
|
77
75
|
}
|
|
@@ -281,13 +279,10 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
281
279
|
// console.log(result);
|
|
282
280
|
|
|
283
281
|
try {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
body.
|
|
287
|
-
|
|
288
|
-
integration_meta: body.integration_meta,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
282
|
+
await repzo.updateIntegrationMeta.create(
|
|
283
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
284
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
285
|
+
);
|
|
291
286
|
} catch (e) {
|
|
292
287
|
console.error(e);
|
|
293
288
|
}
|
|
@@ -20,6 +20,7 @@ interface SAPPayment {
|
|
|
20
20
|
ChequeNumber?: string | number;
|
|
21
21
|
BankCode?: string;
|
|
22
22
|
CountryCode?: string; // "JO";
|
|
23
|
+
UserId?: string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export const create_payment = async (event: EVENT, options: Config) => {
|
|
@@ -38,15 +39,13 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
38
39
|
|
|
39
40
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
40
41
|
try {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
}
|
|
42
|
+
await repzo.updateIntegrationMeta.create(
|
|
43
|
+
[
|
|
44
|
+
{ key: "sync_to_sap_started", value: true },
|
|
45
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
46
|
+
],
|
|
47
|
+
{ _id: body._id, type: "payments" }
|
|
48
|
+
);
|
|
50
49
|
} catch (e) {
|
|
51
50
|
console.error(e);
|
|
52
51
|
}
|
|
@@ -78,6 +77,7 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
78
77
|
throw `Client with _id: ${repzo_payment.client_id} not found in Repzo`;
|
|
79
78
|
|
|
80
79
|
const sap_payment: SAPPayment = {
|
|
80
|
+
UserId: repzo_rep?.integration_id,
|
|
81
81
|
PaymentID: repzo_serial_number,
|
|
82
82
|
ClientCode: repzo_client?.client_code,
|
|
83
83
|
PaymentDate: moment(repzo_payment.paytime, "YYYY-MM-DD").format(
|
|
@@ -138,13 +138,10 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
138
138
|
// console.log(result);
|
|
139
139
|
|
|
140
140
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
body.
|
|
144
|
-
|
|
145
|
-
integration_meta: body.integration_meta,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
141
|
+
await repzo.updateIntegrationMeta.create(
|
|
142
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
143
|
+
{ _id: body._id, type: "payments" }
|
|
144
|
+
);
|
|
148
145
|
} catch (e) {
|
|
149
146
|
console.error(e);
|
|
150
147
|
}
|
|
@@ -44,19 +44,17 @@ 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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// console.error(e);
|
|
59
|
-
// }
|
|
47
|
+
try {
|
|
48
|
+
await repzo.updateIntegrationMeta.create(
|
|
49
|
+
[
|
|
50
|
+
{ key: "sync_to_sap_started", value: true },
|
|
51
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
52
|
+
],
|
|
53
|
+
{ _id: body._id, type: "proformas" }
|
|
54
|
+
);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.error(e);
|
|
57
|
+
}
|
|
60
58
|
|
|
61
59
|
await actionLog
|
|
62
60
|
.addDetail(`SalesOrder - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -208,17 +206,14 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
208
206
|
|
|
209
207
|
// console.log(result);
|
|
210
208
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// } catch (e) {
|
|
220
|
-
// console.error(e);
|
|
221
|
-
// }
|
|
209
|
+
try {
|
|
210
|
+
await repzo.updateIntegrationMeta.create(
|
|
211
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
212
|
+
{ _id: body._id, type: "proformas" }
|
|
213
|
+
);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
console.error(e);
|
|
216
|
+
}
|
|
222
217
|
|
|
223
218
|
await actionLog
|
|
224
219
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -53,15 +53,13 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
53
53
|
|
|
54
54
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
}
|
|
56
|
+
await repzo.updateIntegrationMeta.create(
|
|
57
|
+
[
|
|
58
|
+
{ key: "sync_to_sap_started", value: true },
|
|
59
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
60
|
+
],
|
|
61
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
62
|
+
);
|
|
65
63
|
} catch (e) {
|
|
66
64
|
console.error(e);
|
|
67
65
|
}
|
|
@@ -240,13 +238,10 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
240
238
|
// console.log(result);
|
|
241
239
|
|
|
242
240
|
try {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
body.
|
|
246
|
-
|
|
247
|
-
integration_meta: body.integration_meta,
|
|
248
|
-
});
|
|
249
|
-
}
|
|
241
|
+
await repzo.updateIntegrationMeta.create(
|
|
242
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
243
|
+
{ _id: body._id, type: "fullinvoices" }
|
|
244
|
+
);
|
|
250
245
|
} catch (e) {
|
|
251
246
|
console.error(e);
|
|
252
247
|
}
|
|
@@ -41,24 +41,22 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
41
41
|
if (body?.integration_meta?.sync_to_sap_started) return;
|
|
42
42
|
await actionLog.load(action_sync_id);
|
|
43
43
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// console.error(e);
|
|
56
|
-
// }
|
|
44
|
+
try {
|
|
45
|
+
await repzo.updateIntegrationMeta.create(
|
|
46
|
+
[
|
|
47
|
+
{ key: "sync_to_sap_started", value: true },
|
|
48
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
49
|
+
],
|
|
50
|
+
{ _id: body._id, type: "transfers" },
|
|
51
|
+
);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error(e);
|
|
54
|
+
}
|
|
57
55
|
|
|
58
56
|
await actionLog
|
|
59
57
|
.addDetail(`Transfer - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
60
58
|
.addDetail(
|
|
61
|
-
`Repzo => SAP: Started Create Transfer - ${repzo_serial_number}
|
|
59
|
+
`Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`,
|
|
62
60
|
)
|
|
63
61
|
.commit();
|
|
64
62
|
|
|
@@ -84,7 +82,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
84
82
|
if (item?.product_id) {
|
|
85
83
|
repzo_product_ids[item.product_id.toString()] = true;
|
|
86
84
|
}
|
|
87
|
-
}
|
|
85
|
+
},
|
|
88
86
|
);
|
|
89
87
|
const repzo_products = await repzo.patchAction.create(
|
|
90
88
|
{
|
|
@@ -97,7 +95,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
97
95
|
},
|
|
98
96
|
],
|
|
99
97
|
},
|
|
100
|
-
{ per_page: 50000, populatedKeys: ["measureunit"] }
|
|
98
|
+
{ per_page: 50000, populatedKeys: ["measureunit"] },
|
|
101
99
|
);
|
|
102
100
|
|
|
103
101
|
// Prepare Transfer Items
|
|
@@ -108,14 +106,14 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
108
106
|
|
|
109
107
|
const repzo_product = repzo_products?.data?.find(
|
|
110
108
|
//@ts-ignore
|
|
111
|
-
(p) => p._id.toString() == repzo_transfer_item.product_id?.toString()
|
|
109
|
+
(p) => p._id.toString() == repzo_transfer_item.product_id?.toString(),
|
|
112
110
|
);
|
|
113
111
|
if (!repzo_product) {
|
|
114
112
|
// console.log(
|
|
115
113
|
// `Product with _id: ${repzo_transfer_item.product_id} was not found In Repzo`,
|
|
116
114
|
// );
|
|
117
115
|
throw new Error(
|
|
118
|
-
`Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo
|
|
116
|
+
`Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo`,
|
|
119
117
|
);
|
|
120
118
|
}
|
|
121
119
|
|
|
@@ -126,7 +124,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
126
124
|
// `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
|
|
127
125
|
// );
|
|
128
126
|
throw new Error(
|
|
129
|
-
`Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found
|
|
127
|
+
`Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
|
|
130
128
|
);
|
|
131
129
|
}
|
|
132
130
|
|
|
@@ -158,24 +156,21 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
158
156
|
|
|
159
157
|
actionLog.addDetail(
|
|
160
158
|
`Repzo => SAP: Transfer - ${repzo_serial_number}`,
|
|
161
|
-
sap_transfer
|
|
159
|
+
sap_transfer,
|
|
162
160
|
);
|
|
163
161
|
|
|
164
162
|
const result = await _create(
|
|
165
163
|
SAP_HOST_URL,
|
|
166
164
|
"/AddStockTransfer",
|
|
167
|
-
sap_transfer
|
|
165
|
+
sap_transfer,
|
|
168
166
|
);
|
|
169
167
|
|
|
170
168
|
// console.log(result);
|
|
171
169
|
try {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// integration_meta: body.integration_meta,
|
|
177
|
-
// });
|
|
178
|
-
// }
|
|
170
|
+
await repzo.updateIntegrationMeta.create(
|
|
171
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
172
|
+
{ _id: body._id, type: "transfers" },
|
|
173
|
+
);
|
|
179
174
|
} catch (e) {
|
|
180
175
|
console.error(e);
|
|
181
176
|
}
|