repzo-sap-absjo 1.0.51 → 1.0.53
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/lib/actions/create_client.d.ts +8 -0
- package/lib/actions/create_client.js +205 -0
- package/lib/actions/index.js +3 -0
- package/lib/commands/join.js +34 -4
- package/lib/commands/measureunit.js +2 -1
- package/lib/test/actions/create_client.d.ts +1 -0
- package/lib/test/actions/create_client.js +141 -0
- package/lib/test/commands/join.js +165 -84
- package/lib/types.d.ts +3 -0
- package/package.json +5 -3
- package/src/actions/create_client.ts +184 -0
- package/src/actions/index.ts +3 -0
- package/src/commands/join.ts +8 -0
- package/src/commands/measureunit.ts +2 -1
- package/src/test/actions/create_client.ts +141 -0
- package/src/test/commands/join.ts +165 -84
- package/src/types.ts +1 -0
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { Commands } from "../../index.js";
|
|
2
2
|
let commandEvent = {
|
|
3
3
|
app: {
|
|
4
|
-
_id: "
|
|
5
|
-
name: "SAP",
|
|
4
|
+
_id: "68d11f0322e5865ce90326fe",
|
|
5
|
+
name: "SAP Integration ",
|
|
6
6
|
disabled: false,
|
|
7
7
|
available_app: {
|
|
8
|
-
_id: "
|
|
8
|
+
_id: "639ee4cf462a9df7c25cef4c",
|
|
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",
|
|
16
17
|
type: "object",
|
|
17
18
|
required: ["repzoApiKey", "sapHostUrl"],
|
|
18
19
|
properties: {
|
|
19
|
-
repzoApiKey: {
|
|
20
|
-
|
|
21
|
-
title: "Repzo API KEY",
|
|
22
|
-
},
|
|
23
|
-
sapHostUrl: {
|
|
24
|
-
type: "string",
|
|
25
|
-
title: "SAP Host Url",
|
|
26
|
-
},
|
|
20
|
+
repzoApiKey: { type: "string", title: "Repzo API KEY" },
|
|
21
|
+
sapHostUrl: { type: "string", title: "SAP Host Url" },
|
|
27
22
|
errorEmail: {
|
|
28
23
|
type: "string",
|
|
29
24
|
format: "email",
|
|
@@ -44,11 +39,22 @@ let commandEvent = {
|
|
|
44
39
|
format: "string",
|
|
45
40
|
title: "Invoice/Return Department Code",
|
|
46
41
|
},
|
|
47
|
-
|
|
42
|
+
return_reasons: {
|
|
48
43
|
type: "string",
|
|
49
44
|
format: "string",
|
|
50
45
|
title: "Return Reason Array",
|
|
51
46
|
},
|
|
47
|
+
measureUnitInjections: {
|
|
48
|
+
type: "string",
|
|
49
|
+
format: "string",
|
|
50
|
+
title:
|
|
51
|
+
'Uom Injection Array, example: [{ "itemCode": "010-KEA-JU0003", "uom": "PC" }]',
|
|
52
|
+
},
|
|
53
|
+
defaultWarehouseForSalesOrder: {
|
|
54
|
+
type: "string",
|
|
55
|
+
format: "string",
|
|
56
|
+
title: "Default Warehouse Code For Sales Orders",
|
|
57
|
+
},
|
|
52
58
|
SalPersCode: {
|
|
53
59
|
type: "string",
|
|
54
60
|
format: "string",
|
|
@@ -110,6 +116,24 @@ let commandEvent = {
|
|
|
110
116
|
title: "Live Sync Approved Transfers from Repzo to SAP",
|
|
111
117
|
default: false,
|
|
112
118
|
},
|
|
119
|
+
adjustInventoryInFailedTransfer: {
|
|
120
|
+
type: "boolean",
|
|
121
|
+
title:
|
|
122
|
+
"Adjust Inventories in Repzo if creation Transfer Failed in SAP",
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
client: {
|
|
128
|
+
type: "object",
|
|
129
|
+
title: "Client",
|
|
130
|
+
required: ["createClientHook"],
|
|
131
|
+
properties: {
|
|
132
|
+
createClientHook: {
|
|
133
|
+
type: "boolean",
|
|
134
|
+
title: "Live Sync Clients from Repzo to SAP",
|
|
135
|
+
default: false,
|
|
136
|
+
},
|
|
113
137
|
},
|
|
114
138
|
},
|
|
115
139
|
},
|
|
@@ -124,122 +148,189 @@ let commandEvent = {
|
|
|
124
148
|
type: "string",
|
|
125
149
|
format: "date",
|
|
126
150
|
},
|
|
151
|
+
bench_time_channel: {
|
|
152
|
+
title: "Bench Time: Channels",
|
|
153
|
+
type: "string",
|
|
154
|
+
format: "date-time",
|
|
155
|
+
},
|
|
156
|
+
bench_time_payment_term: {
|
|
157
|
+
title: "Bench Time: Payment Terms",
|
|
158
|
+
type: "string",
|
|
159
|
+
format: "date-time",
|
|
160
|
+
},
|
|
161
|
+
bench_time_product: {
|
|
162
|
+
title: "Bench Time: Products",
|
|
163
|
+
type: "string",
|
|
164
|
+
format: "date-time",
|
|
165
|
+
},
|
|
166
|
+
bench_time_product_disabled: {
|
|
167
|
+
title: "Bench Time: Inactive Products",
|
|
168
|
+
type: "string",
|
|
169
|
+
format: "date-time",
|
|
170
|
+
},
|
|
171
|
+
bench_time_price_list: {
|
|
172
|
+
title: "Bench Time: Price List",
|
|
173
|
+
type: "string",
|
|
174
|
+
format: "date-time",
|
|
175
|
+
},
|
|
176
|
+
bench_time_client: {
|
|
177
|
+
title: "Bench Time: Clients",
|
|
178
|
+
type: "string",
|
|
179
|
+
format: "date-time",
|
|
180
|
+
},
|
|
181
|
+
bench_time_disabled_client: {
|
|
182
|
+
title: "Bench Time: Inactive Clients",
|
|
183
|
+
type: "string",
|
|
184
|
+
format: "date-time",
|
|
185
|
+
},
|
|
127
186
|
},
|
|
128
187
|
},
|
|
129
188
|
app_settings: {
|
|
130
189
|
repo: "",
|
|
131
190
|
serviceEndPoint: "",
|
|
132
|
-
_id: "
|
|
191
|
+
_id: "639ee4cf462a9df7c25cef4d",
|
|
133
192
|
},
|
|
134
|
-
app_category: "
|
|
193
|
+
app_category: "629c62fcff7a8a2dc7a21ba1",
|
|
135
194
|
commands: [
|
|
136
195
|
{
|
|
137
196
|
command: "basic",
|
|
138
197
|
name: "Full Sync",
|
|
139
|
-
description: "",
|
|
140
|
-
|
|
198
|
+
description: "Exclude Join & Adjust Inventories",
|
|
199
|
+
group_sync: false,
|
|
200
|
+
_id: "639ee4cf462a9df7c25cef4e",
|
|
141
201
|
},
|
|
142
202
|
{
|
|
143
203
|
command: "join",
|
|
144
204
|
name: "Join",
|
|
145
205
|
description: "",
|
|
146
|
-
|
|
206
|
+
group_sync: false,
|
|
207
|
+
_id: "639ee4cf462a9df7c25cef4f",
|
|
147
208
|
},
|
|
148
209
|
{
|
|
149
210
|
command: "warehouse",
|
|
150
211
|
name: "Sync Warehouse",
|
|
151
212
|
description: "Sync Warehouses From SAP to Repzo",
|
|
152
|
-
|
|
213
|
+
group_sync: false,
|
|
214
|
+
_id: "639ee4cf462a9df7c25cef50",
|
|
153
215
|
},
|
|
154
216
|
{
|
|
155
217
|
command: "rep",
|
|
156
218
|
name: "Sync Representatives",
|
|
157
219
|
description: "Sync Representatives From SAP to Repzo",
|
|
158
|
-
|
|
220
|
+
group_sync: false,
|
|
221
|
+
_id: "639ee4cf462a9df7c25cef51",
|
|
159
222
|
},
|
|
160
223
|
{
|
|
161
224
|
command: "tax",
|
|
162
225
|
name: "Sync Taxes",
|
|
163
226
|
description: "Sync Taxes From SAP to Repzo",
|
|
164
|
-
|
|
227
|
+
group_sync: false,
|
|
228
|
+
_id: "639ee4cf462a9df7c25cef52",
|
|
165
229
|
},
|
|
166
230
|
{
|
|
167
231
|
command: "tag",
|
|
168
232
|
name: "Sync Area Tags",
|
|
169
233
|
description: "Sync Area Tags From SAP to Repzo",
|
|
170
|
-
|
|
234
|
+
group_sync: false,
|
|
235
|
+
_id: "639ee4cf462a9df7c25cef53",
|
|
171
236
|
},
|
|
172
237
|
{
|
|
173
238
|
command: "measureunit",
|
|
174
239
|
name: "Sync Measure Units",
|
|
175
240
|
description: "Sync Measure Units From SAP to Repzo",
|
|
176
|
-
|
|
241
|
+
group_sync: false,
|
|
242
|
+
_id: "639ee4cf462a9df7c25cef54",
|
|
177
243
|
},
|
|
178
244
|
{
|
|
179
245
|
command: "measureunit_family",
|
|
180
246
|
name: "Sync Measure Units Family",
|
|
181
247
|
description: "Sync Measure Units Family From SAP to Repzo",
|
|
182
|
-
|
|
248
|
+
group_sync: false,
|
|
249
|
+
_id: "639ee4cf462a9df7c25cef55",
|
|
183
250
|
},
|
|
184
251
|
{
|
|
185
252
|
command: "category",
|
|
186
253
|
name: "Sync Product Category",
|
|
187
254
|
description: "Sync Product Categories From SAP to Repzo",
|
|
255
|
+
group_sync: false,
|
|
256
|
+
_id: "639ee4cf462a9df7c25cef56",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
command: "brand",
|
|
260
|
+
name: "Sync Product Brand",
|
|
261
|
+
description: "Sync Product Brands From SAP to Repzo",
|
|
262
|
+
group_sync: false,
|
|
188
263
|
_id: "63984085edafde008af2f689",
|
|
189
264
|
},
|
|
190
265
|
{
|
|
191
266
|
command: "channel",
|
|
192
267
|
name: "Sync Client's Channels",
|
|
193
268
|
description: "Sync Client's Channels From SAP to Repzo",
|
|
194
|
-
|
|
269
|
+
group_sync: false,
|
|
270
|
+
_id: "639ee4cf462a9df7c25cef57",
|
|
195
271
|
},
|
|
196
272
|
{
|
|
197
273
|
command: "payment_term",
|
|
198
274
|
name: "Sync Payments Term",
|
|
199
275
|
description: "Sync Payments Term From SAP to Repzo",
|
|
200
|
-
|
|
276
|
+
group_sync: false,
|
|
277
|
+
_id: "639ee4cf462a9df7c25cef58",
|
|
201
278
|
},
|
|
202
279
|
{
|
|
203
280
|
command: "bank",
|
|
204
281
|
name: "Sync Banks",
|
|
205
282
|
description: "Sync Banks From SAP to Repzo",
|
|
206
|
-
|
|
283
|
+
group_sync: false,
|
|
284
|
+
_id: "639ee4cf462a9df7c25cef59",
|
|
207
285
|
},
|
|
208
286
|
{
|
|
209
287
|
command: "product",
|
|
210
288
|
name: "Sync Products",
|
|
211
289
|
description: "Sync Active Products From SAP to Repzo",
|
|
212
|
-
|
|
290
|
+
group_sync: false,
|
|
291
|
+
_id: "639ee4cf462a9df7c25cef5a",
|
|
213
292
|
},
|
|
214
293
|
{
|
|
215
294
|
command: "disabled_product",
|
|
216
295
|
name: "Sync Inactive Products",
|
|
217
296
|
description: "Sync Inactive Products From SAP to Repzo",
|
|
218
|
-
|
|
297
|
+
group_sync: false,
|
|
298
|
+
_id: "639ee4cf462a9df7c25cef5b",
|
|
219
299
|
},
|
|
220
300
|
{
|
|
221
301
|
command: "price_list",
|
|
222
302
|
name: "Sync Price Lists",
|
|
223
303
|
description: "Sync Price Lists From SAP to Repzo",
|
|
224
|
-
|
|
304
|
+
group_sync: false,
|
|
305
|
+
_id: "639ee4cf462a9df7c25cef5c",
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
command: "price_list_disabled",
|
|
309
|
+
name: "Sync Disbaled Price List Items",
|
|
310
|
+
description: "Sync Disbaled Price List Items From SAP to Repzo",
|
|
311
|
+
group_sync: false,
|
|
312
|
+
_id: "656ed4098961a3f97182773f",
|
|
225
313
|
},
|
|
226
314
|
{
|
|
227
315
|
command: "client",
|
|
228
316
|
name: "Sync Clients",
|
|
229
317
|
description: "Sync Clients From SAP to Repzo",
|
|
230
|
-
|
|
318
|
+
group_sync: false,
|
|
319
|
+
_id: "639ee4cf462a9df7c25cef5d",
|
|
231
320
|
},
|
|
232
321
|
{
|
|
233
322
|
command: "disabled_client",
|
|
234
323
|
name: "Sync Inactive Clients",
|
|
235
324
|
description: "Sync Inactive Clients From SAP to Repzo",
|
|
236
|
-
|
|
325
|
+
group_sync: false,
|
|
326
|
+
_id: "639ee4cf462a9df7c25cef5e",
|
|
237
327
|
},
|
|
238
328
|
{
|
|
239
329
|
command: "adjust_inventory",
|
|
240
330
|
name: "Adjust Inventories",
|
|
241
331
|
description: "Adjust Inventories From SAP to Repzo",
|
|
242
|
-
|
|
332
|
+
group_sync: false,
|
|
333
|
+
_id: "639ee4cf462a9df7c25cef5f",
|
|
243
334
|
},
|
|
244
335
|
],
|
|
245
336
|
actions: [
|
|
@@ -247,93 +338,83 @@ let commandEvent = {
|
|
|
247
338
|
action: "create_invoice",
|
|
248
339
|
name: "Sync Invoices",
|
|
249
340
|
description: "Sync Invoices From Repzo to SAP",
|
|
250
|
-
_id: "
|
|
341
|
+
_id: "639ee4cf462a9df7c25cef60",
|
|
251
342
|
},
|
|
252
343
|
{
|
|
253
344
|
action: "create_return_invoice",
|
|
254
345
|
name: "Sync Return Invoices",
|
|
255
346
|
description: "Sync Return Invoices From Repzo to SAP",
|
|
256
|
-
_id: "
|
|
347
|
+
_id: "639ee4cf462a9df7c25cef61",
|
|
257
348
|
},
|
|
258
349
|
{
|
|
259
350
|
action: "create_proforma",
|
|
260
351
|
name: "Sync Approved Sales Orders",
|
|
261
352
|
description: "Sync Approved Sales Orders From Repzo to SAP",
|
|
262
|
-
_id: "
|
|
353
|
+
_id: "639ee4cf462a9df7c25cef62",
|
|
263
354
|
},
|
|
264
355
|
{
|
|
265
356
|
action: "create_payment",
|
|
266
357
|
name: "Sync Paymants",
|
|
267
358
|
description: "Sync Paymants From Repzo to SAP",
|
|
268
|
-
_id: "
|
|
359
|
+
_id: "639ee4cf462a9df7c25cef63",
|
|
269
360
|
},
|
|
270
361
|
{
|
|
271
362
|
action: "create_transfer",
|
|
272
363
|
name: "Sync Approved Transfers",
|
|
273
364
|
description: "Sync Approved Transfers From Repzo to SAP",
|
|
274
|
-
_id: "
|
|
365
|
+
_id: "639ee4cf462a9df7c25cef64",
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
action: "create_client",
|
|
369
|
+
name: "Sync Approved Clients",
|
|
370
|
+
description: "Sync Approved Clients From Repzo to SAP",
|
|
371
|
+
_id: "68edeaa0bfbb2c273b91736f",
|
|
275
372
|
},
|
|
276
373
|
],
|
|
277
|
-
createdAt: "2022-12-
|
|
278
|
-
updatedAt: "
|
|
374
|
+
createdAt: "2022-12-18T10:00:47.414Z",
|
|
375
|
+
updatedAt: "2025-10-14T06:16:00.977Z",
|
|
279
376
|
__v: 0,
|
|
377
|
+
subscription_billing_mode: "free",
|
|
280
378
|
},
|
|
281
|
-
company_namespace: ["
|
|
379
|
+
company_namespace: ["hassanein1"],
|
|
282
380
|
formData: {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
createPaymentHook: false,
|
|
289
|
-
},
|
|
290
|
-
proformas: {
|
|
291
|
-
createApprovedProformaHook: false,
|
|
292
|
-
},
|
|
381
|
+
repzoApiKey: "SZx76pM2TiuFt9kK7fsBCLkW7oY8qA8pIjUHdmgzdZg",
|
|
382
|
+
sapHostUrl: "https://abs-dmz.b1pro.com:9001/api",
|
|
383
|
+
invoices: { createInvoiceHook: true, createReturnInvoiceHook: true },
|
|
384
|
+
payments: { createPaymentHook: true },
|
|
385
|
+
proformas: { createApprovedProformaHook: true },
|
|
293
386
|
transfers: {
|
|
294
|
-
createApprovedTransferHook: false,
|
|
295
|
-
},
|
|
296
|
-
transfer: {
|
|
297
387
|
createApprovedTransferHook: true,
|
|
388
|
+
adjustInventoryInFailedTransfer: true,
|
|
298
389
|
},
|
|
299
|
-
|
|
300
|
-
sapHostUrl: "http://unipal.b1pro.com:8083/api",
|
|
301
|
-
errorEmail: "maram.alshen@repzoapp.com",
|
|
302
|
-
serviceApiKey: "awdas",
|
|
303
|
-
warehouseDefaultUpdateDate: "2015-01-01",
|
|
304
|
-
DepartmentCode: "D2",
|
|
305
|
-
return_reason:
|
|
306
|
-
'[{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"}]',
|
|
307
|
-
SalPersCode: "111",
|
|
308
|
-
SalesPersonCode: "111",
|
|
390
|
+
client: { createClientHook: true },
|
|
309
391
|
},
|
|
310
392
|
options_formData: {
|
|
311
|
-
bench_time_warehouse: "
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
bench_time_disabled_client: "2022-12-18T05:40:29.169Z",
|
|
393
|
+
bench_time_warehouse: "2025-01-01",
|
|
394
|
+
bench_time_channel: "2025-09-22T11:59:38.667Z",
|
|
395
|
+
bench_time_payment_term: "2025-09-24T09:04:47.049Z",
|
|
396
|
+
bench_time_product: "2025-10-06T10:10:13.619Z",
|
|
397
|
+
bench_time_price_list: "2025-10-14T11:00:40.686Z",
|
|
398
|
+
bench_time_client: "2025-10-14T11:20:40.049Z",
|
|
399
|
+
bench_time_rep: "2025-10-12T10:40:25.535Z",
|
|
400
|
+
bench_time_tax: "2025-09-22T12:05:46.901Z",
|
|
401
|
+
bench_time_tag: "2025-09-22T12:06:01.041Z",
|
|
402
|
+
bench_time_measureunit: "2025-10-06T10:16:06.878Z",
|
|
403
|
+
bench_time_measureunit_family: "2025-09-29T13:21:39.534Z",
|
|
404
|
+
bench_time_category: "2025-09-24T09:04:43.969Z",
|
|
405
|
+
bench_time_brand: "2025-09-22T11:59:36.800Z",
|
|
406
|
+
bench_time_price_list_disabled: "2025-09-22T12:23:39.010Z",
|
|
326
407
|
},
|
|
327
|
-
createdAt: "
|
|
328
|
-
updatedAt: "
|
|
408
|
+
createdAt: "2025-09-22T10:03:47.010Z",
|
|
409
|
+
updatedAt: "2025-10-14T11:20:48.859Z",
|
|
329
410
|
__v: 0,
|
|
330
411
|
},
|
|
331
412
|
end_of_day: "04:00",
|
|
332
|
-
nameSpace: ["
|
|
413
|
+
nameSpace: ["hassanein1"],
|
|
333
414
|
timezone: "Asia/Amman",
|
|
334
415
|
meta: "",
|
|
335
416
|
env: "staging",
|
|
336
|
-
sync_id: "
|
|
417
|
+
sync_id: "bacad499-81e4-4925-bba4-b1f0befb7b21",
|
|
337
418
|
command: "join",
|
|
338
419
|
};
|
|
339
420
|
Commands(commandEvent);
|
package/lib/types.d.ts
CHANGED
|
@@ -113,6 +113,9 @@ export interface FormData {
|
|
|
113
113
|
createApprovedTransferHook?: boolean;
|
|
114
114
|
adjustInventoryInFailedTransfer?: boolean;
|
|
115
115
|
};
|
|
116
|
+
client?: {
|
|
117
|
+
createClientHook?: boolean;
|
|
118
|
+
};
|
|
116
119
|
}
|
|
117
120
|
interface OptionsFormData {
|
|
118
121
|
bench_time_warehouse?: string;
|
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.53",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": {
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"lint": "npx --yes prettier --write .",
|
|
22
22
|
"build": "tsc && npm run lint",
|
|
23
23
|
"test": "mocha",
|
|
24
|
-
"mac": "npm run build && node ./lib/test/
|
|
24
|
+
"mac": "npm run build && node ./lib/test/actions/***.js",
|
|
25
|
+
"command": "npm run build && node ./lib/test/commands/***.js",
|
|
26
|
+
"action": "npm run build && node ./lib/test/actions/***.js",
|
|
25
27
|
"prepublishOnly": "npm run build"
|
|
26
28
|
},
|
|
27
29
|
"repository": {
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"jsonwebtoken": "^8.5.1",
|
|
46
48
|
"lodash": "^4.17.21",
|
|
47
49
|
"moment-timezone": "^0.5.34",
|
|
48
|
-
"repzo": "^1.0.
|
|
50
|
+
"repzo": "^1.0.209",
|
|
49
51
|
"uuid": "^8.3.2"
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import Repzo from "repzo";
|
|
2
|
+
import { EVENT, Config } from "../types";
|
|
3
|
+
import { _fetch, _create, _update, _delete } from "../util.js";
|
|
4
|
+
import { Service } from "repzo/src/types";
|
|
5
|
+
import { v4 as uuid } from "uuid";
|
|
6
|
+
|
|
7
|
+
interface SAPCustomer {
|
|
8
|
+
AdditionalID: string; // "68eb85af0a28bf5038627c91";
|
|
9
|
+
CardName?: string; // "ÄBD";
|
|
10
|
+
Phone1?: string; // "0788877776";
|
|
11
|
+
cellular?: string; // "234567";
|
|
12
|
+
CLIENTID?: string; // "CL01483";
|
|
13
|
+
CLIENTADDRESS?: string; // null;
|
|
14
|
+
CLIENTCITY?: string; // null;
|
|
15
|
+
CLIENTCOUNTRY?: string; // null;
|
|
16
|
+
CLIENTCOUNTY?: string; // null;
|
|
17
|
+
CLIENTGROUPCODE?: number; // 113;
|
|
18
|
+
CLIENTGROUP?: string; // "RETAIL - توزيع";
|
|
19
|
+
PAYMENTTERM?: number; // 0;
|
|
20
|
+
CLIENTCONTACTPERSON?: string; // "الدوره حي الشرطه قرب ماركت الريان";
|
|
21
|
+
CLIENTPHONE1?: string; // "07761490829";
|
|
22
|
+
CLIENTPHONE2?: string; // null;
|
|
23
|
+
CLIENTNOTE?: string; // null;
|
|
24
|
+
CLIENTSTATUS?: "Y" | "N"; // "N";
|
|
25
|
+
CLIENTCREDITCONSUMED?: number; // 0.0;
|
|
26
|
+
CLIENTMAXCHEQUEVALUE?: number; // 1500000.0;
|
|
27
|
+
CLIENTCREDITLIMIT?: number; // 1500000.0;
|
|
28
|
+
CLIENTPRICELISTID?: number; // 2;
|
|
29
|
+
CLIENTADDRESSID?: string; // null;
|
|
30
|
+
CLIENTDESCF?: string; // null;
|
|
31
|
+
SALESPERSONCODE?: number; // 8;
|
|
32
|
+
DISCOUNTPERCENT?: number; // 0.0;
|
|
33
|
+
TERRITORYID?: string; // null;
|
|
34
|
+
TERRITORYNAME?: string; // null;
|
|
35
|
+
PARENTCODE?: string; // null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const create_client = async (event: EVENT, options: Config) => {
|
|
39
|
+
const repzo = new Repzo(options.data?.repzoApiKey, { env: options.env });
|
|
40
|
+
const action_sync_id: string = event?.headers?.action_sync_id || uuid();
|
|
41
|
+
const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
|
|
42
|
+
let body: Service.Client.Data | any;
|
|
43
|
+
try {
|
|
44
|
+
// console.log("create_client");
|
|
45
|
+
await actionLog.load(action_sync_id);
|
|
46
|
+
|
|
47
|
+
body = event.body;
|
|
48
|
+
try {
|
|
49
|
+
if (body) body = JSON.parse(body);
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
await repzo.updateIntegrationMeta.create(
|
|
54
|
+
[
|
|
55
|
+
{ key: "sync_to_sap_started", value: true },
|
|
56
|
+
{ key: "sync_to_sap_succeeded", value: false },
|
|
57
|
+
],
|
|
58
|
+
{ _id: body._id, type: "clients" }
|
|
59
|
+
);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.error(e);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
await actionLog
|
|
65
|
+
.addDetail(`Client - ${body?.name} => ${body?.sync_id}`)
|
|
66
|
+
.addDetail(`Repzo => SAP: Started Create Client - ${body?.name}`)
|
|
67
|
+
.commit();
|
|
68
|
+
|
|
69
|
+
const SAP_HOST_URL = options.data?.sapHostUrl;
|
|
70
|
+
if (!SAP_HOST_URL)
|
|
71
|
+
throw `SAP Host Url is missing and Required: ${SAP_HOST_URL}`;
|
|
72
|
+
|
|
73
|
+
const repzo_client: Service.Client.Data = body;
|
|
74
|
+
|
|
75
|
+
const channel = repzo_client.channel
|
|
76
|
+
? await repzo.channel.get(repzo_client.channel)
|
|
77
|
+
: null;
|
|
78
|
+
const paymentTerm = repzo_client.paymentTerm
|
|
79
|
+
? await repzo.paymentTerm.get(repzo_client.paymentTerm)
|
|
80
|
+
: null;
|
|
81
|
+
const price_list = repzo_client.sv_priceList
|
|
82
|
+
? await repzo.priceList.get(repzo_client.sv_priceList)
|
|
83
|
+
: null;
|
|
84
|
+
const price_list_name = price_list?.integration_meta?.id
|
|
85
|
+
? Number(price_list.integration_meta.id.split("-")[1])
|
|
86
|
+
: undefined;
|
|
87
|
+
const rep = repzo_client.assigned_to?.length
|
|
88
|
+
? await repzo.rep.get(repzo_client.assigned_to[0])
|
|
89
|
+
: undefined;
|
|
90
|
+
const tags = repzo_client.tags?.length
|
|
91
|
+
? await repzo.tag.find({ _id: repzo_client.tags, type: "area" })
|
|
92
|
+
: null;
|
|
93
|
+
const area_tags = tags?.data?.filter(
|
|
94
|
+
(t) => t.type === "area" && !t.disabled && t.integration_meta?.TerritoryID
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const sap_customer: SAPCustomer = {
|
|
98
|
+
AdditionalID: repzo_client._id,
|
|
99
|
+
CLIENTID: repzo_client.client_code,
|
|
100
|
+
CLIENTDESCF: repzo_client.local_name,
|
|
101
|
+
CLIENTCITY: repzo_client.city,
|
|
102
|
+
CLIENTCOUNTY: repzo_client.state,
|
|
103
|
+
CLIENTCOUNTRY: repzo_client.country,
|
|
104
|
+
CLIENTCONTACTPERSON: repzo_client.contact_name,
|
|
105
|
+
CLIENTPHONE1: repzo_client.phone,
|
|
106
|
+
CLIENTPHONE2: repzo_client.cell_phone,
|
|
107
|
+
CLIENTNOTE: repzo_client.comment,
|
|
108
|
+
CLIENTADDRESSID: repzo_client.formatted_address,
|
|
109
|
+
CLIENTGROUP: channel?.name,
|
|
110
|
+
PAYMENTTERM: paymentTerm?.due_days,
|
|
111
|
+
CLIENTPRICELISTID: price_list_name,
|
|
112
|
+
SALESPERSONCODE: rep ? Number(rep?.integration_id) : undefined,
|
|
113
|
+
TERRITORYID: area_tags?.[0]?.integration_meta?.TerritoryID,
|
|
114
|
+
CLIENTCREDITCONSUMED: repzo_client.integrated_client_balance
|
|
115
|
+
? repzo_client.integrated_client_balance / 1000
|
|
116
|
+
: undefined,
|
|
117
|
+
// CLIENTMAXCHEQUEVALUE: 1500000.0,
|
|
118
|
+
CLIENTCREDITLIMIT: repzo_client.financials?.credit_limit
|
|
119
|
+
? repzo_client.financials?.credit_limit / 1000
|
|
120
|
+
: undefined,
|
|
121
|
+
// CardName: "ÄBD",
|
|
122
|
+
// Phone1: "0788877776",
|
|
123
|
+
// cellular: "234567",
|
|
124
|
+
// CLIENTADDRESS: null,
|
|
125
|
+
// CLIENTGROUPCODE: 113,
|
|
126
|
+
// CLIENTSTATUS: "N",
|
|
127
|
+
// DISCOUNTPERCENT: 0.0,
|
|
128
|
+
// TERRITORYNAME: null,
|
|
129
|
+
// PARENTCODE: null, // ????
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// console.dir(sap_customer, { depth: null });
|
|
133
|
+
|
|
134
|
+
actionLog.addDetail(`Repzo => SAP: Client - ${body?.name}`, sap_customer);
|
|
135
|
+
|
|
136
|
+
const result: {
|
|
137
|
+
result: "Success";
|
|
138
|
+
message: string | "The Customer already Exists in SAP";
|
|
139
|
+
} = await _create(SAP_HOST_URL, "/AddCustomer", sap_customer);
|
|
140
|
+
|
|
141
|
+
// console.log(result);
|
|
142
|
+
|
|
143
|
+
actionLog.addDetail(`SAP Responded with `, result);
|
|
144
|
+
|
|
145
|
+
if (
|
|
146
|
+
result.result == "Success" &&
|
|
147
|
+
result.message != "The Customer already Exists in SAP"
|
|
148
|
+
) {
|
|
149
|
+
const update_repzo_client_body: Service.Client.Update.Body = {
|
|
150
|
+
client_code: result.message,
|
|
151
|
+
"integration_meta.id": `${repzo_client.company_namespace[0]}_${result.message}`,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const updated_repzo_client = await repzo.client.update(
|
|
155
|
+
repzo_client._id,
|
|
156
|
+
update_repzo_client_body
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
actionLog.addDetail(`Update Client Code: ${body?.name} in Repzo`);
|
|
160
|
+
// console.log({ updated_repzo_client });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
await repzo.updateIntegrationMeta.create(
|
|
165
|
+
[{ key: "sync_to_sap_succeeded", value: true }],
|
|
166
|
+
{ _id: body._id, type: "clients" }
|
|
167
|
+
);
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error(e);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
await actionLog
|
|
173
|
+
.addDetail(`Repzo => SAP: Client - ${body?.name}`)
|
|
174
|
+
.setStatus("success")
|
|
175
|
+
.setBody(repzo_client)
|
|
176
|
+
.commit();
|
|
177
|
+
return result;
|
|
178
|
+
} catch (e: any) {
|
|
179
|
+
//@ts-ignore
|
|
180
|
+
console.error(e?.response || e);
|
|
181
|
+
await actionLog.setStatus("fail", e).setBody(body).commit();
|
|
182
|
+
throw e;
|
|
183
|
+
}
|
|
184
|
+
};
|
package/src/actions/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { create_return_invoice } from "./create_return_invoice.js";
|
|
|
6
6
|
import { create_proforma } from "./create_proforma.js";
|
|
7
7
|
import { create_payment } from "./create_payment.js";
|
|
8
8
|
import { create_transfer } from "./create_transfer.js";
|
|
9
|
+
import { create_client } from "./create_client.js";
|
|
9
10
|
|
|
10
11
|
export const actions = async (event: any, options: Config) => {
|
|
11
12
|
switch (event.queryStringParameters?.action) {
|
|
@@ -19,6 +20,8 @@ export const actions = async (event: any, options: Config) => {
|
|
|
19
20
|
return await create_payment(event, options);
|
|
20
21
|
case "create_transfer":
|
|
21
22
|
return await create_transfer(event, options);
|
|
23
|
+
case "create_client":
|
|
24
|
+
return await create_client(event, options);
|
|
22
25
|
default:
|
|
23
26
|
throw `Route: ${event.queryStringParameters?.action} not found`;
|
|
24
27
|
}
|