repzo-sap-absjo 1.0.1

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 (157) hide show
  1. package/README.md +3 -0
  2. package/changelog.md +17 -0
  3. package/lib/actions/create_invoice.d.ts +26 -0
  4. package/lib/actions/create_invoice.js +311 -0
  5. package/lib/actions/create_payment.d.ts +5 -0
  6. package/lib/actions/create_payment.js +177 -0
  7. package/lib/actions/create_proforma.d.ts +5 -0
  8. package/lib/actions/create_proforma.js +241 -0
  9. package/lib/actions/create_return_invoice.d.ts +5 -0
  10. package/lib/actions/create_return_invoice.js +268 -0
  11. package/lib/actions/create_transfer.d.ts +5 -0
  12. package/lib/actions/create_transfer.js +171 -0
  13. package/lib/actions/index.d.ts +3 -0
  14. package/lib/actions/index.js +31 -0
  15. package/lib/commands/adjust_inventory.d.ts +6 -0
  16. package/lib/commands/adjust_inventory.js +303 -0
  17. package/lib/commands/bank.d.ts +7 -0
  18. package/lib/commands/bank.js +301 -0
  19. package/lib/commands/basic.d.ts +2 -0
  20. package/lib/commands/basic.js +73 -0
  21. package/lib/commands/category.d.ts +4 -0
  22. package/lib/commands/category.js +193 -0
  23. package/lib/commands/channel.d.ts +4 -0
  24. package/lib/commands/channel.js +213 -0
  25. package/lib/commands/client.d.ts +39 -0
  26. package/lib/commands/client.js +410 -0
  27. package/lib/commands/client_disabled.d.ts +4 -0
  28. package/lib/commands/client_disabled.js +183 -0
  29. package/lib/commands/index.d.ts +23 -0
  30. package/lib/commands/index.js +82 -0
  31. package/lib/commands/join.d.ts +2 -0
  32. package/lib/commands/join.js +134 -0
  33. package/lib/commands/measureunit.d.ts +23 -0
  34. package/lib/commands/measureunit.js +314 -0
  35. package/lib/commands/measureunit_family.d.ts +12 -0
  36. package/lib/commands/measureunit_family.js +263 -0
  37. package/lib/commands/payment_term.d.ts +4 -0
  38. package/lib/commands/payment_term.js +217 -0
  39. package/lib/commands/price_list.d.ts +18 -0
  40. package/lib/commands/price_list.js +608 -0
  41. package/lib/commands/product.d.ts +39 -0
  42. package/lib/commands/product.js +454 -0
  43. package/lib/commands/product_disabled.d.ts +4 -0
  44. package/lib/commands/product_disabled.js +178 -0
  45. package/lib/commands/rep.d.ts +2 -0
  46. package/lib/commands/rep.js +246 -0
  47. package/lib/commands/tag.d.ts +2 -0
  48. package/lib/commands/tag.js +195 -0
  49. package/lib/commands/tax.d.ts +2 -0
  50. package/lib/commands/tax.js +198 -0
  51. package/lib/commands/warehouse.d.ts +4 -0
  52. package/lib/commands/warehouse.js +221 -0
  53. package/lib/index.d.ts +29 -0
  54. package/lib/index.js +6 -0
  55. package/lib/test/actions/create_invoice.d.ts +1 -0
  56. package/lib/test/actions/create_invoice.js +214 -0
  57. package/lib/test/actions/create_payment.d.ts +1 -0
  58. package/lib/test/actions/create_payment.js +131 -0
  59. package/lib/test/actions/create_proforma.d.ts +1 -0
  60. package/lib/test/actions/create_proforma.js +242 -0
  61. package/lib/test/actions/create_return_invoice.d.ts +1 -0
  62. package/lib/test/actions/create_return_invoice.js +226 -0
  63. package/lib/test/actions/create_transfer.d.ts +1 -0
  64. package/lib/test/actions/create_transfer.js +142 -0
  65. package/lib/test/commands/adjust_inventory.d.ts +1 -0
  66. package/lib/test/commands/adjust_inventory.js +97 -0
  67. package/lib/test/commands/bank.d.ts +1 -0
  68. package/lib/test/commands/bank.js +97 -0
  69. package/lib/test/commands/basic.d.ts +1 -0
  70. package/lib/test/commands/basic.js +339 -0
  71. package/lib/test/commands/category.d.ts +1 -0
  72. package/lib/test/commands/category.js +97 -0
  73. package/lib/test/commands/channel.d.ts +1 -0
  74. package/lib/test/commands/channel.js +97 -0
  75. package/lib/test/commands/client.d.ts +1 -0
  76. package/lib/test/commands/client.js +97 -0
  77. package/lib/test/commands/client_disabled.d.ts +1 -0
  78. package/lib/test/commands/client_disabled.js +97 -0
  79. package/lib/test/commands/join.d.ts +1 -0
  80. package/lib/test/commands/join.js +339 -0
  81. package/lib/test/commands/measureunit.d.ts +1 -0
  82. package/lib/test/commands/measureunit.js +97 -0
  83. package/lib/test/commands/measureunit_family.d.ts +1 -0
  84. package/lib/test/commands/measureunit_family.js +97 -0
  85. package/lib/test/commands/payment_term.d.ts +1 -0
  86. package/lib/test/commands/payment_term.js +97 -0
  87. package/lib/test/commands/price_list.d.ts +1 -0
  88. package/lib/test/commands/price_list.js +97 -0
  89. package/lib/test/commands/product.d.ts +1 -0
  90. package/lib/test/commands/product.js +97 -0
  91. package/lib/test/commands/product_disabled.d.ts +1 -0
  92. package/lib/test/commands/product_disabled.js +97 -0
  93. package/lib/test/commands/rep.d.ts +1 -0
  94. package/lib/test/commands/rep.js +97 -0
  95. package/lib/test/commands/tag.d.ts +1 -0
  96. package/lib/test/commands/tag.js +97 -0
  97. package/lib/test/commands/tax.d.ts +1 -0
  98. package/lib/test/commands/tax.js +97 -0
  99. package/lib/test/commands/warehouse.d.ts +1 -0
  100. package/lib/test/commands/warehouse.js +97 -0
  101. package/lib/types.d.ts +77 -0
  102. package/lib/types.js +1 -0
  103. package/lib/util.d.ts +70 -0
  104. package/lib/util.js +164 -0
  105. package/package.json +51 -0
  106. package/src/actions/create_invoice.ts +275 -0
  107. package/src/actions/create_payment.ts +138 -0
  108. package/src/actions/create_proforma.ts +187 -0
  109. package/src/actions/create_return_invoice.ts +217 -0
  110. package/src/actions/create_transfer.ts +160 -0
  111. package/src/actions/index.ts +27 -0
  112. package/src/commands/adjust_inventory.ts +250 -0
  113. package/src/commands/bank.ts +243 -0
  114. package/src/commands/basic.ts +64 -0
  115. package/src/commands/category.ts +176 -0
  116. package/src/commands/channel.ts +219 -0
  117. package/src/commands/client.ts +368 -0
  118. package/src/commands/client_disabled.ts +158 -0
  119. package/src/commands/index.ts +87 -0
  120. package/src/commands/join.ts +80 -0
  121. package/src/commands/measureunit.ts +276 -0
  122. package/src/commands/measureunit_family.ts +209 -0
  123. package/src/commands/payment_term.ts +224 -0
  124. package/src/commands/price_list.ts +434 -0
  125. package/src/commands/product.ts +359 -0
  126. package/src/commands/product_disabled.ts +152 -0
  127. package/src/commands/rep.ts +209 -0
  128. package/src/commands/tag.ts +173 -0
  129. package/src/commands/tax.ts +178 -0
  130. package/src/commands/warehouse.ts +204 -0
  131. package/src/index.ts +7 -0
  132. package/src/test/actions/create_invoice.ts +214 -0
  133. package/src/test/actions/create_payment.ts +131 -0
  134. package/src/test/actions/create_proforma.ts +242 -0
  135. package/src/test/actions/create_return_invoice.ts +226 -0
  136. package/src/test/actions/create_transfer.ts +142 -0
  137. package/src/test/commands/adjust_inventory.ts +100 -0
  138. package/src/test/commands/bank.ts +100 -0
  139. package/src/test/commands/basic.ts +342 -0
  140. package/src/test/commands/category.ts +100 -0
  141. package/src/test/commands/channel.ts +100 -0
  142. package/src/test/commands/client.ts +100 -0
  143. package/src/test/commands/client_disabled.ts +100 -0
  144. package/src/test/commands/join.ts +342 -0
  145. package/src/test/commands/measureunit.ts +100 -0
  146. package/src/test/commands/measureunit_family.ts +100 -0
  147. package/src/test/commands/payment_term.ts +100 -0
  148. package/src/test/commands/price_list.ts +100 -0
  149. package/src/test/commands/product.ts +100 -0
  150. package/src/test/commands/product_disabled.ts +100 -0
  151. package/src/test/commands/rep.ts +100 -0
  152. package/src/test/commands/tag.ts +100 -0
  153. package/src/test/commands/tax.ts +100 -0
  154. package/src/test/commands/warehouse.ts +100 -0
  155. package/src/types.ts +76 -0
  156. package/src/util.ts +205 -0
  157. package/tsconfig.json +15 -0
