repzo-sap-absjo 1.0.20 → 1.0.22

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 (90) hide show
  1. package/changelog.md +1 -0
  2. package/lib/actions/create_invoice.d.ts +19 -13
  3. package/lib/actions/create_invoice.js +359 -210
  4. package/lib/actions/create_payment.d.ts +4 -1
  5. package/lib/actions/create_payment.js +195 -107
  6. package/lib/actions/create_proforma.d.ts +4 -1
  7. package/lib/actions/create_proforma.js +288 -147
  8. package/lib/actions/create_return_invoice.d.ts +4 -1
  9. package/lib/actions/create_return_invoice.js +312 -158
  10. package/lib/actions/create_transfer.d.ts +4 -1
  11. package/lib/actions/create_transfer.js +223 -126
  12. package/lib/actions/index.js +23 -15
  13. package/lib/commands/adjust_inventory.d.ts +4 -2
  14. package/lib/commands/adjust_inventory.js +290 -160
  15. package/lib/commands/bank.d.ts +4 -2
  16. package/lib/commands/bank.js +279 -157
  17. package/lib/commands/basic.js +68 -48
  18. package/lib/commands/brand.d.ts +3 -1
  19. package/lib/commands/brand.js +174 -100
  20. package/lib/commands/category.d.ts +3 -1
  21. package/lib/commands/category.js +178 -104
  22. package/lib/commands/channel.d.ts +3 -1
  23. package/lib/commands/channel.js +198 -117
  24. package/lib/commands/client.d.ts +34 -32
  25. package/lib/commands/client.js +404 -244
  26. package/lib/commands/client_disabled.d.ts +3 -1
  27. package/lib/commands/client_disabled.js +163 -94
  28. package/lib/commands/index.d.ts +24 -11
  29. package/lib/commands/index.js +65 -62
  30. package/lib/commands/join.js +192 -66
  31. package/lib/commands/measureunit.d.ts +19 -14
  32. package/lib/commands/measureunit.js +289 -191
  33. package/lib/commands/measureunit_family.d.ts +10 -8
  34. package/lib/commands/measureunit_family.js +250 -138
  35. package/lib/commands/payment_term.d.ts +3 -1
  36. package/lib/commands/payment_term.js +202 -123
  37. package/lib/commands/price_list.d.ts +15 -15
  38. package/lib/commands/price_list.js +617 -326
  39. package/lib/commands/price_list_disabled.d.ts +12 -0
  40. package/lib/commands/price_list_disabled.js +216 -0
  41. package/lib/commands/product.d.ts +32 -30
  42. package/lib/commands/product.js +485 -263
  43. package/lib/commands/product_disabled.d.ts +3 -1
  44. package/lib/commands/product_disabled.js +160 -94
  45. package/lib/commands/rep.js +221 -141
  46. package/lib/commands/tag.js +174 -109
  47. package/lib/commands/tax.js +177 -112
  48. package/lib/commands/warehouse.d.ts +3 -1
  49. package/lib/commands/warehouse.js +207 -119
  50. package/lib/index.d.ts +30 -12
  51. package/lib/test/actions/create_invoice.js +193 -188
  52. package/lib/test/actions/create_payment.js +112 -107
  53. package/lib/test/actions/create_proforma.js +220 -216
  54. package/lib/test/actions/create_return_invoice.js +205 -200
  55. package/lib/test/actions/create_transfer.js +120 -115
  56. package/lib/test/commands/adjust_inventory.js +90 -90
  57. package/lib/test/commands/bank.js +90 -90
  58. package/lib/test/commands/basic.js +335 -327
  59. package/lib/test/commands/brand.js +90 -90
  60. package/lib/test/commands/category.js +90 -90
  61. package/lib/test/commands/channel.js +90 -90
  62. package/lib/test/commands/client.js +355 -353
  63. package/lib/test/commands/client_disabled.js +90 -90
  64. package/lib/test/commands/join.js +328 -327
  65. package/lib/test/commands/measureunit.js +90 -90
  66. package/lib/test/commands/measureunit_family.js +90 -90
  67. package/lib/test/commands/payment_term.js +90 -90
  68. package/lib/test/commands/price_list.js +337 -334
  69. package/lib/test/commands/price_list_disabled.d.ts +1 -0
  70. package/lib/test/commands/price_list_disabled.js +359 -0
  71. package/lib/test/commands/product.js +90 -90
  72. package/lib/test/commands/product_disabled.js +90 -90
  73. package/lib/test/commands/rep.js +346 -344
  74. package/lib/test/commands/tag.js +90 -90
  75. package/lib/test/commands/tax.js +90 -90
  76. package/lib/test/commands/warehouse.js +90 -90
  77. package/lib/types.d.ts +78 -53
  78. package/lib/util.d.ts +76 -19
  79. package/lib/util.js +179 -144
  80. package/package.json +1 -1
  81. package/src/actions/create_invoice.ts +7 -18
  82. package/src/actions/create_proforma.ts +11 -1
  83. package/src/commands/basic.ts +1 -0
  84. package/src/commands/index.ts +3 -0
  85. package/src/commands/price_list.ts +7 -2
  86. package/src/commands/price_list_disabled.ts +194 -0
  87. package/src/test/commands/basic.ts +7 -0
  88. package/src/test/commands/price_list_disabled.ts +362 -0
  89. package/src/types.ts +1 -0
  90. package/src/util.ts +18 -1
