repzo-sap-absjo 1.0.6 → 1.0.8

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.
Files changed (80) hide show
  1. package/changelog.md +4 -0
  2. package/lib/actions/create_invoice.d.ts +13 -19
  3. package/lib/actions/create_invoice.js +216 -336
  4. package/lib/actions/create_payment.d.ts +1 -4
  5. package/lib/actions/create_payment.js +125 -171
  6. package/lib/actions/create_proforma.d.ts +1 -4
  7. package/lib/actions/create_proforma.js +165 -268
  8. package/lib/actions/create_return_invoice.d.ts +1 -4
  9. package/lib/actions/create_return_invoice.js +177 -295
  10. package/lib/actions/create_transfer.d.ts +1 -4
  11. package/lib/actions/create_transfer.js +143 -198
  12. package/lib/actions/index.js +15 -23
  13. package/lib/commands/adjust_inventory.d.ts +2 -4
  14. package/lib/commands/adjust_inventory.js +160 -290
  15. package/lib/commands/bank.d.ts +2 -4
  16. package/lib/commands/bank.js +157 -279
  17. package/lib/commands/basic.js +47 -66
  18. package/lib/commands/category.d.ts +1 -3
  19. package/lib/commands/category.js +104 -178
  20. package/lib/commands/channel.d.ts +1 -3
  21. package/lib/commands/channel.js +117 -198
  22. package/lib/commands/client.d.ts +32 -34
  23. package/lib/commands/client.js +244 -404
  24. package/lib/commands/client_disabled.d.ts +1 -3
  25. package/lib/commands/client_disabled.js +94 -163
  26. package/lib/commands/index.d.ts +11 -15
  27. package/lib/commands/index.js +60 -60
  28. package/lib/commands/join.js +66 -192
  29. package/lib/commands/measureunit.d.ts +14 -19
  30. package/lib/commands/measureunit.js +191 -289
  31. package/lib/commands/measureunit_family.d.ts +8 -10
  32. package/lib/commands/measureunit_family.js +138 -250
  33. package/lib/commands/payment_term.d.ts +1 -3
  34. package/lib/commands/payment_term.js +123 -202
  35. package/lib/commands/price_list.d.ts +15 -15
  36. package/lib/commands/price_list.js +327 -571
  37. package/lib/commands/product.d.ts +30 -32
  38. package/lib/commands/product.js +243 -425
  39. package/lib/commands/product_disabled.d.ts +1 -3
  40. package/lib/commands/product_disabled.js +94 -164
  41. package/lib/commands/rep.js +141 -221
  42. package/lib/commands/tag.js +109 -174
  43. package/lib/commands/tax.js +112 -177
  44. package/lib/commands/warehouse.d.ts +1 -3
  45. package/lib/commands/warehouse.js +119 -207
  46. package/lib/index.d.ts +12 -21
  47. package/lib/test/actions/create_invoice.js +188 -193
  48. package/lib/test/actions/create_payment.js +107 -112
  49. package/lib/test/actions/create_proforma.js +216 -220
  50. package/lib/test/actions/create_return_invoice.js +200 -205
  51. package/lib/test/actions/create_transfer.js +115 -120
  52. package/lib/test/commands/adjust_inventory.js +90 -90
  53. package/lib/test/commands/bank.js +90 -90
  54. package/lib/test/commands/basic.js +327 -328
  55. package/lib/test/commands/category.js +90 -90
  56. package/lib/test/commands/channel.js +90 -90
  57. package/lib/test/commands/client.js +353 -355
  58. package/lib/test/commands/client_disabled.js +90 -90
  59. package/lib/test/commands/join.js +327 -328
  60. package/lib/test/commands/measureunit.js +90 -90
  61. package/lib/test/commands/measureunit_family.js +90 -90
  62. package/lib/test/commands/payment_term.js +90 -90
  63. package/lib/test/commands/price_list.js +337 -90
  64. package/lib/test/commands/product.js +90 -90
  65. package/lib/test/commands/product_disabled.js +90 -90
  66. package/lib/test/commands/rep.js +344 -346
  67. package/lib/test/commands/tag.js +90 -90
  68. package/lib/test/commands/tax.js +90 -90
  69. package/lib/test/commands/warehouse.js +90 -90
  70. package/lib/types.d.ts +60 -83
  71. package/lib/util.d.ts +19 -70
  72. package/lib/util.js +144 -170
  73. package/package.json +1 -1
  74. package/src/actions/create_invoice.ts +35 -0
  75. package/src/actions/create_payment.ts +35 -0
  76. package/src/actions/create_proforma.ts +35 -0
  77. package/src/actions/create_return_invoice.ts +35 -0
  78. package/src/actions/create_transfer.ts +34 -0
  79. package/src/commands/price_list.ts +40 -4
  80. package/src/test/commands/price_list.ts +263 -13
