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
|
@@ -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)
|
|
@@ -152,7 +152,7 @@ export const sync_measureunit_family = async (commandEvent: CommandEvent) => {
|
|
|
152
152
|
} else {
|
|
153
153
|
if (
|
|
154
154
|
repzo_family.name == body.name &&
|
|
155
|
-
!_.
|
|
155
|
+
!_.xor(
|
|
156
156
|
repzo_family?.measureunits?.map((m) => m?.toString()) || [],
|
|
157
157
|
body?.measureunits || []
|
|
158
158
|
)?.length
|
|
@@ -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) {
|