@@ -1,119 +1,184 @@
1
1
  import Repzo from "repzo";
2
2
  import DataSet from "data-set-query";
3
- import { _create, update_bench_time, set_error, } from "../util.js";
3
+ import { _create, update_bench_time, set_error } from "../util.js";
4
4
  export const sync_tag = async (commandEvent) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
6
- const repzo = new Repzo((_a = commandEvent.app.formData) === null || _a === void 0 ? void 0 : _a.repzoApiKey, {
7
- env: commandEvent.env,
5
+ var _a, _b, _c, _d, _e, _f, _g;
6
+ const repzo = new Repzo(
7
+ (_a = commandEvent.app.formData) === null || _a === void 0
8
+ ? void 0
9
+ : _a.repzoApiKey,
10
+ {
11
+ env: commandEvent.env,
12
+ }
13
+ );
14
+ const commandLog = new Repzo.CommandLog(
15
+ repzo,
16
+ commandEvent.app,
17
+ commandEvent.command
18
+ );
19
+ try {
20
+ // console.log("sync_tag");
21
+ const new_bench_time = new Date().toISOString();
22
+ const bench_time_key = "bench_time_tag";
23
+ await commandLog.load(commandEvent.sync_id);
24
+ await commandLog.addDetail("Repzo SAP: Started Syncing Tags").commit();
25
+ const nameSpace = commandEvent.nameSpace.join("_");
26
+ const result = {
27
+ sap_total: 0,
28
+ repzo_total: 0,
29
+ created: 0,
30
+ updated: 0,
31
+ failed: 0,
32
+ };
33
+ const failed_docs_report = [];
34
+ const sap_tags = await get_sap_tags(
35
+ commandEvent.app.formData.sapHostUrl,
36
+ {}
37
+ );
38
+ result.sap_total =
39
+ (_b =
40
+ sap_tags === null || sap_tags === void 0
41
+ ? void 0
42
+ : sap_tags.Territories) === null || _b === void 0
43
+ ? void 0
44
+ : _b.length;
45
+ await commandLog
46
+ .addDetail(`${result.sap_total} Territories in SAP`)
47
+ .commit();
48
+ const db = new DataSet([], { autoIndex: false });
49
+ db.createIndex({
50
+ TerritoryID: true,
51
+ Description: true,
8
52
  });
9
- const commandLog = new Repzo.CommandLog(repzo, commandEvent.app, commandEvent.command);
10
- try {
11
- // console.log("sync_tag");
12
- const new_bench_time = new Date().toISOString();
13
- const bench_time_key = "bench_time_tag";
14
- await commandLog.load(commandEvent.sync_id);
15
- await commandLog.addDetail("Repzo SAP: Started Syncing Tags").commit();
16
- const nameSpace = commandEvent.nameSpace.join("_");
17
- const result = {
18
- sap_total: 0,
19
- repzo_total: 0,
20
- created: 0,
21
- updated: 0,
22
- failed: 0,
23
- };
24
- const failed_docs_report = [];
25
- const sap_tags = await get_sap_tags(commandEvent.app.formData.sapHostUrl, {});
26
- result.sap_total = (_b = sap_tags === null || sap_tags === void 0 ? void 0 : sap_tags.Territories) === null || _b === void 0 ? void 0 : _b.length;
27
- await commandLog
28
- .addDetail(`${result.sap_total} Territories in SAP`)
29
- .commit();
30
- const db = new DataSet([], { autoIndex: false });
31
- db.createIndex({
32
- TerritoryID: true,
33
- Description: true,
53
+ db.load(
54
+ sap_tags === null || sap_tags === void 0 ? void 0 : sap_tags.Territories
55
+ );
56
+ const repzo_tags = await repzo.tag.find({ type: "area", per_page: 50000 });
57
+ result.repzo_total =
58
+ (_c =
59
+ repzo_tags === null || repzo_tags === void 0
60
+ ? void 0
61
+ : repzo_tags.data) === null || _c === void 0
62
+ ? void 0
63
+ : _c.length;
64
+ await commandLog
65
+ .addDetail(
66
+ `${
67
+ (_d =
68
+ repzo_tags === null || repzo_tags === void 0
69
+ ? void 0
70
+ : repzo_tags.data) === null || _d === void 0
71
+ ? void 0
72
+ : _d.length
73
+ } Area Tags in Repzo`
74
+ )
75
+ .commit();
76
+ for (
77
+ let i = 0;
78
+ i <
79
+ ((_e =
80
+ sap_tags === null || sap_tags === void 0
81
+ ? void 0
82
+ : sap_tags.Territories) === null || _e === void 0
83
+ ? void 0
84
+ : _e.length);
85
+ i++
86
+ ) {
87
+ const sap_tag = sap_tags.Territories[i];
88
+ const repzo_tag = repzo_tags.data.find((r_tag) => {
89
+ var _a;
90
+ return (
91
+ ((_a = r_tag.integration_meta) === null || _a === void 0
92
+ ? void 0
93
+ : _a.id) == `${nameSpace}_${sap_tag.TerritoryID}`
94
+ );
95
+ });
96
+ const body = {
97
+ tag: sap_tag.Description,
98
+ type: "area",
99
+ disabled: false,
100
+ integration_meta: {
101
+ id: `${nameSpace}_${sap_tag.TerritoryID}`,
102
+ TerritoryID: sap_tag.TerritoryID,
103
+ },
104
+ company_namespace: [nameSpace],
105
+ };
106
+ if (!repzo_tag) {
107
+ // Create
108
+ try {
109
+ const created_tag = await repzo.tag.create(body);
110
+ result.created++;
111
+ } catch (e) {
112
+ // console.log("Create Tag Failed >> ", e?.response, body);
113
+ failed_docs_report.push({
114
+ method: "create",
115
+ doc: body,
116
+ error_message: set_error(e),
117
+ });
118
+ result.failed++;
119
+ }
120
+ } else {
121
+ const found_identical_docs = db.search({
122
+ TerritoryID:
123
+ (_f = repzo_tag.integration_meta) === null || _f === void 0
124
+ ? void 0
125
+ : _f.TerritoryID,
126
+ Description: repzo_tag.tag,
34
127
  });
35
- db.load(sap_tags === null || sap_tags === void 0 ? void 0 : sap_tags.Territories);
36
- const repzo_tags = await repzo.tag.find({ type: "area", per_page: 50000 });
37
- result.repzo_total = (_c = repzo_tags === null || repzo_tags === void 0 ? void 0 : repzo_tags.data) === null || _c === void 0 ? void 0 : _c.length;
38
- await commandLog
39
- .addDetail(`${(_d = repzo_tags === null || repzo_tags === void 0 ? void 0 : repzo_tags.data) === null || _d === void 0 ? void 0 : _d.length} Area Tags in Repzo`)
40
- .commit();
41
- for (let i = 0; i < ((_e = sap_tags === null || sap_tags === void 0 ? void 0 : sap_tags.Territories) === null || _e === void 0 ? void 0 : _e.length); i++) {
42
- const sap_tag = sap_tags.Territories[i];
43
- const repzo_tag = repzo_tags.data.find((r_tag) => { var _a; return ((_a = r_tag.integration_meta) === null || _a === void 0 ? void 0 : _a.id) == `${nameSpace}_${sap_tag.TerritoryID}`; });
44
- const body = {
45
- tag: sap_tag.Description,
46
- type: "area",
47
- disabled: false,
48
- integration_meta: {
49
- id: `${nameSpace}_${sap_tag.TerritoryID}`,
50
- TerritoryID: sap_tag.TerritoryID,
51
- },
52
- company_namespace: [nameSpace],
53
- };
54
- if (!repzo_tag) {
55
- // Create
56
- try {
57
- const created_tag = await repzo.tag.create(body);
58
- result.created++;
59
- }
60
- catch (e) {
61
- // console.log("Create Tag Failed >> ", e?.response, body);
62
- failed_docs_report.push({
63
- method: "create",
64
- doc: body,
65
- error_message: set_error(e),
66
- });
67
- result.failed++;
68
- }
69
- }
70
- else {
71
- const found_identical_docs = db.search({
72
- TerritoryID: (_f = repzo_tag.integration_meta) === null || _f === void 0 ? void 0 : _f.TerritoryID,
73
- Description: repzo_tag.tag,
74
- });
75
- if (found_identical_docs.length)
76
- continue;
77
- // Update
78
- try {
79
- const updated_tag = await repzo.tag.update(repzo_tag._id, body);
80
- result.updated++;
81
- }
82
- catch (e) {
83
- // console.log("Update Tag Failed >> ", e?.response?.data, body);
84
- failed_docs_report.push({
85
- method: "update",
86
- doc_id: repzo_tag === null || repzo_tag === void 0 ? void 0 : repzo_tag._id,
87
- doc: body,
88
- error_message: set_error(e),
89
- });
90
- result.failed++;
91
- }
92
- }
128
+ if (found_identical_docs.length) continue;
129
+ // Update
130
+ try {
131
+ const updated_tag = await repzo.tag.update(repzo_tag._id, body);
132
+ result.updated++;
133
+ } catch (e) {
134
+ // console.log("Update Tag Failed >> ", e?.response?.data, body);
135
+ failed_docs_report.push({
136
+ method: "update",
137
+ doc_id:
138
+ repzo_tag === null || repzo_tag === void 0
139
+ ? void 0
140
+ : repzo_tag._id,
141
+ doc: body,
142
+ error_message: set_error(e),
143
+ });
144
+ result.failed++;
93
145
  }
94
- // console.log(result);
95
- await update_bench_time(repzo, commandEvent.app._id, bench_time_key, new_bench_time);
96
- await commandLog
97
- .setStatus("success", failed_docs_report.length ? failed_docs_report : null)
98
- .setBody(result)
99
- .commit();
100
- return result;
101
- }
102
- catch (e) {
103
- //@ts-ignore
104
- console.error(((_g = e === null || e === void 0 ? void 0 : e.response) === null || _g === void 0 ? void 0 : _g.data) || e);
105
- await commandLog.setStatus("fail", e).commit();
106
- throw e;
146
+ }
107
147
  }
148
+ // console.log(result);
149
+ await update_bench_time(
150
+ repzo,
151
+ commandEvent.app._id,
152
+ bench_time_key,
153
+ new_bench_time
154
+ );
155
+ await commandLog
156
+ .setStatus(
157
+ "success",
158
+ failed_docs_report.length ? failed_docs_report : null
159
+ )
160
+ .setBody(result)
161
+ .commit();
162
+ return result;
163
+ } catch (e) {
164
+ //@ts-ignore
165
+ console.error(
166
+ ((_g = e === null || e === void 0 ? void 0 : e.response) === null ||
167
+ _g === void 0
168
+ ? void 0
169
+ : _g.data) || e
170
+ );
171
+ await commandLog.setStatus("fail", e).commit();
172
+ throw e;
173
+ }
108
174
  };
109
175
  const get_sap_tags = async (serviceEndPoint, query) => {
110
- try {
111
- const sap_tags = await _create(serviceEndPoint, "/Territories", {
112
- Inactive: "N",
113
- });
114
- return sap_tags;
115
- }
116
- catch (e) {
117
- throw e;
118
- }
176
+ try {
177
+ const sap_tags = await _create(serviceEndPoint, "/Territories", {
178
+ Inactive: "N",
179
+ });
180
+ return sap_tags;
181
+ } catch (e) {
182
+ throw e;
183
+ }
119
184
  };
@@ -1,122 +1,187 @@
1
1
  import Repzo from "repzo";
2
2
  import DataSet from "data-set-query";
3
- import { _create, update_bench_time, set_error, } from "../util.js";
3
+ import { _create, update_bench_time, set_error } from "../util.js";
4
4
  export const sync_tax = async (commandEvent) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
6
- const repzo = new Repzo((_a = commandEvent.app.formData) === null || _a === void 0 ? void 0 : _a.repzoApiKey, {
7
- env: commandEvent.env,
5
+ var _a, _b, _c, _d, _e, _f, _g;
6
+ const repzo = new Repzo(
7
+ (_a = commandEvent.app.formData) === null || _a === void 0
8
+ ? void 0
9
+ : _a.repzoApiKey,
10
+ {
11
+ env: commandEvent.env,
12
+ }
13
+ );
14
+ const commandLog = new Repzo.CommandLog(
15
+ repzo,
16
+ commandEvent.app,
17
+ commandEvent.command
18
+ );
19
+ try {
20
+ // console.log("sync_tax");
21
+ const new_bench_time = new Date().toISOString();
22
+ const bench_time_key = "bench_time_tax";
23
+ await commandLog.load(commandEvent.sync_id);
24
+ await commandLog.addDetail("Repzo SAP: Started Syncing Taxes").commit();
25
+ const nameSpace = commandEvent.nameSpace.join("_");
26
+ const result = {
27
+ sap_total: 0,
28
+ repzo_total: 0,
29
+ created: 0,
30
+ updated: 0,
31
+ failed: 0,
32
+ };
33
+ const failed_docs_report = [];
34
+ const sap_taxes = await get_sap_taxes(
35
+ commandEvent.app.formData.sapHostUrl,
36
+ {}
37
+ );
38
+ result.sap_total =
39
+ (_b =
40
+ sap_taxes === null || sap_taxes === void 0
41
+ ? void 0
42
+ : sap_taxes.Taxes) === null || _b === void 0
43
+ ? void 0
44
+ : _b.length;
45
+ await commandLog.addDetail(`${result.sap_total} taxes in SAP`).commit();
46
+ const db = new DataSet([], { autoIndex: false });
47
+ db.createIndex({
48
+ TaxCode: true,
49
+ TaxName: true,
50
+ TaxRate: true,
51
+ type: "additive",
8
52
  });
9
- const commandLog = new Repzo.CommandLog(repzo, commandEvent.app, commandEvent.command);
10
- try {
11
- // console.log("sync_tax");
12
- const new_bench_time = new Date().toISOString();
13
- const bench_time_key = "bench_time_tax";
14
- await commandLog.load(commandEvent.sync_id);
15
- await commandLog.addDetail("Repzo SAP: Started Syncing Taxes").commit();
16
- const nameSpace = commandEvent.nameSpace.join("_");
17
- const result = {
18
- sap_total: 0,
19
- repzo_total: 0,
20
- created: 0,
21
- updated: 0,
22
- failed: 0,
23
- };
24
- const failed_docs_report = [];
25
- const sap_taxes = await get_sap_taxes(commandEvent.app.formData.sapHostUrl, {});
26
- result.sap_total = (_b = sap_taxes === null || sap_taxes === void 0 ? void 0 : sap_taxes.Taxes) === null || _b === void 0 ? void 0 : _b.length;
27
- await commandLog.addDetail(`${result.sap_total} taxes in SAP`).commit();
28
- const db = new DataSet([], { autoIndex: false });
29
- db.createIndex({
30
- TaxCode: true,
31
- TaxName: true,
32
- TaxRate: true,
33
- type: "additive",
53
+ db.load(
54
+ sap_taxes === null || sap_taxes === void 0 ? void 0 : sap_taxes.Taxes
55
+ );
56
+ const repzo_taxes = await repzo.tax.find({ per_page: 50000 });
57
+ result.repzo_total =
58
+ (_c =
59
+ repzo_taxes === null || repzo_taxes === void 0
60
+ ? void 0
61
+ : repzo_taxes.data) === null || _c === void 0
62
+ ? void 0
63
+ : _c.length;
64
+ await commandLog
65
+ .addDetail(
66
+ `${
67
+ (_d =
68
+ repzo_taxes === null || repzo_taxes === void 0
69
+ ? void 0
70
+ : repzo_taxes.data) === null || _d === void 0
71
+ ? void 0
72
+ : _d.length
73
+ } taxes in Repzo`
74
+ )
75
+ .commit();
76
+ for (
77
+ let i = 0;
78
+ i <
79
+ ((_e =
80
+ sap_taxes === null || sap_taxes === void 0
81
+ ? void 0
82
+ : sap_taxes.Taxes) === null || _e === void 0
83
+ ? void 0
84
+ : _e.length);
85
+ i++
86
+ ) {
87
+ const sap_tax = sap_taxes.Taxes[i];
88
+ const repzo_tax = repzo_taxes.data.find((r_tax) => {
89
+ var _a;
90
+ return (
91
+ ((_a = r_tax.integration_meta) === null || _a === void 0
92
+ ? void 0
93
+ : _a.id) == `${nameSpace}_${sap_tax.TaxCode}`
94
+ );
95
+ });
96
+ const body = {
97
+ name: sap_tax.TaxName,
98
+ rate: Number(sap_tax.TaxRate / 100),
99
+ type: "additive", // hardcode
100
+ disabled: sap_tax.Inactive === "N" ? false : true,
101
+ integration_meta: {
102
+ id: `${nameSpace}_${sap_tax.TaxCode}`,
103
+ TaxCode: sap_tax.TaxCode,
104
+ },
105
+ company_namespace: [nameSpace],
106
+ };
107
+ if (!repzo_tax) {
108
+ // Create
109
+ try {
110
+ const created_tax = await repzo.tax.create(body);
111
+ result.created++;
112
+ } catch (e) {
113
+ // console.log("Create Tax Failed >> ", e?.response, body);
114
+ failed_docs_report.push({
115
+ method: "create",
116
+ doc: body,
117
+ error_message: set_error(e),
118
+ });
119
+ result.failed++;
120
+ }
121
+ } else {
122
+ const found_identical_docs = db.search({
123
+ TaxCode:
124
+ (_f = repzo_tax.integration_meta) === null || _f === void 0
125
+ ? void 0
126
+ : _f.TaxCode,
127
+ TaxName: repzo_tax.name,
128
+ TaxRate: repzo_tax.rate * 100,
129
+ type: repzo_tax.type,
34
130
  });
35
- db.load(sap_taxes === null || sap_taxes === void 0 ? void 0 : sap_taxes.Taxes);
36
- const repzo_taxes = await repzo.tax.find({ per_page: 50000 });
37
- result.repzo_total = (_c = repzo_taxes === null || repzo_taxes === void 0 ? void 0 : repzo_taxes.data) === null || _c === void 0 ? void 0 : _c.length;
38
- await commandLog
39
- .addDetail(`${(_d = repzo_taxes === null || repzo_taxes === void 0 ? void 0 : repzo_taxes.data) === null || _d === void 0 ? void 0 : _d.length} taxes in Repzo`)
40
- .commit();
41
- for (let i = 0; i < ((_e = sap_taxes === null || sap_taxes === void 0 ? void 0 : sap_taxes.Taxes) === null || _e === void 0 ? void 0 : _e.length); i++) {
42
- const sap_tax = sap_taxes.Taxes[i];
43
- const repzo_tax = repzo_taxes.data.find((r_tax) => { var _a; return ((_a = r_tax.integration_meta) === null || _a === void 0 ? void 0 : _a.id) == `${nameSpace}_${sap_tax.TaxCode}`; });
44
- const body = {
45
- name: sap_tax.TaxName,
46
- rate: Number(sap_tax.TaxRate / 100),
47
- type: "additive",
48
- disabled: sap_tax.Inactive === "N" ? false : true,
49
- integration_meta: {
50
- id: `${nameSpace}_${sap_tax.TaxCode}`,
51
- TaxCode: sap_tax.TaxCode,
52
- },
53
- company_namespace: [nameSpace],
54
- };
55
- if (!repzo_tax) {
56
- // Create
57
- try {
58
- const created_tax = await repzo.tax.create(body);
59
- result.created++;
60
- }
61
- catch (e) {
62
- // console.log("Create Tax Failed >> ", e?.response, body);
63
- failed_docs_report.push({
64
- method: "create",
65
- doc: body,
66
- error_message: set_error(e),
67
- });
68
- result.failed++;
69
- }
70
- }
71
- else {
72
- const found_identical_docs = db.search({
73
- TaxCode: (_f = repzo_tax.integration_meta) === null || _f === void 0 ? void 0 : _f.TaxCode,
74
- TaxName: repzo_tax.name,
75
- TaxRate: repzo_tax.rate * 100,
76
- type: repzo_tax.type,
77
- });
78
- if (found_identical_docs.length)
79
- continue;
80
- // Update
81
- try {
82
- const updated_tax = await repzo.tax.update(repzo_tax._id, body);
83
- result.updated++;
84
- }
85
- catch (e) {
86
- // console.log("Update Tax Failed >> ", e?.response?.data, body);
87
- failed_docs_report.push({
88
- method: "update",
89
- doc_id: repzo_tax === null || repzo_tax === void 0 ? void 0 : repzo_tax._id,
90
- doc: body,
91
- error_message: set_error(e),
92
- });
93
- result.failed++;
94
- }
95
- }
131
+ if (found_identical_docs.length) continue;
132
+ // Update
133
+ try {
134
+ const updated_tax = await repzo.tax.update(repzo_tax._id, body);
135
+ result.updated++;
136
+ } catch (e) {
137
+ // console.log("Update Tax Failed >> ", e?.response?.data, body);
138
+ failed_docs_report.push({
139
+ method: "update",
140
+ doc_id:
141
+ repzo_tax === null || repzo_tax === void 0
142
+ ? void 0
143
+ : repzo_tax._id,
144
+ doc: body,
145
+ error_message: set_error(e),
146
+ });
147
+ result.failed++;
96
148
  }
97
- // console.log(result);
98
- await update_bench_time(repzo, commandEvent.app._id, bench_time_key, new_bench_time);
99
- await commandLog
100
- .setStatus("success", failed_docs_report.length ? failed_docs_report : null)
101
- .setBody(result)
102
- .commit();
103
- return result;
104
- }
105
- catch (e) {
106
- //@ts-ignore
107
- console.error(((_g = e === null || e === void 0 ? void 0 : e.response) === null || _g === void 0 ? void 0 : _g.data) || e);
108
- await commandLog.setStatus("fail", e).commit();
109
- throw e;
149
+ }
110
150
  }
151
+ // console.log(result);
152
+ await update_bench_time(
153
+ repzo,
154
+ commandEvent.app._id,
155
+ bench_time_key,
156
+ new_bench_time
157
+ );
158
+ await commandLog
159
+ .setStatus(
160
+ "success",
161
+ failed_docs_report.length ? failed_docs_report : null
162
+ )
163
+ .setBody(result)
164
+ .commit();
165
+ return result;
166
+ } catch (e) {
167
+ //@ts-ignore
168
+ console.error(
169
+ ((_g = e === null || e === void 0 ? void 0 : e.response) === null ||
170
+ _g === void 0
171
+ ? void 0
172
+ : _g.data) || e
173
+ );
174
+ await commandLog.setStatus("fail", e).commit();
175
+ throw e;
176
+ }
111
177
  };
112
178
  const get_sap_taxes = async (serviceEndPoint, query) => {
113
- try {
114
- const sap_taxes = await _create(serviceEndPoint, "/Taxes", {
115
- Inactive: "N",
116
- });
117
- return sap_taxes;
118
- }
119
- catch (e) {
120
- throw e;
121
- }
179
+ try {
180
+ const sap_taxes = await _create(serviceEndPoint, "/Taxes", {
181
+ Inactive: "N",
182
+ });
183
+ return sap_taxes;
184
+ } catch (e) {
185
+ throw e;
186
+ }
122
187
  };
@@ -1,2 +1,4 @@
1
1
  import { CommandEvent, Result } from "../types";
2
- export declare const sync_warehouse: (commandEvent: CommandEvent) => Promise<Result>;
2
+ export declare const sync_warehouse: (
3
+ commandEvent: CommandEvent
4
+ ) => Promise<Result>;