repzo-sap-absjo 1.0.39 → 1.0.40

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.
@@ -1,9 +1,29 @@
1
1
  import Repzo from "repzo";
2
- import { _create, getUniqueConcatenatedValues } from "../util.js";
2
+ import { _create, getUniqueConcatenatedValues, set_error } from "../util.js";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import moment from "moment-timezone";
5
5
  export const create_proforma = async (event, options) => {
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
6
+ var _a,
7
+ _b,
8
+ _c,
9
+ _d,
10
+ _e,
11
+ _f,
12
+ _g,
13
+ _h,
14
+ _j,
15
+ _k,
16
+ _l,
17
+ _m,
18
+ _o,
19
+ _p,
20
+ _q,
21
+ _r,
22
+ _s,
23
+ _t,
24
+ _u,
25
+ _v,
26
+ _w;
7
27
  const repzo = new Repzo(
8
28
  (_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
9
29
  { env: options.env }
@@ -318,7 +338,26 @@ export const create_proforma = async (event, options) => {
318
338
  `Repzo => SAP: SalesOrder - ${repzo_serial_number}`,
319
339
  sap_invoice
320
340
  ); // .commit();
321
- const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
341
+ let result;
342
+ try {
343
+ result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
344
+ } catch (e) {
345
+ if (
346
+ typeof ((_u = set_error(e)) === null || _u === void 0
347
+ ? void 0
348
+ : _u.message) === "string" &&
349
+ ((_w =
350
+ (_v = set_error(e)) === null || _v === void 0
351
+ ? void 0
352
+ : _v.message) === null || _w === void 0
353
+ ? void 0
354
+ : _w.includes("this Sales Order is allready existed"))
355
+ ) {
356
+ result = { success: true, message: "Sales Order already exists" };
357
+ } else {
358
+ throw e;
359
+ }
360
+ }
322
361
  // console.log(result);
323
362
  try {
324
363
  await repzo.updateIntegrationMeta.create(
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_channel = async (commandEvent) => {
9
- var _a, _b, _c, _d;
9
+ var _a, _b, _c, _d, _e, _f;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -40,7 +40,10 @@ export const sync_channel = async (commandEvent) => {
40
40
  const sap_clients = await get_sap_clients(
41
41
  commandEvent.app.formData.sapHostUrl,
42
42
  {
43
- updateAt: commandEvent.app.options_formData[bench_time_key],
43
+ updateAt:
44
+ (_b = commandEvent.app.options_formData) === null || _b === void 0
45
+ ? void 0
46
+ : _b[bench_time_key],
44
47
  GroupCode: commandEvent.app.formData.GroupCode,
45
48
  }
46
49
  );
@@ -59,27 +62,29 @@ export const sync_channel = async (commandEvent) => {
59
62
  await commandLog
60
63
  .addDetail(
61
64
  `${result.sap_total} Client Channels in SAP changed since ${
62
- commandEvent.app.options_formData[bench_time_key] || "ever"
65
+ ((_c = commandEvent.app.options_formData) === null || _c === void 0
66
+ ? void 0
67
+ : _c[bench_time_key]) || "ever"
63
68
  }`
64
69
  )
65
70
  .commit();
66
71
  const repzo_channels = await repzo.channel.find({ per_page: 50000 });
67
72
  result.repzo_total =
68
- (_b =
73
+ (_d =
69
74
  repzo_channels === null || repzo_channels === void 0
70
75
  ? void 0
71
- : repzo_channels.data) === null || _b === void 0
76
+ : repzo_channels.data) === null || _d === void 0
72
77
  ? void 0
73
- : _b.length;
78
+ : _d.length;
74
79
  await commandLog
75
80
  .addDetail(
76
81
  `${
77
- (_c =
82
+ (_e =
78
83
  repzo_channels === null || repzo_channels === void 0
79
84
  ? void 0
80
- : repzo_channels.data) === null || _c === void 0
85
+ : repzo_channels.data) === null || _e === void 0
81
86
  ? void 0
82
- : _c.length
87
+ : _e.length
83
88
  } Client Channels in Repzo`
84
89
  )
85
90
  .commit();
@@ -178,10 +183,10 @@ export const sync_channel = async (commandEvent) => {
178
183
  } catch (e) {
179
184
  //@ts-ignore
180
185
  console.error(
181
- ((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
182
- _d === void 0
186
+ ((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
187
+ _f === void 0
183
188
  ? void 0
184
- : _d.data) || e
189
+ : _f.data) || e
185
190
  );
186
191
  await commandLog.setStatus("fail", e).commit();
187
192
  throw e;
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_client = async (commandEvent) => {
9
- var _a, _b, _c, _d, _e, _f, _g, _h;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -39,7 +39,10 @@ export const sync_client = async (commandEvent) => {
39
39
  const sap_clients = await get_sap_clients(
40
40
  commandEvent.app.formData.sapHostUrl,
41
41
  {
42
- updateAt: commandEvent.app.options_formData[bench_time_key],
42
+ updateAt:
43
+ (_b = commandEvent.app.options_formData) === null || _b === void 0
44
+ ? void 0
45
+ : _b[bench_time_key],
43
46
  GroupCode: commandEvent.app.formData.GroupCode,
44
47
  }
45
48
  );
@@ -50,7 +53,9 @@ export const sync_client = async (commandEvent) => {
50
53
  await commandLog
51
54
  .addDetail(
52
55
  `${result.sap_total} Customers in SAP changed since ${
53
- commandEvent.app.options_formData[bench_time_key] || "ever"
56
+ ((_c = commandEvent.app.options_formData) === null || _c === void 0
57
+ ? void 0
58
+ : _c[bench_time_key]) || "ever"
54
59
  }`
55
60
  )
56
61
  .commit();
@@ -89,21 +94,21 @@ export const sync_client = async (commandEvent) => {
89
94
  project: ["_id", "integration_meta"],
90
95
  });
91
96
  result.repzo_total =
92
- (_b =
97
+ (_d =
93
98
  repzo_clients === null || repzo_clients === void 0
94
99
  ? void 0
95
- : repzo_clients.data) === null || _b === void 0
100
+ : repzo_clients.data) === null || _d === void 0
96
101
  ? void 0
97
- : _b.length;
102
+ : _d.length;
98
103
  await commandLog
99
104
  .addDetail(
100
105
  `${
101
- (_c =
106
+ (_e =
102
107
  repzo_clients === null || repzo_clients === void 0
103
108
  ? void 0
104
- : repzo_clients.data) === null || _c === void 0
109
+ : repzo_clients.data) === null || _e === void 0
105
110
  ? void 0
106
- : _c.length
111
+ : _e.length
107
112
  } Clients in Repzo`
108
113
  )
109
114
  .commit();
@@ -125,12 +130,12 @@ export const sync_client = async (commandEvent) => {
125
130
  );
126
131
  });
127
132
  const tag =
128
- (_d =
133
+ (_f =
129
134
  repzo_tags === null || repzo_tags === void 0
130
135
  ? void 0
131
- : repzo_tags.data) === null || _d === void 0
136
+ : repzo_tags.data) === null || _f === void 0
132
137
  ? void 0
133
- : _d.find((tag) => {
138
+ : _f.find((tag) => {
134
139
  var _a;
135
140
  return (
136
141
  ((_a = tag.integration_meta) === null || _a === void 0
@@ -139,12 +144,12 @@ export const sync_client = async (commandEvent) => {
139
144
  );
140
145
  });
141
146
  const channel =
142
- (_e =
147
+ (_g =
143
148
  repzo_channels === null || repzo_channels === void 0
144
149
  ? void 0
145
- : repzo_channels.data) === null || _e === void 0
150
+ : repzo_channels.data) === null || _g === void 0
146
151
  ? void 0
147
- : _e.find((channel) => {
152
+ : _g.find((channel) => {
148
153
  var _a;
149
154
  return (
150
155
  ((_a = channel.integration_meta) === null || _a === void 0
@@ -153,12 +158,12 @@ export const sync_client = async (commandEvent) => {
153
158
  );
154
159
  });
155
160
  const paymentTerm =
156
- (_f =
161
+ (_h =
157
162
  repzo_payment_terms === null || repzo_payment_terms === void 0
158
163
  ? void 0
159
- : repzo_payment_terms.data) === null || _f === void 0
164
+ : repzo_payment_terms.data) === null || _h === void 0
160
165
  ? void 0
161
- : _f.find((paymentTerm) => {
166
+ : _h.find((paymentTerm) => {
162
167
  var _a;
163
168
  return (
164
169
  ((_a = paymentTerm.integration_meta) === null || _a === void 0
@@ -167,12 +172,12 @@ export const sync_client = async (commandEvent) => {
167
172
  );
168
173
  });
169
174
  const priceList =
170
- (_g =
175
+ (_j =
171
176
  repzo_price_lists === null || repzo_price_lists === void 0
172
177
  ? void 0
173
- : repzo_price_lists.data) === null || _g === void 0
178
+ : repzo_price_lists.data) === null || _j === void 0
174
179
  ? void 0
175
- : _g.find((pricelist) => {
180
+ : _j.find((pricelist) => {
176
181
  var _a;
177
182
  return (
178
183
  ((_a = pricelist.integration_meta) === null || _a === void 0
@@ -313,10 +318,10 @@ export const sync_client = async (commandEvent) => {
313
318
  } catch (e) {
314
319
  //@ts-ignore
315
320
  console.error(
316
- ((_h = e === null || e === void 0 ? void 0 : e.response) === null ||
317
- _h === void 0
321
+ ((_k = e === null || e === void 0 ? void 0 : e.response) === null ||
322
+ _k === void 0
318
323
  ? void 0
319
- : _h.data) || e
324
+ : _k.data) || e
320
325
  );
321
326
  await commandLog.setStatus("fail", e).commit();
322
327
  throw e;
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_disabled_client = async (commandEvent) => {
9
- var _a, _b, _c, _d;
9
+ var _a, _b, _c, _d, _e, _f;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -40,7 +40,10 @@ export const sync_disabled_client = async (commandEvent) => {
40
40
  const sap_disabled_clients = await get_sap_clients(
41
41
  commandEvent.app.formData.sapHostUrl,
42
42
  {
43
- updateAt: commandEvent.app.options_formData[bench_time_key],
43
+ updateAt:
44
+ (_b = commandEvent.app.options_formData) === null || _b === void 0
45
+ ? void 0
46
+ : _b[bench_time_key],
44
47
  GroupCode: commandEvent.app.formData.GroupCode,
45
48
  }
46
49
  );
@@ -51,7 +54,9 @@ export const sync_disabled_client = async (commandEvent) => {
51
54
  await commandLog
52
55
  .addDetail(
53
56
  `${result.sap_total} Disabled Clients in SAP changed since ${
54
- commandEvent.app.options_formData[bench_time_key] || "ever"
57
+ ((_c = commandEvent.app.options_formData) === null || _c === void 0
58
+ ? void 0
59
+ : _c[bench_time_key]) || "ever"
55
60
  }`
56
61
  )
57
62
  .commit();
@@ -76,9 +81,9 @@ export const sync_disabled_client = async (commandEvent) => {
76
81
  { per_page: 50000, project: ["_id", "integration_meta"] }
77
82
  );
78
83
  result.repzo_total =
79
- (_b = repzo_disabled_clients.data) === null || _b === void 0
84
+ (_d = repzo_disabled_clients.data) === null || _d === void 0
80
85
  ? void 0
81
- : _b.length;
86
+ : _d.length;
82
87
  await commandLog
83
88
  .addDetail(`${result.repzo_total} Matched Active Clients in Repzo`)
84
89
  .commit();
@@ -92,9 +97,9 @@ export const sync_disabled_client = async (commandEvent) => {
92
97
  ) {
93
98
  const sap_client = sap_disabled_clients[i];
94
99
  const repzo_client =
95
- (_c = repzo_disabled_clients.data) === null || _c === void 0
100
+ (_e = repzo_disabled_clients.data) === null || _e === void 0
96
101
  ? void 0
97
- : _c.find((r_client) => {
102
+ : _e.find((r_client) => {
98
103
  var _a;
99
104
  return (
100
105
  ((_a = r_client.integration_meta) === null || _a === void 0
@@ -142,10 +147,10 @@ export const sync_disabled_client = async (commandEvent) => {
142
147
  } catch (e) {
143
148
  //@ts-ignore
144
149
  console.error(
145
- ((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
146
- _d === void 0
150
+ ((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
151
+ _f === void 0
147
152
  ? void 0
148
- : _d.data) || e
153
+ : _f.data) || e
149
154
  );
150
155
  await commandLog.setStatus("fail", e).commit();
151
156
  throw e;
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_payment_term = async (commandEvent) => {
9
- var _a, _b, _c, _d;
9
+ var _a, _b, _c, _d, _e, _f;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -40,7 +40,10 @@ export const sync_payment_term = async (commandEvent) => {
40
40
  const sap_clients = await get_sap_clients(
41
41
  commandEvent.app.formData.sapHostUrl,
42
42
  {
43
- updateAt: commandEvent.app.options_formData[bench_time_key],
43
+ updateAt:
44
+ (_b = commandEvent.app.options_formData) === null || _b === void 0
45
+ ? void 0
46
+ : _b[bench_time_key],
44
47
  GroupCode: commandEvent.app.formData.GroupCode,
45
48
  }
46
49
  );
@@ -59,7 +62,9 @@ export const sync_payment_term = async (commandEvent) => {
59
62
  await commandLog
60
63
  .addDetail(
61
64
  `${result.sap_total} Payments Term in SAP changed since ${
62
- commandEvent.app.options_formData[bench_time_key] || "ever"
65
+ ((_c = commandEvent.app.options_formData) === null || _c === void 0
66
+ ? void 0
67
+ : _c[bench_time_key]) || "ever"
63
68
  }`
64
69
  )
65
70
  .commit();
@@ -67,21 +72,21 @@ export const sync_payment_term = async (commandEvent) => {
67
72
  per_page: 50000,
68
73
  });
69
74
  result.repzo_total =
70
- (_b =
75
+ (_d =
71
76
  repzo_payment_terms === null || repzo_payment_terms === void 0
72
77
  ? void 0
73
- : repzo_payment_terms.data) === null || _b === void 0
78
+ : repzo_payment_terms.data) === null || _d === void 0
74
79
  ? void 0
75
- : _b.length;
80
+ : _d.length;
76
81
  await commandLog
77
82
  .addDetail(
78
83
  `${
79
- (_c =
84
+ (_e =
80
85
  repzo_payment_terms === null || repzo_payment_terms === void 0
81
86
  ? void 0
82
- : repzo_payment_terms.data) === null || _c === void 0
87
+ : repzo_payment_terms.data) === null || _e === void 0
83
88
  ? void 0
84
- : _c.length
89
+ : _e.length
85
90
  } Payments Term in Repzo`
86
91
  )
87
92
  .commit();
@@ -182,10 +187,10 @@ export const sync_payment_term = async (commandEvent) => {
182
187
  } catch (e) {
183
188
  //@ts-ignore
184
189
  console.error(
185
- ((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
186
- _d === void 0
190
+ ((_f = e === null || e === void 0 ? void 0 : e.response) === null ||
191
+ _f === void 0
187
192
  ? void 0
188
- : _d.data) || e
193
+ : _f.data) || e
189
194
  );
190
195
  await commandLog.setStatus("fail", e).commit();
191
196
  throw e;