@@ -1,419 +1,259 @@
1
1
  import Repzo from "repzo";
2
- import {
3
- _create,
4
- update_bench_time,
5
- date_formatting,
6
- set_error,
7
- } from "../util.js";
2
+ import { _create, update_bench_time, date_formatting, set_error, } from "../util.js";
8
3
  export const sync_client = async (commandEvent) => {
9
- var _a, _b, _c, _d, _e, _f, _g, _h;
10
- const repzo = new Repzo(
11
- (_a = commandEvent.app.formData) === null || _a === void 0
12
- ? void 0
13
- : _a.repzoApiKey,
14
- {
15
- env: commandEvent.env,
16
- }
17
- );
18
- const commandLog = new Repzo.CommandLog(
19
- repzo,
20
- commandEvent.app,
21
- commandEvent.command
22
- );
23
- try {
24
- // console.log("sync_client");
25
- const new_bench_time = new Date().toISOString();
26
- const bench_time_key = "bench_time_client";
27
- await commandLog.load(commandEvent.sync_id);
28
- await commandLog.addDetail("Repzo SAP: Started Syncing Clients").commit();
29
- const nameSpace = commandEvent.nameSpace.join("_");
30
- const result = {
31
- sap_total: 0,
32
- repzo_total: 0,
33
- created: 0,
34
- updated: 0,
35
- failed: 0,
36
- };
37
- const failed_docs_report = [];
38
- // Get SAP CLients to be created/updated
39
- const sap_clients = await get_sap_clients(
40
- commandEvent.app.formData.sapHostUrl,
41
- {
42
- updateAt: commandEvent.app.options_formData[bench_time_key],
43
- GroupCode: commandEvent.app.formData.GroupCode,
44
- }
45
- );
46
- result.sap_total =
47
- sap_clients === null || sap_clients === void 0
48
- ? void 0
49
- : sap_clients.length;
50
- await commandLog
51
- .addDetail(
52
- `${result.sap_total} Customers in SAP changed since ${
53
- commandEvent.app.options_formData[bench_time_key] || "ever"
54
- }`
55
- )
56
- .commit();
57
- // Get SAP CLients to be created/updated
58
- const sap_all_clients = await get_sap_clients(
59
- commandEvent.app.formData.sapHostUrl,
60
- {}
61
- );
62
- result.sap_total =
63
- sap_clients === null || sap_clients === void 0
64
- ? void 0
65
- : sap_clients.length;
66
- // Get Repzo Tags
67
- const repzo_tags = await repzo.tag.find({
68
- disabled: false,
69
- per_page: 50000,
70
- });
71
- // Get Repzo Channels
72
- const repzo_channels = await repzo.channel.find({
73
- disabled: false,
74
- per_page: 50000,
75
- });
76
- // Get Repzo PaymentTerms
77
- const repzo_payment_terms = await repzo.paymentTerm.find({
78
- disabled: false,
79
- per_page: 50000,
80
- });
81
- // Get Repzo PriceLists
82
- const repzo_price_lists = await repzo.priceList.find({
83
- disabled: false,
84
- per_page: 50000,
4
+ var _a, _b, _c, _d, _e, _f, _g, _h;
5
+ const repzo = new Repzo((_a = commandEvent.app.formData) === null || _a === void 0 ? void 0 : _a.repzoApiKey, {
6
+ env: commandEvent.env,
85
7
  });
86
- // Get Repzo Clients
87
- const repzo_clients = await repzo.client.find({
88
- per_page: 50000,
89
- project: ["_id", "integration_meta"],
90
- });
91
- result.repzo_total =
92
- (_b =
93
- repzo_clients === null || repzo_clients === void 0
94
- ? void 0
95
- : repzo_clients.data) === null || _b === void 0
96
- ? void 0
97
- : _b.length;
98
- await commandLog
99
- .addDetail(
100
- `${
101
- (_c =
102
- repzo_clients === null || repzo_clients === void 0
103
- ? void 0
104
- : repzo_clients.data) === null || _c === void 0
105
- ? void 0
106
- : _c.length
107
- } Clients in Repzo`
108
- )
109
- .commit();
110
- for (
111
- let i = 0;
112
- i <
113
- (sap_clients === null || sap_clients === void 0
114
- ? void 0
115
- : sap_clients.length);
116
- i++
117
- ) {
118
- const sap_client = sap_clients[i];
119
- const repzo_client = repzo_clients.data.find((r_client) => {
120
- var _a;
121
- return (
122
- ((_a = r_client.integration_meta) === null || _a === void 0
123
- ? void 0
124
- : _a.id) == `${nameSpace}_${sap_client.CLIENTID}`
125
- );
126
- });
127
- const tag =
128
- (_d =
129
- repzo_tags === null || repzo_tags === void 0
130
- ? void 0
131
- : repzo_tags.data) === null || _d === void 0
132
- ? void 0
133
- : _d.find((tag) => {
134
- var _a;
135
- return (
136
- ((_a = tag.integration_meta) === null || _a === void 0
137
- ? void 0
138
- : _a.id) == `${nameSpace}_${sap_client.TERRITORYID}`
139
- );
140
- });
141
- const channel =
142
- (_e =
143
- repzo_channels === null || repzo_channels === void 0
144
- ? void 0
145
- : repzo_channels.data) === null || _e === void 0
146
- ? void 0
147
- : _e.find((channel) => {
148
- var _a;
149
- return (
150
- ((_a = channel.integration_meta) === null || _a === void 0
151
- ? void 0
152
- : _a.id) == `${nameSpace}_${sap_client.CLIENTGROUP}`
153
- );
8
+ const commandLog = new Repzo.CommandLog(repzo, commandEvent.app, commandEvent.command);
9
+ try {
10
+ // console.log("sync_client");
11
+ const new_bench_time = new Date().toISOString();
12
+ const bench_time_key = "bench_time_client";
13
+ await commandLog.load(commandEvent.sync_id);
14
+ await commandLog.addDetail("Repzo SAP: Started Syncing Clients").commit();
15
+ const nameSpace = commandEvent.nameSpace.join("_");
16
+ const result = {
17
+ sap_total: 0,
18
+ repzo_total: 0,
19
+ created: 0,
20
+ updated: 0,
21
+ failed: 0,
22
+ };
23
+ const failed_docs_report = [];
24
+ // Get SAP CLients to be created/updated
25
+ const sap_clients = await get_sap_clients(commandEvent.app.formData.sapHostUrl, {
26
+ updateAt: commandEvent.app.options_formData[bench_time_key],
27
+ GroupCode: commandEvent.app.formData.GroupCode,
28
+ });
29
+ result.sap_total = sap_clients === null || sap_clients === void 0 ? void 0 : sap_clients.length;
30
+ await commandLog
31
+ .addDetail(`${result.sap_total} Customers in SAP changed since ${commandEvent.app.options_formData[bench_time_key] || "ever"}`)
32
+ .commit();
33
+ // Get SAP CLients to be created/updated
34
+ const sap_all_clients = await get_sap_clients(commandEvent.app.formData.sapHostUrl, {});
35
+ result.sap_total = sap_clients === null || sap_clients === void 0 ? void 0 : sap_clients.length;
36
+ // Get Repzo Tags
37
+ const repzo_tags = await repzo.tag.find({
38
+ disabled: false,
39
+ per_page: 50000,
40
+ });
41
+ // Get Repzo Channels
42
+ const repzo_channels = await repzo.channel.find({
43
+ disabled: false,
44
+ per_page: 50000,
45
+ });
46
+ // Get Repzo PaymentTerms
47
+ const repzo_payment_terms = await repzo.paymentTerm.find({
48
+ disabled: false,
49
+ per_page: 50000,
50
+ });
51
+ // Get Repzo PriceLists
52
+ const repzo_price_lists = await repzo.priceList.find({
53
+ disabled: false,
54
+ per_page: 50000,
55
+ });
56
+ // Get Repzo Clients
57
+ const repzo_clients = await repzo.client.find({
58
+ per_page: 50000,
59
+ project: ["_id", "integration_meta"],
60
+ });
61
+ result.repzo_total = (_b = repzo_clients === null || repzo_clients === void 0 ? void 0 : repzo_clients.data) === null || _b === void 0 ? void 0 : _b.length;
62
+ await commandLog
63
+ .addDetail(`${(_c = repzo_clients === null || repzo_clients === void 0 ? void 0 : repzo_clients.data) === null || _c === void 0 ? void 0 : _c.length} Clients in Repzo`)
64
+ .commit();
65
+ for (let i = 0; i < (sap_clients === null || sap_clients === void 0 ? void 0 : sap_clients.length); i++) {
66
+ const sap_client = sap_clients[i];
67
+ const repzo_client = repzo_clients.data.find((r_client) => { var _a; return ((_a = r_client.integration_meta) === null || _a === void 0 ? void 0 : _a.id) == `${nameSpace}_${sap_client.CLIENTID}`; });
68
+ const tag = (_d = repzo_tags === null || repzo_tags === void 0 ? void 0 : repzo_tags.data) === null || _d === void 0 ? void 0 : _d.find((tag) => { var _a; return ((_a = tag.integration_meta) === null || _a === void 0 ? void 0 : _a.id) == `${nameSpace}_${sap_client.TERRITORYID}`; });
69
+ const channel = (_e = repzo_channels === null || repzo_channels === void 0 ? void 0 : repzo_channels.data) === null || _e === void 0 ? void 0 : _e.find((channel) => {
70
+ var _a;
71
+ return ((_a = channel.integration_meta) === null || _a === void 0 ? void 0 : _a.id) ==
72
+ `${nameSpace}_${sap_client.CLIENTGROUP}`;
154
73
  });
155
- const paymentTerm =
156
- (_f =
157
- repzo_payment_terms === null || repzo_payment_terms === void 0
158
- ? void 0
159
- : repzo_payment_terms.data) === null || _f === void 0
160
- ? void 0
161
- : _f.find((paymentTerm) => {
162
- var _a;
163
- return (
164
- ((_a = paymentTerm.integration_meta) === null || _a === void 0
165
- ? void 0
166
- : _a.id) == `${nameSpace}_${sap_client.PAYMENTTERM}`
167
- );
74
+ const paymentTerm = (_f = repzo_payment_terms === null || repzo_payment_terms === void 0 ? void 0 : repzo_payment_terms.data) === null || _f === void 0 ? void 0 : _f.find((paymentTerm) => {
75
+ var _a;
76
+ return ((_a = paymentTerm.integration_meta) === null || _a === void 0 ? void 0 : _a.id) ==
77
+ `${nameSpace}_${sap_client.PAYMENTTERM}`;
168
78
  });
169
- const priceList =
170
- (_g =
171
- repzo_price_lists === null || repzo_price_lists === void 0
172
- ? void 0
173
- : repzo_price_lists.data) === null || _g === void 0
174
- ? void 0
175
- : _g.find((pricelist) => {
176
- var _a;
177
- return (
178
- ((_a = pricelist.integration_meta) === null || _a === void 0
179
- ? void 0
180
- : _a.id) == `${nameSpace}_${sap_client.CLIENTPRICELISTID}`
181
- );
79
+ const priceList = (_g = repzo_price_lists === null || repzo_price_lists === void 0 ? void 0 : repzo_price_lists.data) === null || _g === void 0 ? void 0 : _g.find((pricelist) => {
80
+ var _a;
81
+ return ((_a = pricelist.integration_meta) === null || _a === void 0 ? void 0 : _a.id) ==
82
+ `${nameSpace}_${sap_client.CLIENTPRICELISTID}`;
182
83
  });
183
- let parent;
184
- if (sap_client.PARENTCODE) {
185
- parent = sap_all_clients.find(
186
- (c) => c.CLIENTID == sap_client.PARENTCODE
187
- );
188
- }
189
- const credit_limit = parent
190
- ? parent.CLIENTCREDITLIMIT
191
- : sap_client.CLIENTCREDITLIMIT;
192
- const client_credit_consumed = parent
193
- ? parent.CLIENTCREDITCONSUMED
194
- : sap_client.CLIENTCREDITCONSUMED;
195
- const body = {
196
- integration_meta: {
197
- id: `${nameSpace}_${sap_client.CLIENTID}`,
198
- PAYMENTTERM: sap_client.PAYMENTTERM,
199
- CLIENTCREDITCONSUMED: parent
200
- ? parent.CLIENTCREDITCONSUMED
201
- : sap_client.CLIENTCREDITCONSUMED,
202
- CLIENTMAXCHEQUEVALUE: parent
203
- ? parent.CLIENTMAXCHEQUEVALUE
204
- : sap_client.CLIENTMAXCHEQUEVALUE,
205
- CLIENTCREDITLIMIT: parent
206
- ? parent.CLIENTCREDITLIMIT
207
- : sap_client.CLIENTCREDITLIMIT,
208
- CLIENTPRICELISTID: sap_client.CLIENTPRICELISTID,
209
- },
210
- client_code: sap_client.CLIENTID,
211
- name: sap_client.CLIENTDESC,
212
- local_name: sap_client.CLIENTDESCF ? sap_client.CLIENTDESCF : undefined,
213
- city: sap_client.CLIENTCITY,
214
- state: sap_client.CLIENTCOUNTY,
215
- country: sap_client.CLIENTCOUNTRY,
216
- contact_name: sap_client.CLIENTCONTACTPERSON,
217
- phone: sap_client.CLIENTPHONE1,
218
- cell_phone: sap_client.CLIENTPHONE2,
219
- comment: sap_client.CLIENTNOTE,
220
- formatted_address: sap_client.CLIENTADDRESSID,
221
- tags: tag ? [tag._id] : [],
222
- credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
223
- ? credit_limit && Math.round(credit_limit * 1000)
224
- : 1000000000,
225
- financials: {
226
- credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
227
- ? credit_limit && Math.round(credit_limit * 1000)
228
- : 1000000000,
229
- },
230
- channel: channel ? channel._id : undefined,
231
- paymentTerm: paymentTerm ? paymentTerm._id : undefined,
232
- sv_priceList: priceList ? priceList._id : undefined,
233
- disabled: sap_client.ACTIVE == "Y" ? false : true,
234
- payment_type: sap_client.PAYMENTTERM ? "credit" : "cash",
235
- integrated_client_balance:
236
- client_credit_consumed && Math.round(client_credit_consumed * 1000),
237
- };
238
- if (!repzo_client) {
239
- // Create
240
- try {
241
- const created_client = await repzo.client.create(body);
242
- result.created++;
243
- } catch (e) {
244
- // console.log("Create Client Failed >> ", e?.response, body);
245
- failed_docs_report.push({
246
- method: "create",
247
- doc: body,
248
- error_message: set_error(e),
249
- });
250
- result.failed++;
251
- }
252
- } else {
253
- const repzo_original_doc = await repzo.client.get(repzo_client._id);
254
- // console.log("match", is_matched(body, repzo_original_doc));
255
- if (is_matched(body, repzo_original_doc)) {
256
- continue;
257
- }
258
- // Update
259
- try {
260
- const updated_client = await repzo.client.update(
261
- repzo_client._id,
262
- body
263
- );
264
- result.updated++;
265
- } catch (e) {
266
- // console.log("Update Client Failed >> ", e?.response?.data, body);
267
- failed_docs_report.push({
268
- method: "update",
269
- doc_id:
270
- repzo_client === null || repzo_client === void 0
271
- ? void 0
272
- : repzo_client._id,
273
- doc: body,
274
- error_message: set_error(e),
275
- });
276
- result.failed++;
84
+ let parent;
85
+ if (sap_client.PARENTCODE) {
86
+ parent = sap_all_clients.find((c) => c.CLIENTID == sap_client.PARENTCODE);
87
+ }
88
+ const credit_limit = parent
89
+ ? parent.CLIENTCREDITLIMIT
90
+ : sap_client.CLIENTCREDITLIMIT;
91
+ const client_credit_consumed = parent
92
+ ? parent.CLIENTCREDITCONSUMED
93
+ : sap_client.CLIENTCREDITCONSUMED;
94
+ const body = {
95
+ integration_meta: {
96
+ id: `${nameSpace}_${sap_client.CLIENTID}`,
97
+ PAYMENTTERM: sap_client.PAYMENTTERM,
98
+ CLIENTCREDITCONSUMED: parent
99
+ ? parent.CLIENTCREDITCONSUMED
100
+ : sap_client.CLIENTCREDITCONSUMED,
101
+ CLIENTMAXCHEQUEVALUE: parent
102
+ ? parent.CLIENTMAXCHEQUEVALUE
103
+ : sap_client.CLIENTMAXCHEQUEVALUE,
104
+ CLIENTCREDITLIMIT: parent
105
+ ? parent.CLIENTCREDITLIMIT
106
+ : sap_client.CLIENTCREDITLIMIT,
107
+ CLIENTPRICELISTID: sap_client.CLIENTPRICELISTID,
108
+ },
109
+ client_code: sap_client.CLIENTID,
110
+ name: sap_client.CLIENTDESC,
111
+ local_name: sap_client.CLIENTDESCF ? sap_client.CLIENTDESCF : undefined,
112
+ city: sap_client.CLIENTCITY,
113
+ state: sap_client.CLIENTCOUNTY,
114
+ country: sap_client.CLIENTCOUNTRY,
115
+ contact_name: sap_client.CLIENTCONTACTPERSON,
116
+ phone: sap_client.CLIENTPHONE1,
117
+ cell_phone: sap_client.CLIENTPHONE2,
118
+ comment: sap_client.CLIENTNOTE,
119
+ formatted_address: sap_client.CLIENTADDRESSID,
120
+ tags: tag ? [tag._id] : [],
121
+ credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
122
+ ? credit_limit && Math.round(credit_limit * 1000)
123
+ : 1000000000,
124
+ financials: {
125
+ credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
126
+ ? credit_limit && Math.round(credit_limit * 1000)
127
+ : 1000000000,
128
+ },
129
+ channel: channel ? channel._id : undefined,
130
+ paymentTerm: paymentTerm ? paymentTerm._id : undefined,
131
+ sv_priceList: priceList ? priceList._id : undefined,
132
+ disabled: sap_client.ACTIVE == "Y" ? false : true,
133
+ payment_type: sap_client.PAYMENTTERM ? "credit" : "cash",
134
+ integrated_client_balance: client_credit_consumed && Math.round(client_credit_consumed * 1000),
135
+ };
136
+ if (!repzo_client) {
137
+ // Create
138
+ try {
139
+ const created_client = await repzo.client.create(body);
140
+ result.created++;
141
+ }
142
+ catch (e) {
143
+ // console.log("Create Client Failed >> ", e?.response, body);
144
+ failed_docs_report.push({
145
+ method: "create",
146
+ doc: body,
147
+ error_message: set_error(e),
148
+ });
149
+ result.failed++;
150
+ }
151
+ }
152
+ else {
153
+ const repzo_original_doc = await repzo.client.get(repzo_client._id);
154
+ // console.log("match", is_matched(body, repzo_original_doc));
155
+ if (is_matched(body, repzo_original_doc)) {
156
+ continue;
157
+ }
158
+ // Update
159
+ try {
160
+ const updated_client = await repzo.client.update(repzo_client._id, body);
161
+ result.updated++;
162
+ }
163
+ catch (e) {
164
+ // console.log("Update Client Failed >> ", e?.response?.data, body);
165
+ failed_docs_report.push({
166
+ method: "update",
167
+ doc_id: repzo_client === null || repzo_client === void 0 ? void 0 : repzo_client._id,
168
+ doc: body,
169
+ error_message: set_error(e),
170
+ });
171
+ result.failed++;
172
+ }
173
+ }
277
174
  }
278
- }
175
+ // console.log(result);
176
+ await update_bench_time(repzo, commandEvent.app._id, bench_time_key, new_bench_time);
177
+ await commandLog
178
+ .setStatus("success", failed_docs_report.length ? failed_docs_report : null)
179
+ .setBody(result)
180
+ .commit();
181
+ return result;
182
+ }
183
+ catch (e) {
184
+ //@ts-ignore
185
+ console.error(((_h = e === null || e === void 0 ? void 0 : e.response) === null || _h === void 0 ? void 0 : _h.data) || e);
186
+ await commandLog.setStatus("fail", e).commit();
187
+ throw e;
279
188
  }
280
- // console.log(result);
281
- await update_bench_time(
282
- repzo,
283
- commandEvent.app._id,
284
- bench_time_key,
285
- new_bench_time
286
- );
287
- await commandLog
288
- .setStatus(
289
- "success",
290
- failed_docs_report.length ? failed_docs_report : null
291
- )
292
- .setBody(result)
293
- .commit();
294
- return result;
295
- } catch (e) {
296
- //@ts-ignore
297
- console.error(
298
- ((_h = e === null || e === void 0 ? void 0 : e.response) === null ||
299
- _h === void 0
300
- ? void 0
301
- : _h.data) || e
302
- );
303
- await commandLog.setStatus("fail", e).commit();
304
- throw e;
305
- }
306
189
  };
307
190
  const get_sap_clients = async (serviceEndPoint, query) => {
308
- try {
309
- const sap_clients = await _create(serviceEndPoint, "/Customers", {
310
- Active: "Y",
311
- Frozen: "N",
312
- UpdateAt: date_formatting(
313
- query === null || query === void 0 ? void 0 : query.updateAt,
314
- "YYYYMMDD:HHmmss"
315
- ),
316
- GroupCode:
317
- (query === null || query === void 0 ? void 0 : query.GroupCode) || "",
318
- });
319
- return sap_clients.Customers;
320
- } catch (e) {
321
- throw e;
322
- }
191
+ try {
192
+ const sap_clients = await _create(serviceEndPoint, "/Customers", {
193
+ Active: "Y",
194
+ Frozen: "N",
195
+ UpdateAt: date_formatting(query === null || query === void 0 ? void 0 : query.updateAt, "YYYYMMDD:HHmmss"),
196
+ GroupCode: (query === null || query === void 0 ? void 0 : query.GroupCode) || "",
197
+ });
198
+ return sap_clients.Customers;
199
+ }
200
+ catch (e) {
201
+ throw e;
202
+ }
323
203
  };
324
204
  const is_matched = (body_1, body_2) => {
325
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
326
- try {
327
- const keys = [
328
- "client_code",
329
- "name",
330
- "local_name",
331
- "city",
332
- "state",
333
- "country",
334
- "contact_name",
335
- "phone",
336
- "cell_phone",
337
- "comment",
338
- "formatted_address",
339
- "tags",
340
- "credit_limit",
341
- // "financials",
342
- "channel",
343
- "paymentTerm",
344
- "sv_priceList",
345
- "disabled",
346
- "payment_type",
347
- "integrated_client_balance",
348
- ];
349
- const integration_meta_keys = [
350
- "id",
351
- "PAYMENTTERM",
352
- "CLIENTCREDITCONSUMED",
353
- "CLIENTMAXCHEQUEVALUE",
354
- "CLIENTCREDITLIMIT",
355
- "CLIENTPRICELISTID",
356
- ];
357
- for (let i = 0; i < keys.length; i++) {
358
- const key = keys[i];
359
- if (
360
- ((_a = body_1[key]) === null || _a === void 0
361
- ? void 0
362
- : _a.toString()) !==
363
- ((_b = body_2[key]) === null || _b === void 0 ? void 0 : _b.toString())
364
- ) {
365
- return false;
366
- }
367
- }
368
- for (let i = 0; i < integration_meta_keys.length; i++) {
369
- const key = keys[i];
370
- if (
371
- ((_d =
372
- (_c =
373
- body_1 === null || body_1 === void 0
374
- ? void 0
375
- : body_1.integration_meta) === null || _c === void 0
376
- ? void 0
377
- : _c[key]) === null || _d === void 0
378
- ? void 0
379
- : _d.toString()) !==
380
- ((_f =
381
- (_e =
382
- body_2 === null || body_2 === void 0
383
- ? void 0
384
- : body_2.integration_meta) === null || _e === void 0
385
- ? void 0
386
- : _e[key]) === null || _f === void 0
387
- ? void 0
388
- : _f.toString())
389
- ) {
390
- return false;
391
- }
205
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
206
+ try {
207
+ const keys = [
208
+ "client_code",
209
+ "name",
210
+ "local_name",
211
+ "city",
212
+ "state",
213
+ "country",
214
+ "contact_name",
215
+ "phone",
216
+ "cell_phone",
217
+ "comment",
218
+ "formatted_address",
219
+ "tags",
220
+ "credit_limit",
221
+ // "financials",
222
+ "channel",
223
+ "paymentTerm",
224
+ "sv_priceList",
225
+ "disabled",
226
+ "payment_type",
227
+ "integrated_client_balance",
228
+ ];
229
+ const integration_meta_keys = [
230
+ "id",
231
+ "PAYMENTTERM",
232
+ "CLIENTCREDITCONSUMED",
233
+ "CLIENTMAXCHEQUEVALUE",
234
+ "CLIENTCREDITLIMIT",
235
+ "CLIENTPRICELISTID",
236
+ ];
237
+ for (let i = 0; i < keys.length; i++) {
238
+ const key = keys[i];
239
+ if (((_a = body_1[key]) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = body_2[key]) === null || _b === void 0 ? void 0 : _b.toString())) {
240
+ return false;
241
+ }
242
+ }
243
+ for (let i = 0; i < integration_meta_keys.length; i++) {
244
+ const key = keys[i];
245
+ if (((_d = (_c = body_1 === null || body_1 === void 0 ? void 0 : body_1.integration_meta) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.toString()) !==
246
+ ((_f = (_e = body_2 === null || body_2 === void 0 ? void 0 : body_2.integration_meta) === null || _e === void 0 ? void 0 : _e[key]) === null || _f === void 0 ? void 0 : _f.toString())) {
247
+ return false;
248
+ }
249
+ }
250
+ if (((_h = (_g = body_1 === null || body_1 === void 0 ? void 0 : body_1.integration_meta) === null || _g === void 0 ? void 0 : _g["financials"]) === null || _h === void 0 ? void 0 : _h.credit_limit) !==
251
+ ((_k = (_j = body_2 === null || body_2 === void 0 ? void 0 : body_2.integration_meta) === null || _j === void 0 ? void 0 : _j["financials"]) === null || _k === void 0 ? void 0 : _k.credit_limit)) {
252
+ return false;
253
+ }
254
+ return true;
392
255
  }
393
- if (
394
- ((_h =
395
- (_g =
396
- body_1 === null || body_1 === void 0
397
- ? void 0
398
- : body_1.integration_meta) === null || _g === void 0
399
- ? void 0
400
- : _g["financials"]) === null || _h === void 0
401
- ? void 0
402
- : _h.credit_limit) !==
403
- ((_k =
404
- (_j =
405
- body_2 === null || body_2 === void 0
406
- ? void 0
407
- : body_2.integration_meta) === null || _j === void 0
408
- ? void 0
409
- : _j["financials"]) === null || _k === void 0
410
- ? void 0
411
- : _k.credit_limit)
412
- ) {
413
- return false;
256
+ catch (e) {
257
+ throw e;
414
258
  }
415
- return true;
416
- } catch (e) {
417
- throw e;
418
- }
419
259
  };