repzo-sap-absjo 1.0.26 → 1.0.27

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/changelog.md CHANGED
@@ -9,6 +9,7 @@
9
9
  - [commands/product] assign Foreign Name (ITEMDESCF) in SAP to local_name in Repzo @maramalshen
10
10
  - [actions/payment] add the field UserId where it equals USERID of the SAP API REP @maramalshen
11
11
  - [commands/price_list_disabled] new command: Disabled PriceListItems from Repzo if it is not found on SAP @maramalshen
12
+ - [commands/measureunit] create unique measure-unit for each product, by inject ITEMCODE in integration_meta.id @maramalshen
12
13
 
13
14
  ### Changed
14
15
 
@@ -2,7 +2,7 @@ import Repzo from "repzo";
2
2
  import DataSet from "data-set-query";
3
3
  import { _create, update_bench_time, set_error } from "../util.js";
4
4
  export const sync_measureunit = async (commandEvent) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
6
  const repzo = new Repzo(
7
7
  (_a = commandEvent.app.formData) === null || _a === void 0
8
8
  ? void 0
@@ -169,12 +169,13 @@ export const sync_measureunit = async (commandEvent) => {
169
169
  i++
170
170
  ) {
171
171
  const Uom = sap_UoMs[i];
172
- const key = `${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
172
+ const key = `${Uom.ITEMCODE}_${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
173
173
  if (!unique_UoMs[key]) unique_UoMs[key] = Uom;
174
174
  }
175
175
  unique_UoMs = Object.values(unique_UoMs);
176
176
  const db = new DataSet([], { autoIndex: false });
177
177
  db.createIndex({
178
+ ITEMCODE: true,
178
179
  ALTUOMCODE: true,
179
180
  repzo_factor: true,
180
181
  UOMGROUPENTRY: true,
@@ -196,7 +197,7 @@ export const sync_measureunit = async (commandEvent) => {
196
197
  ((_a = r_UoM.integration_meta) === null || _a === void 0
197
198
  ? void 0
198
199
  : _a.id) ==
199
- `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`
200
+ `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`
200
201
  );
201
202
  });
202
203
  const body = {
@@ -205,9 +206,10 @@ export const sync_measureunit = async (commandEvent) => {
205
206
  factor: sap_UoM.repzo_factor || 0,
206
207
  disabled: false,
207
208
  integration_meta: {
208
- id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
209
+ id: `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
209
210
  UOMGROUPENTRY: sap_UoM.UOMGROUPENTRY,
210
211
  ALTUOMID: sap_UoM.ALTUOMID,
212
+ ITEMCODE: sap_UoM.ITEMCODE,
211
213
  },
212
214
  company_namespace: [nameSpace],
213
215
  };
@@ -229,14 +231,18 @@ export const sync_measureunit = async (commandEvent) => {
229
231
  const found_identical_docs = db.search({
230
232
  ALTUOMCODE: repzo_UoM.name,
231
233
  repzo_factor: repzo_UoM.factor,
232
- UOMGROUPENTRY:
234
+ ITEMCODE:
233
235
  (_e = repzo_UoM.integration_meta) === null || _e === void 0
234
236
  ? void 0
235
- : _e.UOMGROUPENTRY,
236
- ALTUOMID:
237
+ : _e.ITEMCODE,
238
+ UOMGROUPENTRY:
237
239
  (_f = repzo_UoM.integration_meta) === null || _f === void 0
238
240
  ? void 0
239
- : _f.ALTUOMID,
241
+ : _f.UOMGROUPENTRY,
242
+ ALTUOMID:
243
+ (_g = repzo_UoM.integration_meta) === null || _g === void 0
244
+ ? void 0
245
+ : _g.ALTUOMID,
240
246
  });
241
247
  if (found_identical_docs.length) continue;
242
248
  // Update
@@ -283,10 +289,10 @@ export const sync_measureunit = async (commandEvent) => {
283
289
  } catch (e) {
284
290
  //@ts-ignore
285
291
  console.error(
286
- ((_g = e === null || e === void 0 ? void 0 : e.response) === null ||
287
- _g === void 0
292
+ ((_h = e === null || e === void 0 ? void 0 : e.response) === null ||
293
+ _h === void 0
288
294
  ? void 0
289
- : _g.data) || e
295
+ : _h.data) || e
290
296
  );
291
297
  await commandLog.setStatus("fail", e).commit();
292
298
  throw e;
@@ -114,7 +114,7 @@ export const sync_measureunit_family = async (commandEvent) => {
114
114
  const sap_UoM = sap_UoMs[i];
115
115
  const key = sap_UoM.ITEMCODE;
116
116
  if (!sap_unique_family[key]) sap_unique_family[key] = {};
117
- const uom_key = `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`;
117
+ const uom_key = `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`;
118
118
  sap_unique_family[key][uom_key] = 1;
119
119
  }
120
120
  result.sap_total =
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.26",
4
+ "version": "1.0.27",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -21,7 +21,7 @@
21
21
  "lint": "npx prettier --write .",
22
22
  "build": "tsc && npm run lint",
23
23
  "test": "mocha",
24
- "mac": "npm run build && node ./lib/test/commands/basic.js"
24
+ "mac": "npm run build && node ./lib/test/commands/***.js"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
@@ -156,7 +156,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
156
156
 
157
157
  for (let i = 0; i < sap_UoMs?.length; i++) {
158
158
  const Uom = sap_UoMs[i];
159
- const key = `${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
159
+ const key = `${Uom.ITEMCODE}_${Uom.UOMGROUPENTRY}_${Uom.ALTUOMID}`;
160
160
  if (!unique_UoMs[key]) unique_UoMs[key] = Uom;
161
161
  }
162
162
 
@@ -164,6 +164,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
164
164
 
165
165
  const db = new DataSet([], { autoIndex: false });
166
166
  db.createIndex({
167
+ ITEMCODE: true,
167
168
  ALTUOMCODE: true,
168
169
  repzo_factor: true,
169
170
  UOMGROUPENTRY: true,
@@ -176,7 +177,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
176
177
  const repzo_UoM = repzo_UoMs.data.find(
177
178
  (r_UoM) =>
178
179
  r_UoM.integration_meta?.id ==
179
- `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
180
+ `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
180
181
  );
181
182
 
182
183
  const body:
@@ -187,9 +188,10 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
187
188
  factor: sap_UoM.repzo_factor || 0, // ??????
188
189
  disabled: false,
189
190
  integration_meta: {
190
- id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
191
+ id: `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
191
192
  UOMGROUPENTRY: sap_UoM.UOMGROUPENTRY,
192
193
  ALTUOMID: sap_UoM.ALTUOMID,
194
+ ITEMCODE: sap_UoM.ITEMCODE,
193
195
  },
194
196
  company_namespace: [nameSpace],
195
197
  };
@@ -214,6 +216,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
214
216
  const found_identical_docs = db.search({
215
217
  ALTUOMCODE: repzo_UoM.name,
216
218
  repzo_factor: repzo_UoM.factor,
219
+ ITEMCODE: repzo_UoM.integration_meta?.ITEMCODE,
217
220
  UOMGROUPENTRY: repzo_UoM.integration_meta?.UOMGROUPENTRY,
218
221
  ALTUOMID: repzo_UoM.integration_meta?.ALTUOMID,
219
222
  });
@@ -92,7 +92,7 @@ export const sync_measureunit_family = async (commandEvent: CommandEvent) => {
92
92
  const sap_UoM = sap_UoMs[i];
93
93
  const key = sap_UoM.ITEMCODE;
94
94
  if (!sap_unique_family[key]) sap_unique_family[key] = {};
95
- const uom_key = `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`;
95
+ const uom_key = `${nameSpace}_${sap_UoM.ITEMCODE}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`;
96
96
  sap_unique_family[key][uom_key] = 1;
97
97
  }
98
98