@@ -0,0 +1,134 @@
1
+ import Repzo from "repzo";
2
+ export const join = async (commandEvent) => {
3
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
4
+ const repzo = new Repzo(
5
+ (_a = commandEvent.app.formData) === null || _a === void 0
6
+ ? void 0
7
+ : _a.repzoApiKey,
8
+ {
9
+ env: commandEvent.env,
10
+ }
11
+ );
12
+ const commandLog = new Repzo.CommandLog(
13
+ repzo,
14
+ commandEvent.app,
15
+ commandEvent.command
16
+ );
17
+ try {
18
+ console.log("join");
19
+ await commandLog.load(commandEvent.sync_id);
20
+ await commandLog.addDetail("Repzo SAP: Join").commit();
21
+ const body = {
22
+ data: [
23
+ // invoice
24
+ {
25
+ app: "repzo-sap",
26
+ action: "create_invoice",
27
+ event: "invoiceItems.create",
28
+ join:
29
+ ((_d =
30
+ (_c =
31
+ (_b =
32
+ commandEvent === null || commandEvent === void 0
33
+ ? void 0
34
+ : commandEvent.app) === null || _b === void 0
35
+ ? void 0
36
+ : _b.formData) === null || _c === void 0
37
+ ? void 0
38
+ : _c.invoices) === null || _d === void 0
39
+ ? void 0
40
+ : _d.createInvoiceHook) || false,
41
+ },
42
+ // return_invoice
43
+ {
44
+ app: "repzo-sap",
45
+ action: "create_return_invoice",
46
+ event: "returnItems.create",
47
+ join:
48
+ ((_g =
49
+ (_f =
50
+ (_e =
51
+ commandEvent === null || commandEvent === void 0
52
+ ? void 0
53
+ : commandEvent.app) === null || _e === void 0
54
+ ? void 0
55
+ : _e.formData) === null || _f === void 0
56
+ ? void 0
57
+ : _f.invoices) === null || _g === void 0
58
+ ? void 0
59
+ : _g.createReturnInvoiceHook) || false,
60
+ },
61
+ // payment
62
+ {
63
+ app: "repzo-sap",
64
+ action: "create_payment",
65
+ event: "payment.create",
66
+ join:
67
+ ((_k =
68
+ (_j =
69
+ (_h =
70
+ commandEvent === null || commandEvent === void 0
71
+ ? void 0
72
+ : commandEvent.app) === null || _h === void 0
73
+ ? void 0
74
+ : _h.formData) === null || _j === void 0
75
+ ? void 0
76
+ : _j.payments) === null || _k === void 0
77
+ ? void 0
78
+ : _k.createPaymentHook) || false,
79
+ },
80
+ // proforma
81
+ {
82
+ app: "repzo-sap",
83
+ action: "create_proforma",
84
+ event: "salesorder.approve",
85
+ join:
86
+ ((_o =
87
+ (_m =
88
+ (_l =
89
+ commandEvent === null || commandEvent === void 0
90
+ ? void 0
91
+ : commandEvent.app) === null || _l === void 0
92
+ ? void 0
93
+ : _l.formData) === null || _m === void 0
94
+ ? void 0
95
+ : _m.proformas) === null || _o === void 0
96
+ ? void 0
97
+ : _o.createApprovedProformaHook) || false,
98
+ },
99
+ // transfer
100
+ {
101
+ app: "repzo-sap",
102
+ action: "create_transfer",
103
+ event: "transfer.approve",
104
+ join:
105
+ ((_r =
106
+ (_q =
107
+ (_p =
108
+ commandEvent === null || commandEvent === void 0
109
+ ? void 0
110
+ : commandEvent.app) === null || _p === void 0
111
+ ? void 0
112
+ : _p.formData) === null || _q === void 0
113
+ ? void 0
114
+ : _q.transfers) === null || _r === void 0
115
+ ? void 0
116
+ : _r.createApprovedTransferHook) || false,
117
+ },
118
+ ],
119
+ };
120
+ const result = await repzo.joinActionsWebHook.update(null, body);
121
+ // console.log(result);
122
+ await commandLog.setStatus("success").setBody(result).commit();
123
+ } catch (e) {
124
+ //@ts-ignore
125
+ console.error(
126
+ ((_s = e === null || e === void 0 ? void 0 : e.response) === null ||
127
+ _s === void 0
128
+ ? void 0
129
+ : _s.data) || e
130
+ );
131
+ await commandLog.setStatus("fail", e).commit();
132
+ throw e;
133
+ }
134
+ };
@@ -0,0 +1,23 @@
1
+ import { CommandEvent, Result } from "../types";
2
+ export interface SAPUoM {
3
+ ITEMCODE: string;
4
+ UOMGROUPENTRY: number;
5
+ UOMGROUPCODE: string;
6
+ UOMGROUPNAME: string;
7
+ BASEUOMID: number;
8
+ BASEUOMCODE: string;
9
+ BASEQTY: number;
10
+ ALTUOMID: number;
11
+ ALTUOMCODE: string;
12
+ ALTQTY: number;
13
+ repzo_factor?: number;
14
+ }
15
+ export declare const sync_measureunit: (
16
+ commandEvent: CommandEvent
17
+ ) => Promise<Result>;
18
+ export declare const get_sap_UoMs: (
19
+ serviceEndPoint: string,
20
+ query?: {
21
+ updateAt?: string;
22
+ }
23
+ ) => Promise<SAPUoM[]>;
@@ -0,0 +1,314 @@
1
+ import Repzo from "repzo";
2
+ import DataSet from "data-set-query";
3
+ import { _create, update_bench_time, set_error } from "../util.js";
4
+ export const sync_measureunit = async (commandEvent) => {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
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_measureunit");
21
+ const new_bench_time = new Date().toISOString();
22
+ const bench_time_key = "bench_time_measureunit";
23
+ await commandLog.load(commandEvent.sync_id);
24
+ await commandLog
25
+ .addDetail("Repzo SAP: Started Syncing Measure units")
26
+ .commit();
27
+ const nameSpace = commandEvent.nameSpace.join("_");
28
+ const result = {
29
+ sap_total: 0,
30
+ repzo_total: 0,
31
+ created: 0,
32
+ updated: 0,
33
+ failed: 0,
34
+ };
35
+ const failed_docs_report = [];
36
+ const sap_UoMs = await get_sap_UoMs(
37
+ commandEvent.app.formData.sapHostUrl,
38
+ {}
39
+ );
40
+ result.sap_total =
41
+ sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length;
42
+ await commandLog
43
+ .addDetail(`${result.sap_total} Unit of Measures in SAP`)
44
+ .commit();
45
+ // Get Repzo default measureunit
46
+ const repzo_UoM_parent = await repzo.measureunit.find({
47
+ parent: "nil",
48
+ disabled: false,
49
+ });
50
+ if (
51
+ !(repzo_UoM_parent === null || repzo_UoM_parent === void 0
52
+ ? void 0
53
+ : repzo_UoM_parent.data) ||
54
+ ((_b =
55
+ repzo_UoM_parent === null || repzo_UoM_parent === void 0
56
+ ? void 0
57
+ : repzo_UoM_parent.data) === null || _b === void 0
58
+ ? void 0
59
+ : _b.length) != 1
60
+ )
61
+ throw "the parent of measure unit is not found or the nameSpace has more than one";
62
+ const repzo_parent_id = repzo_UoM_parent.data[0]._id;
63
+ const repzo_UoMs = await repzo.measureunit.find({ per_page: 50000 });
64
+ result.repzo_total =
65
+ (_c =
66
+ repzo_UoMs === null || repzo_UoMs === void 0
67
+ ? void 0
68
+ : repzo_UoMs.data) === null || _c === void 0
69
+ ? void 0
70
+ : _c.length;
71
+ await commandLog
72
+ .addDetail(
73
+ `${
74
+ (_d =
75
+ repzo_UoMs === null || repzo_UoMs === void 0
76
+ ? void 0
77
+ : repzo_UoMs.data) === null || _d === void 0
78
+ ? void 0
79
+ : _d.length
80
+ } Measure Units in Repzo`
81
+ )
82
+ .commit();
83
+ const byProduct = {};
84
+ sap_UoMs.forEach((unit) => {
85
+ if (!byProduct[unit.ITEMCODE]) byProduct[unit.ITEMCODE] = [];
86
+ byProduct[unit.ITEMCODE].push(unit);
87
+ });
88
+ Object.values(byProduct).forEach((units) => {
89
+ var _a, _b, _c, _d;
90
+ const max_unit = {
91
+ sap_product_UoMs: [],
92
+ value: null,
93
+ default_unit: null,
94
+ };
95
+ units.forEach((unit) => {
96
+ if (max_unit.value == null || unit.BASEQTY > max_unit.value) {
97
+ max_unit.value = unit.BASEQTY;
98
+ max_unit.sap_product_UoMs.push(unit);
99
+ } else if (unit.BASEQTY == max_unit.value) {
100
+ max_unit.sap_product_UoMs.push(unit);
101
+ }
102
+ });
103
+ if (max_unit.sap_product_UoMs.length > 1) {
104
+ max_unit.default_unit = max_unit.sap_product_UoMs.find(
105
+ (u) => u.ALTUOMCODE == "PC"
106
+ );
107
+ if (!max_unit.default_unit) {
108
+ console.log(
109
+ "Create/Update Measure Unit Failed >> ",
110
+ `${
111
+ (_a =
112
+ max_unit === null || max_unit === void 0
113
+ ? void 0
114
+ : max_unit.sap_product_UoMs[0]) === null || _a === void 0
115
+ ? void 0
116
+ : _a.ITEMCODE
117
+ } Could not found the base_unit`,
118
+ units
119
+ );
120
+ failed_docs_report.push({
121
+ method: "create",
122
+ doc_id:
123
+ ((_b =
124
+ max_unit === null || max_unit === void 0
125
+ ? void 0
126
+ : max_unit.sap_product_UoMs[0]) === null || _b === void 0
127
+ ? void 0
128
+ : _b.ITEMCODE) ||
129
+ ((_c = units[0]) === null || _c === void 0
130
+ ? void 0
131
+ : _c.ITEMCODE),
132
+ doc: units,
133
+ error_message: set_error(
134
+ `Create/Update Measure Unit Failed >> ${
135
+ (_d =
136
+ max_unit === null || max_unit === void 0
137
+ ? void 0
138
+ : max_unit.sap_product_UoMs[0]) === null || _d === void 0
139
+ ? void 0
140
+ : _d.ITEMCODE
141
+ } Could not found the base_unit`
142
+ ),
143
+ });
144
+ result.failed++;
145
+ return;
146
+ }
147
+ } else {
148
+ max_unit.default_unit = max_unit.sap_product_UoMs[0];
149
+ }
150
+ units.forEach((unit) => {
151
+ var _a;
152
+ if (
153
+ max_unit === null || max_unit === void 0
154
+ ? void 0
155
+ : max_unit.default_unit
156
+ )
157
+ unit.repzo_factor =
158
+ (unit.ALTQTY / unit.BASEQTY) *
159
+ ((_a =
160
+ max_unit === null || max_unit === void 0
161
+ ? void 0
162
+ : max_unit.default_unit) === null || _a === void 0
163
+ ? void 0
164
+ : _a.BASEQTY);
165
+ });
166
+ });
167
+ let unique_UoMs = {};
168
+ for (
169
+ let i = 0;
170
+ i < (sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.length);
171
+ i++
172
+ ) {
173
+ const Uom = sap_UoMs[i];
174
+ const key = `${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
175
+ if (!unique_UoMs[key]) unique_UoMs[key] = Uom;
176
+ }
177
+ unique_UoMs = Object.values(unique_UoMs);
178
+ const db = new DataSet([], { autoIndex: false });
179
+ db.createIndex({
180
+ ALTUOMCODE: true,
181
+ repzo_factor: true,
182
+ UOMGROUPENTRY: true,
183
+ ALTUOMID: true,
184
+ });
185
+ db.load(unique_UoMs);
186
+ for (
187
+ let i = 0;
188
+ i <
189
+ (unique_UoMs === null || unique_UoMs === void 0
190
+ ? void 0
191
+ : unique_UoMs.length);
192
+ i++
193
+ ) {
194
+ const sap_UoM = unique_UoMs[i];
195
+ const repzo_UoM = repzo_UoMs.data.find((r_UoM) => {
196
+ var _a;
197
+ return (
198
+ ((_a = r_UoM.integration_meta) === null || _a === void 0
199
+ ? void 0
200
+ : _a.id) ==
201
+ `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`
202
+ );
203
+ });
204
+ const body = {
205
+ parent: repzo_parent_id,
206
+ name: sap_UoM.ALTUOMCODE,
207
+ factor: sap_UoM.repzo_factor || 0,
208
+ disabled: false,
209
+ integration_meta: {
210
+ id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
211
+ UOMGROUPENTRY: sap_UoM.UOMGROUPENTRY,
212
+ ALTUOMID: sap_UoM.ALTUOMID,
213
+ },
214
+ company_namespace: [nameSpace],
215
+ };
216
+ if (!repzo_UoM) {
217
+ // Create
218
+ try {
219
+ const created_UoM = await repzo.measureunit.create(body);
220
+ result.created++;
221
+ } catch (e) {
222
+ console.log(
223
+ "Create Measure Unit Failed >> ",
224
+ e === null || e === void 0 ? void 0 : e.response,
225
+ body
226
+ );
227
+ failed_docs_report.push({
228
+ method: "create",
229
+ doc: body,
230
+ error_message: set_error(e),
231
+ });
232
+ result.failed++;
233
+ }
234
+ } else {
235
+ const found_identical_docs = db.search({
236
+ ALTUOMCODE: repzo_UoM.name,
237
+ repzo_factor: repzo_UoM.factor,
238
+ UOMGROUPENTRY:
239
+ (_e = repzo_UoM.integration_meta) === null || _e === void 0
240
+ ? void 0
241
+ : _e.UOMGROUPENTRY,
242
+ ALTUOMID:
243
+ (_f = repzo_UoM.integration_meta) === null || _f === void 0
244
+ ? void 0
245
+ : _f.ALTUOMID,
246
+ });
247
+ if (found_identical_docs.length) continue;
248
+ // Update
249
+ try {
250
+ const updated_UoM = await repzo.measureunit.update(
251
+ repzo_UoM._id,
252
+ body
253
+ );
254
+ result.updated++;
255
+ } catch (e) {
256
+ console.log(
257
+ "Update Measure Unit Failed >> ",
258
+ (_g = e === null || e === void 0 ? void 0 : e.response) === null ||
259
+ _g === void 0
260
+ ? void 0
261
+ : _g.data,
262
+ body
263
+ );
264
+ failed_docs_report.push({
265
+ method: "update",
266
+ doc_id:
267
+ repzo_UoM === null || repzo_UoM === void 0
268
+ ? void 0
269
+ : repzo_UoM._id,
270
+ doc: body,
271
+ error_message: set_error(e),
272
+ });
273
+ result.failed++;
274
+ }
275
+ }
276
+ }
277
+ // console.log(result);
278
+ await update_bench_time(
279
+ repzo,
280
+ commandEvent.app._id,
281
+ bench_time_key,
282
+ new_bench_time
283
+ );
284
+ await commandLog
285
+ .setStatus(
286
+ "success",
287
+ failed_docs_report.length ? failed_docs_report : null
288
+ )
289
+ .setBody(result)
290
+ .commit();
291
+ return result;
292
+ } catch (e) {
293
+ //@ts-ignore
294
+ console.error(
295
+ ((_h = e === null || e === void 0 ? void 0 : e.response) === null ||
296
+ _h === void 0
297
+ ? void 0
298
+ : _h.data) || e
299
+ );
300
+ await commandLog.setStatus("fail", e).commit();
301
+ throw e;
302
+ }
303
+ };
304
+ export const get_sap_UoMs = async (serviceEndPoint, query) => {
305
+ try {
306
+ const sap_UoMs = await _create(serviceEndPoint, "/Uom", {
307
+ Inactive: "N",
308
+ Locked: "N",
309
+ });
310
+ return sap_UoMs === null || sap_UoMs === void 0 ? void 0 : sap_UoMs.UoM;
311
+ } catch (e) {
312
+ throw e;
313
+ }
314
+ };
@@ -0,0 +1,12 @@
1
+ import { CommandEvent } from "../types";
2
+ export declare const sync_measureunit_family: (
3
+ commandEvent: CommandEvent
4
+ ) => Promise<{
5
+ sap_total: number;
6
+ repzo_total: number;
7
+ sap_UoM_total: number;
8
+ repzo_UoM_total: number;
9
+ created: number;
10
+ updated: number;
11
+ failed: number;
12
+ }>;