repzo-sap-absjo 1.0.14 → 1.0.16

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.
@@ -282,6 +282,8 @@ export const create_invoice = async (event, options) => {
282
282
  if (!repzo_product)
283
283
  throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
284
284
  items.push({
285
+ MEO_Serial: getUniqueConcatenatedValues(item, "ref", " | "),
286
+ Promotion_Name: getUniqueConcatenatedValues(item, "name", " | "),
285
287
  ItemCode: item.variant.variant_name,
286
288
  Quantity: item.qty,
287
289
  TaxCode: repzo_tax.integration_meta.TaxCode,
@@ -367,3 +369,12 @@ export const get_invoice_from_sap = async (serviceEndPoint, query) => {
367
369
  throw e;
368
370
  }
369
371
  };
372
+ function getUniqueConcatenatedValues(item, key, delimiter) {
373
+ item.general_promotions = item.general_promotions || [];
374
+ item.used_promotions = item.used_promotions || [];
375
+ const allPromotions = [...item.general_promotions, ...item.used_promotions];
376
+ const uniqueValues = new Set(
377
+ allPromotions.map((promotion) => promotion[key]).filter((value) => value)
378
+ );
379
+ return [...uniqueValues].join(delimiter);
380
+ }
@@ -451,6 +451,7 @@ const is_matched = (body_1, body_2) => {
451
451
  "category",
452
452
  "measureunit_family",
453
453
  "sv_measureUnit",
454
+ "brand",
454
455
  ];
455
456
  const integration_meta_keys = [
456
457
  "id",
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.14",
4
+ "version": "1.0.16",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -15,6 +15,8 @@ interface SAPInvoiceItem {
15
15
  UomCode: number; // 3;
16
16
  Brand: null;
17
17
  Department: string; // "D6";
18
+ MEO_Serial: string; //"used_promotion_ref1 | used_promotion_ref2"
19
+ Promotion_Name: string; //"used_promotion_name1 | used_promotion_name2"
18
20
  }
19
21
 
20
22
  interface SAPInvoice {
@@ -236,6 +238,8 @@ export const create_invoice = async (event: EVENT, options: Config) => {
236
238
  throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
237
239
 
238
240
  items.push({
241
+ MEO_Serial: getUniqueConcatenatedValues(item, "ref", " | "),
242
+ Promotion_Name: getUniqueConcatenatedValues(item, "name", " | "),
239
243
  ItemCode: item.variant.variant_name,
240
244
  Quantity: item.qty,
241
245
  TaxCode: repzo_tax.integration_meta.TaxCode,
@@ -321,3 +325,17 @@ export const get_invoice_from_sap = async (
321
325
  throw e;
322
326
  }
323
327
  };
328
+
329
+ function getUniqueConcatenatedValues(
330
+ item: Service.Item.Schema,
331
+ key: "name" | "ref",
332
+ delimiter: string
333
+ ): string {
334
+ item.general_promotions = item.general_promotions || [];
335
+ item.used_promotions = item.used_promotions || [];
336
+ const allPromotions = [...item.general_promotions, ...item.used_promotions];
337
+ const uniqueValues = new Set(
338
+ allPromotions.map((promotion) => promotion[key]).filter((value) => value)
339
+ );
340
+ return [...uniqueValues].join(delimiter);
341
+ }
@@ -47,7 +47,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
47
47
  { key: "sync_to_sap_started", value: true },
48
48
  { key: "sync_to_sap_succeeded", value: false },
49
49
  ],
50
- { _id: body._id, type: "transfers" },
50
+ { _id: body._id, type: "transfers" }
51
51
  );
52
52
  } catch (e) {
53
53
  console.error(e);
@@ -56,7 +56,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
56
56
  await actionLog
57
57
  .addDetail(`Transfer - ${repzo_serial_number} => ${body?.sync_id}`)
58
58
  .addDetail(
59
- `Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`,
59
+ `Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`
60
60
  )
61
61
  .commit();
62
62
 
@@ -82,7 +82,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
82
82
  if (item?.product_id) {
83
83
  repzo_product_ids[item.product_id.toString()] = true;
84
84
  }
85
- },
85
+ }
86
86
  );
87
87
  const repzo_products = await repzo.patchAction.create(
88
88
  {
@@ -95,7 +95,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
95
95
  },
96
96
  ],
97
97
  },
98
- { per_page: 50000, populatedKeys: ["measureunit"] },
98
+ { per_page: 50000, populatedKeys: ["measureunit"] }
99
99
  );
100
100
 
101
101
  // Prepare Transfer Items
@@ -106,14 +106,14 @@ export const create_transfer = async (event: EVENT, options: Config) => {
106
106
 
107
107
  const repzo_product = repzo_products?.data?.find(
108
108
  //@ts-ignore
109
- (p) => p._id.toString() == repzo_transfer_item.product_id?.toString(),
109
+ (p) => p._id.toString() == repzo_transfer_item.product_id?.toString()
110
110
  );
111
111
  if (!repzo_product) {
112
112
  // console.log(
113
113
  // `Product with _id: ${repzo_transfer_item.product_id} was not found In Repzo`,
114
114
  // );
115
115
  throw new Error(
116
- `Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo`,
116
+ `Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo`
117
117
  );
118
118
  }
119
119
 
@@ -124,7 +124,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
124
124
  // `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
125
125
  // );
126
126
  throw new Error(
127
- `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
127
+ `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`
128
128
  );
129
129
  }
130
130
 
@@ -156,20 +156,20 @@ export const create_transfer = async (event: EVENT, options: Config) => {
156
156
 
157
157
  actionLog.addDetail(
158
158
  `Repzo => SAP: Transfer - ${repzo_serial_number}`,
159
- sap_transfer,
159
+ sap_transfer
160
160
  );
161
161
 
162
162
  const result = await _create(
163
163
  SAP_HOST_URL,
164
164
  "/AddStockTransfer",
165
- sap_transfer,
165
+ sap_transfer
166
166
  );
167
167
 
168
168
  // console.log(result);
169
169
  try {
170
170
  await repzo.updateIntegrationMeta.create(
171
171
  [{ key: "sync_to_sap_succeeded", value: true }],
172
- { _id: body._id, type: "transfers" },
172
+ { _id: body._id, type: "transfers" }
173
173
  );
174
174
  } catch (e) {
175
175
  console.error(e);
@@ -350,6 +350,7 @@ const is_matched = (
350
350
  "category",
351
351
  "measureunit_family",
352
352
  "sv_measureUnit",
353
+ "brand",
353
354
  ];
354
355
  const integration_meta_keys = [
355
356
  "id",