repzo-sap-absjo 1.0.21 → 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.
@@ -1,5 +1,5 @@
1
1
  import Repzo from "repzo";
2
- import { _create } from "../util.js";
2
+ import { _create, getUniqueConcatenatedValues } from "../util.js";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import moment from "moment-timezone";
5
5
  export const create_invoice = async (event, options) => {
@@ -288,14 +288,14 @@ export const create_invoice = async (event, options) => {
288
288
  Quantity: item.qty,
289
289
  TaxCode: repzo_tax.integration_meta.TaxCode,
290
290
  UnitPrice: (item.price * repzo_measureunit.factor) / 1000,
291
- DiscountPerc: "0",
291
+ DiscountPerc: "0", // ??
292
292
  //@ts-ignore
293
293
  LineTotal: item.total_before_tax / 1000,
294
294
  UomCode: repzo_measureunit.integration_meta.ALTUOMID,
295
295
  Brand:
296
296
  (_m = repzo_product.integration_meta) === null || _m === void 0
297
297
  ? void 0
298
- : _m.BRAND,
298
+ : _m.BRAND, // "B1", // ??
299
299
  Department:
300
300
  ((_o =
301
301
  repzo_rep === null || repzo_rep === void 0
@@ -369,12 +369,3 @@ export const get_invoice_from_sap = async (serviceEndPoint, query) => {
369
369
  throw e;
370
370
  }
371
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
- }
@@ -1,5 +1,5 @@
1
1
  import Repzo from "repzo";
2
- import { _create } from "../util.js";
2
+ import { _create, getUniqueConcatenatedValues } from "../util.js";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import moment from "moment-timezone";
5
5
  export const create_proforma = async (event, options) => {
@@ -222,6 +222,8 @@ export const create_proforma = async (event, options) => {
222
222
  if (!repzo_product)
223
223
  throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
224
224
  items.push({
225
+ MEO_Serial: getUniqueConcatenatedValues(item, "ref", " | "),
226
+ Promotion_Name: getUniqueConcatenatedValues(item, "name", " | "),
225
227
  ItemCode: item.variant.variant_name,
226
228
  Quantity: item.qty,
227
229
  TaxCode: repzo_tax.integration_meta.TaxCode,
@@ -252,7 +254,7 @@ export const create_proforma = async (event, options) => {
252
254
  ? repzo_rep.integration_id
253
255
  : (_q = options.data) === null || _q === void 0
254
256
  ? void 0
255
- : _q.SalPersCode,
257
+ : _q.SalPersCode, // "111",
256
258
  DocDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format(
257
259
  "YYYYMMDD"
258
260
  ),
@@ -253,7 +253,7 @@ export const create_return_invoice = async (event, options) => {
253
253
  Brand:
254
254
  (_o = repzo_product.integration_meta) === null || _o === void 0
255
255
  ? void 0
256
- : _o.BRAND,
256
+ : _o.BRAND, // "B1",
257
257
  Department:
258
258
  ((_p =
259
259
  repzo_rep === null || repzo_rep === void 0
@@ -263,7 +263,7 @@ export const create_return_invoice = async (event, options) => {
263
263
  : _p.DEPARTMENTCODE) ||
264
264
  ((_q = options.data) === null || _q === void 0
265
265
  ? void 0
266
- : _q.DepartmentCode),
266
+ : _q.DepartmentCode), // "D2"
267
267
  Return_Reason:
268
268
  item_return_reason === null || item_return_reason === void 0
269
269
  ? void 0
@@ -171,7 +171,7 @@ export const create_transfer = async (event, options) => {
171
171
  ? repzo_rep.integration_id
172
172
  : (_o = options.data) === null || _o === void 0
173
173
  ? void 0
174
- : _o.SalesPersonCode,
174
+ : _o.SalesPersonCode, // "111"
175
175
  FromWarehouse: body.from.code,
176
176
  ToWarehouse: body.to.code,
177
177
  RepzoStockTransferLines: variants,
@@ -231,7 +231,7 @@ export const sync_client = async (commandEvent) => {
231
231
  paymentTerm: paymentTerm ? paymentTerm._id : undefined,
232
232
  sv_priceList: priceList ? priceList._id : undefined,
233
233
  disabled: sap_client.ACTIVE == "Y" ? false : true,
234
- payment_type: sap_client.PAYMENTTERM ? "credit" : "cash",
234
+ payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
235
235
  integrated_client_balance:
236
236
  client_credit_consumed && Math.round(client_credit_consumed * 1000),
237
237
  };
@@ -197,7 +197,7 @@ export const sync_measureunit = async (commandEvent) => {
197
197
  const body = {
198
198
  parent: repzo_parent_id,
199
199
  name: sap_UoM.ALTUOMCODE,
200
- factor: sap_UoM.repzo_factor || 0,
200
+ factor: sap_UoM.repzo_factor || 0, // ??????
201
201
  disabled: false,
202
202
  integration_meta: {
203
203
  id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
@@ -299,7 +299,7 @@ export const sync_product = async (commandEvent) => {
299
299
  {
300
300
  disabled: false,
301
301
  name: sap_product.ITEMCODE,
302
- price: 0,
302
+ price: 0, // Math.round(sap_product.PRICE * 1000),
303
303
  integration_meta: {
304
304
  id: `${nameSpace}_${sap_product.ITEMCODE}`,
305
305
  ITEMCODE: sap_product.ITEMCODE,
@@ -96,7 +96,7 @@ export const sync_tax = async (commandEvent) => {
96
96
  const body = {
97
97
  name: sap_tax.TaxName,
98
98
  rate: Number(sap_tax.TaxRate / 100),
99
- type: "additive",
99
+ type: "additive", // hardcode
100
100
  disabled: sap_tax.Inactive === "N" ? false : true,
101
101
  integration_meta: {
102
102
  id: `${nameSpace}_${sap_tax.TaxCode}`,
@@ -6,7 +6,7 @@ Actions(
6
6
  rawPath: "/actions",
7
7
  rawQueryString: "app=repzo-sap-absjo&action=create_invoice",
8
8
  headers: {
9
- action_sync_id: "Actions-0000001",
9
+ action_sync_id: "Actions-0000001", // SYNC_ID
10
10
  accept: "*/*",
11
11
  "accept-encoding": "gzip, deflate",
12
12
  "content-length": "3658",
@@ -6,7 +6,7 @@ Actions(
6
6
  rawPath: "/actions",
7
7
  rawQueryString: "app=repzo-sap-absjo&action=create_payment",
8
8
  headers: {
9
- action_sync_id: "Actions-0000004",
9
+ action_sync_id: "Actions-0000004", // SYNC_ID
10
10
  accept: "*/*",
11
11
  "accept-encoding": "gzip, deflate",
12
12
  "content-length": "3658",
@@ -6,7 +6,7 @@ Actions(
6
6
  rawPath: "/actions",
7
7
  rawQueryString: "app=repzo-sap-absjo&action=create_proforma",
8
8
  headers: {
9
- action_sync_id: "Actions-0000003",
9
+ action_sync_id: "Actions-0000003", // SYNC_ID
10
10
  accept: "*/*",
11
11
  "accept-encoding": "gzip, deflate",
12
12
  "content-length": "3658",
@@ -6,7 +6,7 @@ Actions(
6
6
  rawPath: "/actions",
7
7
  rawQueryString: "app=repzo-sap-absjo&action=create_return_invoice",
8
8
  headers: {
9
- action_sync_id: "Actions-0000002",
9
+ action_sync_id: "Actions-0000002", // SYNC_ID
10
10
  accept: "*/*",
11
11
  "accept-encoding": "gzip, deflate",
12
12
  "content-length": "3658",
@@ -6,7 +6,7 @@ Actions(
6
6
  rawPath: "/actions",
7
7
  rawQueryString: "app=repzo-sap-absjo&action=create_transfer",
8
8
  headers: {
9
- action_sync_id: "Actions-0000005",
9
+ action_sync_id: "Actions-0000005", // SYNC_ID
10
10
  accept: "*/*",
11
11
  "accept-encoding": "gzip, deflate",
12
12
  "content-length": "3658",
@@ -87,7 +87,7 @@ let commandEvent = {
87
87
  __v: 0,
88
88
  },
89
89
  end_of_day: "04:00",
90
- nameSpace: ["unisap"],
90
+ nameSpace: ["unisap"], // demosv
91
91
  timezone: "Asia/Amman",
92
92
  meta: "",
93
93
  env: "staging",
@@ -87,7 +87,7 @@ let commandEvent = {
87
87
  __v: 0,
88
88
  },
89
89
  end_of_day: "04:00",
90
- nameSpace: ["unisap"],
90
+ nameSpace: ["unisap"], // demosv
91
91
  timezone: "Asia/Amman",
92
92
  meta: "",
93
93
  env: "staging",
@@ -87,7 +87,7 @@ let commandEvent = {
87
87
  __v: 0,
88
88
  },
89
89
  end_of_day: "04:00",
90
- nameSpace: ["unisap"],
90
+ nameSpace: ["unisap"], // demosv
91
91
  timezone: "Asia/Amman",
92
92
  meta: "",
93
93
  env: "staging",
@@ -87,7 +87,7 @@ let commandEvent = {
87
87
  __v: 0,
88
88
  },
89
89
  end_of_day: "04:00",
90
- nameSpace: ["unisap"],
90
+ nameSpace: ["unisap"], // demosv
91
91
  timezone: "Asia/Amman",
92
92
  meta: "",
93
93
  env: "staging",
@@ -341,7 +341,7 @@ let commandEvent = {
341
341
  timezone: "Asia/Amman",
342
342
  meta: "",
343
343
  env: "staging",
344
- sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767",
344
+ sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767", // should change
345
345
  command: "price_list",
346
346
  };
347
347
  Commands(commandEvent);
@@ -353,7 +353,7 @@ let commandEvent = {
353
353
  timezone: "Asia/Amman",
354
354
  meta: "",
355
355
  env: "staging",
356
- sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54",
356
+ sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54", // should change
357
357
  command: "price_list_disabled",
358
358
  };
359
359
  Commands(commandEvent);
@@ -87,7 +87,7 @@ let commandEvent = {
87
87
  __v: 0,
88
88
  },
89
89
  end_of_day: "04:00",
90
- nameSpace: ["unisap"],
90
+ nameSpace: ["unisap"], // demosv
91
91
  timezone: "Asia/Amman",
92
92
  meta: "",
93
93
  env: "staging",
package/lib/util.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Repzo from "repzo";
2
2
  import { CommandType } from "./types";
3
+ import { Service } from "repzo/src/types";
3
4
  interface Params {
4
5
  [key: string]: any;
5
6
  }
@@ -79,4 +80,9 @@ export declare const send_command_to_marketplace: ({
79
80
  env: "production" | "staging" | "local";
80
81
  repzoApiKey: string;
81
82
  }) => Promise<void>;
83
+ export declare const getUniqueConcatenatedValues: (
84
+ item: Service.Item.Schema,
85
+ key: "name" | "ref",
86
+ delimiter: string
87
+ ) => string;
82
88
  export {};
package/lib/util.js CHANGED
@@ -192,3 +192,12 @@ export const send_command_to_marketplace = async ({
192
192
  throw e;
193
193
  }
194
194
  };
195
+ export const getUniqueConcatenatedValues = function (item, key, delimiter) {
196
+ item.general_promotions = item.general_promotions || [];
197
+ item.used_promotions = item.used_promotions || [];
198
+ const allPromotions = [...item.general_promotions, ...item.used_promotions];
199
+ const uniqueValues = new Set(
200
+ allPromotions.map((promotion) => promotion[key]).filter((value) => value)
201
+ );
202
+ return [...uniqueValues].join(delimiter);
203
+ };
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.21",
4
+ "version": "1.0.22",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -1,6 +1,12 @@
1
1
  import Repzo from "repzo";
2
2
  import { EVENT, Config } from "../types";
3
- import { _fetch, _create, _update, _delete } from "../util.js";
3
+ import {
4
+ _fetch,
5
+ _create,
6
+ _update,
7
+ _delete,
8
+ getUniqueConcatenatedValues,
9
+ } from "../util.js";
4
10
  import { Service } from "repzo/src/types";
5
11
  import { v4 as uuid } from "uuid";
6
12
  import moment from "moment-timezone";
@@ -325,20 +331,3 @@ export const get_invoice_from_sap = async (
325
331
  throw e;
326
332
  }
327
333
  };
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: { name: string; ref?: string; [key: string]: any }[] = [
337
- ...item.general_promotions,
338
- ...item.used_promotions,
339
- ];
340
- const uniqueValues = new Set(
341
- allPromotions.map((promotion) => promotion[key]).filter((value) => value)
342
- );
343
- return [...uniqueValues].join(delimiter);
344
- }
@@ -1,11 +1,19 @@
1
1
  import Repzo from "repzo";
2
2
  import { EVENT, Config } from "../types";
3
- import { _fetch, _create, _update, _delete } from "../util.js";
3
+ import {
4
+ _fetch,
5
+ _create,
6
+ _update,
7
+ _delete,
8
+ getUniqueConcatenatedValues,
9
+ } from "../util.js";
4
10
  import { Service } from "repzo/src/types";
5
11
  import { v4 as uuid } from "uuid";
6
12
  import moment from "moment-timezone";
7
13
 
8
14
  interface SAPProformaItem {
15
+ MEO_Serial: string; // "INV-1021-4 | 010-LAG-PO0002";
16
+ Promotion_Name: string; // "INV-1021-4 | 010-LAG-PO0002";
9
17
  ItemCode: string; // "010-LAG-PO0002";
10
18
  Quantity: number; // 10;
11
19
  TaxCode: string; // "S16";
@@ -162,6 +170,8 @@ export const create_proforma = async (event: EVENT, options: Config) => {
162
170
  throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
163
171
 
164
172
  items.push({
173
+ MEO_Serial: getUniqueConcatenatedValues(item, "ref", " | "),
174
+ Promotion_Name: getUniqueConcatenatedValues(item, "name", " | "),
165
175
  ItemCode: item.variant.variant_name,
166
176
  Quantity: item.qty,
167
177
  TaxCode: repzo_tax.integration_meta.TaxCode,
@@ -11,7 +11,7 @@ export const basic = async (commandEvent: CommandEvent) => {
11
11
  const commandLog = new Repzo.CommandLog(
12
12
  repzo,
13
13
  commandEvent.app,
14
- commandEvent.command,
14
+ commandEvent.command
15
15
  );
16
16
  try {
17
17
  // console.log("basic sync");
@@ -35,7 +35,7 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
35
35
  const commandLog = new Repzo.CommandLog(
36
36
  repzo,
37
37
  commandEvent.app,
38
- commandEvent.command,
38
+ commandEvent.command
39
39
  );
40
40
 
41
41
  try {
@@ -66,7 +66,7 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
66
66
  result.repzo_PL_total = repzo_price_lists?.data?.length;
67
67
  await commandLog
68
68
  .addDetail(
69
- `${repzo_price_lists?.data?.length} Active Price Lists in Repzo`,
69
+ `${repzo_price_lists?.data?.length} Active Price Lists in Repzo`
70
70
  )
71
71
  .commit();
72
72
 
@@ -89,7 +89,7 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
89
89
  {
90
90
  updateAt: "20000101:000000",
91
91
  PLDID: sap_price_list_id,
92
- },
92
+ }
93
93
  );
94
94
 
95
95
  result.sap_PL_items_total += sap_price_list_items?.length || 0;
@@ -140,7 +140,7 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
140
140
  console.log(
141
141
  "Disable Price List Item Failed >> ",
142
142
  e?.response?.data,
143
- repzo_item,
143
+ repzo_item
144
144
  );
145
145
  failed_docs_report.push({
146
146
  method: "update",
@@ -159,12 +159,12 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
159
159
  repzo,
160
160
  commandEvent.app._id,
161
161
  bench_time_key,
162
- new_bench_time,
162
+ new_bench_time
163
163
  );
164
164
  await commandLog
165
165
  .setStatus(
166
166
  "success",
167
- failed_docs_report.length ? failed_docs_report : null,
167
+ failed_docs_report.length ? failed_docs_report : null
168
168
  )
169
169
  .setBody(result)
170
170
  .commit();
@@ -179,13 +179,13 @@ export const sync_price_list_disabled = async (commandEvent: CommandEvent) => {
179
179
 
180
180
  const get_sap_price_list = async (
181
181
  serviceEndPoint: string,
182
- query?: { updateAt?: string; PLDID?: string },
182
+ query?: { updateAt?: string; PLDID?: string }
183
183
  ): Promise<SAPPriceListItem[]> => {
184
184
  try {
185
185
  const sap_price_lists: SAPPriceListItems = await _create(
186
186
  serviceEndPoint,
187
187
  "/PriceList",
188
- { UpdateAt: query?.updateAt, PLDID: query?.PLDID },
188
+ { UpdateAt: query?.updateAt, PLDID: query?.PLDID }
189
189
  );
190
190
  return sap_price_lists.PriceList;
191
191
  } catch (e: any) {
package/src/util.ts CHANGED
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  import Repzo from "repzo";
3
3
  import moment from "moment-timezone";
4
4
  import { CommandType } from "./types";
5
-
5
+ import { Service } from "repzo/src/types";
6
6
  interface Params {
7
7
  [key: string]: any;
8
8
  }
@@ -241,3 +241,20 @@ export const send_command_to_marketplace = async ({
241
241
  throw e;
242
242
  }
243
243
  };
244
+
245
+ export const getUniqueConcatenatedValues = function (
246
+ item: Service.Item.Schema,
247
+ key: "name" | "ref",
248
+ delimiter: string
249
+ ): string {
250
+ item.general_promotions = item.general_promotions || [];
251
+ item.used_promotions = item.used_promotions || [];
252
+ const allPromotions: { name: string; ref?: string; [key: string]: any }[] = [
253
+ ...item.general_promotions,
254
+ ...item.used_promotions,
255
+ ];
256
+ const uniqueValues = new Set(
257
+ allPromotions.map((promotion) => promotion[key]).filter((value) => value)
258
+ );
259
+ return [...uniqueValues].join(delimiter);
260
+ };