repzo-sap-absjo 1.0.2 → 1.0.4

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 (65) hide show
  1. package/changelog.md +2 -0
  2. package/lib/actions/create_invoice.d.ts +5 -7
  3. package/lib/actions/create_invoice.js +5 -0
  4. package/lib/actions/create_payment.js +5 -0
  5. package/lib/actions/create_proforma.js +5 -0
  6. package/lib/actions/create_return_invoice.js +5 -0
  7. package/lib/actions/create_transfer.js +39 -18
  8. package/lib/commands/adjust_inventory.js +8 -8
  9. package/lib/commands/bank.js +24 -35
  10. package/lib/commands/basic.js +1 -2
  11. package/lib/commands/category.js +11 -18
  12. package/lib/commands/channel.js +11 -18
  13. package/lib/commands/client.js +31 -20
  14. package/lib/commands/client_disabled.js +8 -15
  15. package/lib/commands/join.js +101 -45
  16. package/lib/commands/measureunit.d.ts +3 -5
  17. package/lib/commands/measureunit.js +25 -39
  18. package/lib/commands/measureunit_family.js +15 -18
  19. package/lib/commands/payment_term.js +11 -18
  20. package/lib/commands/price_list.js +48 -72
  21. package/lib/commands/product.js +8 -19
  22. package/lib/commands/product_disabled.js +8 -15
  23. package/lib/commands/rep.js +7 -18
  24. package/lib/commands/tag.js +7 -18
  25. package/lib/commands/tax.js +7 -18
  26. package/lib/commands/warehouse.js +3 -7
  27. package/lib/test/actions/create_invoice.js +1 -0
  28. package/lib/test/actions/create_payment.js +1 -0
  29. package/lib/test/actions/create_proforma.js +1 -0
  30. package/lib/test/actions/create_return_invoice.js +1 -0
  31. package/lib/test/actions/create_transfer.js +1 -0
  32. package/lib/types.d.ts +36 -10
  33. package/lib/util.d.ts +22 -10
  34. package/lib/util.js +30 -0
  35. package/package.json +2 -2
  36. package/src/actions/create_invoice.ts +1 -0
  37. package/src/actions/create_payment.ts +1 -0
  38. package/src/actions/create_proforma.ts +1 -0
  39. package/src/actions/create_return_invoice.ts +1 -0
  40. package/src/actions/create_transfer.ts +23 -7
  41. package/src/commands/adjust_inventory.ts +8 -8
  42. package/src/commands/bank.ts +3 -3
  43. package/src/commands/basic.ts +3 -4
  44. package/src/commands/category.ts +7 -7
  45. package/src/commands/channel.ts +7 -7
  46. package/src/commands/client.ts +10 -4
  47. package/src/commands/client_disabled.ts +4 -4
  48. package/src/commands/join.ts +11 -6
  49. package/src/commands/measureunit.ts +12 -12
  50. package/src/commands/measureunit_family.ts +11 -11
  51. package/src/commands/payment_term.ts +7 -7
  52. package/src/commands/price_list.ts +18 -18
  53. package/src/commands/product.ts +4 -4
  54. package/src/commands/product_disabled.ts +4 -4
  55. package/src/commands/rep.ts +3 -3
  56. package/src/commands/tag.ts +3 -3
  57. package/src/commands/tax.ts +3 -3
  58. package/src/commands/warehouse.ts +3 -3
  59. package/src/test/actions/create_invoice.ts +1 -0
  60. package/src/test/actions/create_payment.ts +1 -0
  61. package/src/test/actions/create_proforma.ts +1 -0
  62. package/src/test/actions/create_return_invoice.ts +1 -0
  63. package/src/test/actions/create_transfer.ts +1 -0
  64. package/src/types.ts +31 -3
  65. package/src/util.ts +38 -0
package/lib/types.d.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import jwt from "jsonwebtoken";
2
2
  import { Service } from "repzo/src/types";
3
3
  export interface Config {
4
+ app_id: string;
4
5
  data?: any;
5
6
  repzoEndPoint: string;
6
7
  serviceEndPoint: string;
7
8
  env: "staging" | "local" | "production";
8
9
  }
9
- declare type DecodedScope = "admin" | "client" | "rep";
10
- declare type StringId = string;
11
- declare type Email = string;
12
- declare type NameSpaces = string[];
13
- export declare type Decoded = jwt.JwtPayload & {
10
+ type DecodedScope = "admin" | "client" | "rep";
11
+ type StringId = string;
12
+ type Email = string;
13
+ type NameSpaces = string[];
14
+ export type Decoded = jwt.JwtPayload & {
14
15
  id?: StringId;
15
16
  email?: Email;
16
17
  name?: string;
@@ -24,16 +25,41 @@ interface Params {
24
25
  nameSpace: NameSpaces;
25
26
  decoded: Decoded;
26
27
  }
27
- export declare type EVENT = AWSLambda.APIGatewayEvent & {
28
+ export type EVENT = AWSLambda.APIGatewayEvent & {
28
29
  params: Params;
29
30
  };
30
31
  export interface Action {
31
32
  name: string;
32
- action: string;
33
+ action: ActionType | string;
33
34
  description: string;
34
35
  }
36
+ export type ActionType =
37
+ | "create_invoice"
38
+ | "create_return_invoice"
39
+ | "create_proforma"
40
+ | "create_payment"
41
+ | "create_transfer";
42
+ export type CommandType =
43
+ | "join"
44
+ | "basic"
45
+ | "warehouse"
46
+ | "rep"
47
+ | "tax"
48
+ | "tag"
49
+ | "measureunit"
50
+ | "measureunit_family"
51
+ | "category"
52
+ | "channel"
53
+ | "payment_term"
54
+ | "bank"
55
+ | "product"
56
+ | "disabled_product"
57
+ | "price_list"
58
+ | "client"
59
+ | "disabled_client"
60
+ | "adjust_inventory";
35
61
  export interface Command {
36
- command: string;
62
+ command: CommandType | string;
37
63
  description: string;
38
64
  name: string;
39
65
  }
@@ -52,7 +78,7 @@ export interface AvailableApp {
52
78
  }
53
79
  export interface CommandEvent {
54
80
  app: Service.App.Schema_with_populated_AvailableApp;
55
- command: string;
81
+ command: CommandType | string;
56
82
  nameSpace: NameSpaces;
57
83
  meta?: any;
58
84
  sync_id?: string;
@@ -68,7 +94,7 @@ export interface Result {
68
94
  updated: number;
69
95
  failed: number;
70
96
  }
71
- export declare type FailedDocsReport = {
97
+ export type FailedDocsReport = {
72
98
  method: "create" | "update" | "delete" | "fetchingData";
73
99
  doc_id?: string;
74
100
  doc?: any;
package/lib/util.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import Repzo from "repzo";
2
+ import { CommandType } from "./types";
2
3
  interface Params {
3
4
  [key: string]: any;
4
5
  }
@@ -12,35 +13,35 @@ interface Headers {
12
13
  export declare const _fetch: (
13
14
  baseUrl: string,
14
15
  path: string,
15
- headers?: Headers | undefined,
16
- params?: Params | undefined
16
+ headers?: Headers,
17
+ params?: Params
17
18
  ) => Promise<any>;
18
19
  export declare const _create: (
19
20
  baseUrl: string,
20
21
  path: string,
21
22
  body: Data,
22
- headers?: Headers | undefined,
23
- params?: Params | undefined
23
+ headers?: Headers,
24
+ params?: Params
24
25
  ) => Promise<any>;
25
26
  export declare const _update: (
26
27
  baseUrl: string,
27
28
  path: string,
28
29
  body: Data,
29
- headers?: Headers | undefined,
30
- params?: Params | undefined
30
+ headers?: Headers,
31
+ params?: Params
31
32
  ) => Promise<any>;
32
33
  export declare const _delete: (
33
34
  baseUrl: string,
34
35
  path: string,
35
- headers?: Headers | undefined,
36
- params?: Params | undefined
36
+ headers?: Headers,
37
+ params?: Params
37
38
  ) => Promise<any>;
38
39
  export declare const update_bench_time: (
39
40
  repzo: Repzo,
40
41
  app_id: string,
41
42
  key: string,
42
43
  value: string,
43
- format?: string | undefined
44
+ format?: string
44
45
  ) => Promise<void>;
45
46
  export declare const updateAt_query: (
46
47
  QUERY: string,
@@ -52,7 +53,7 @@ export declare const get_data_from_sap: (
52
53
  default_res: any,
53
54
  serviceEndPoint: string,
54
55
  serviceApiKey: string,
55
- query?: string | undefined
56
+ query?: string
56
57
  ) => Promise<any>;
57
58
  export declare const set_error: (error_res: any) => any;
58
59
  export declare const date_formatting: (
@@ -67,4 +68,15 @@ export declare const get_data: (
67
68
  [key: string]: any;
68
69
  }
69
70
  ) => Promise<any[]>;
71
+ export declare const send_command_to_marketplace: ({
72
+ command,
73
+ app_id,
74
+ env,
75
+ repzoApiKey,
76
+ }: {
77
+ command: CommandType;
78
+ app_id: string;
79
+ env: "production" | "staging" | "local";
80
+ repzoApiKey: string;
81
+ }) => Promise<void>;
70
82
  export {};
package/lib/util.js CHANGED
@@ -162,3 +162,33 @@ export const get_data = async (service, key, query_array, extra_query = {}) => {
162
162
  throw e;
163
163
  }
164
164
  };
165
+ export const send_command_to_marketplace = async ({
166
+ command,
167
+ app_id,
168
+ env,
169
+ repzoApiKey,
170
+ }) => {
171
+ try {
172
+ const marketplace_url =
173
+ env === "production"
174
+ ? "https://marketplace.api.repzo.me"
175
+ : env === "staging"
176
+ ? "https://staging.marketplace.api.repzo.me"
177
+ : env === "local"
178
+ ? "https://staging.marketplace.api.repzo.me"
179
+ : "";
180
+ await _create(
181
+ marketplace_url,
182
+ "/commands",
183
+ {},
184
+ { "API-KEY": repzoApiKey },
185
+ {
186
+ app: "repzo-sap-absjo",
187
+ command: command,
188
+ app_id: app_id,
189
+ }
190
+ );
191
+ } catch (e) {
192
+ throw e;
193
+ }
194
+ };
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.2",
4
+ "version": "1.0.4",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -45,7 +45,7 @@
45
45
  "jsonwebtoken": "^8.5.1",
46
46
  "lodash": "^4.17.21",
47
47
  "moment-timezone": "^0.5.34",
48
- "repzo": "^1.0.21",
48
+ "repzo": "^1.0.22",
49
49
  "uuid": "^8.3.2"
50
50
  }
51
51
  }
@@ -64,6 +64,7 @@ export const create_invoice = async (event: EVENT, options: Config) => {
64
64
  const repzo_serial_number = body?.serial_number?.formatted;
65
65
 
66
66
  await actionLog
67
+ .addDetail(`Invoice - ${repzo_serial_number} => ${body?.sync_id}`)
67
68
  .addDetail(
68
69
  `Repzo => SAP: Started Create Invoice - ${repzo_serial_number}`
69
70
  )
@@ -39,6 +39,7 @@ export const create_payment = async (event: EVENT, options: Config) => {
39
39
  const repzo_serial_number = body?.serial_number?.formatted;
40
40
 
41
41
  await actionLog
42
+ .addDetail(`Payment - ${repzo_serial_number} => ${body?.sync_id}`)
42
43
  .addDetail(
43
44
  `Repzo => SAP: Started Create Payment - ${repzo_serial_number}`
44
45
  )
@@ -46,6 +46,7 @@ export const create_proforma = async (event: EVENT, options: Config) => {
46
46
  const repzo_serial_number = body?.serial_number?.formatted;
47
47
 
48
48
  await actionLog
49
+ .addDetail(`SalesOrder - ${repzo_serial_number} => ${body?.sync_id}`)
49
50
  .addDetail(
50
51
  `Repzo => SAP: Started Create SalesOrder - ${repzo_serial_number}`
51
52
  )
@@ -54,6 +54,7 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
54
54
  const repzo_serial_number = body?.serial_number?.formatted;
55
55
 
56
56
  await actionLog
57
+ .addDetail(`Return Invoice - ${repzo_serial_number} => ${body?.sync_id}`)
57
58
  .addDetail(
58
59
  `Repzo => SAP: Started Create Return Invoice - ${repzo_serial_number}`
59
60
  )
@@ -1,6 +1,13 @@
1
1
  import Repzo from "repzo";
2
2
  import { EVENT, Config } from "../types";
3
- import { _fetch, _create, _update, _delete, get_data } from "../util.js";
3
+ import {
4
+ _fetch,
5
+ _create,
6
+ _update,
7
+ _delete,
8
+ get_data,
9
+ send_command_to_marketplace,
10
+ } from "../util.js";
4
11
  import { Service } from "repzo/src/types";
5
12
  import { v4 as uuid } from "uuid";
6
13
  import moment from "moment-timezone";
@@ -37,6 +44,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
37
44
  const repzo_serial_number = body?.serial_number?.formatted;
38
45
 
39
46
  await actionLog
47
+ .addDetail(`Transfer - ${repzo_serial_number} => ${body?.sync_id}`)
40
48
  .addDetail(
41
49
  `Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`
42
50
  )
@@ -84,9 +92,9 @@ export const create_transfer = async (event: EVENT, options: Config) => {
84
92
  (p) => p._id.toString() == repzo_transfer_item.product_id?.toString()
85
93
  );
86
94
  if (!repzo_product) {
87
- console.log(
88
- `Product with _id: ${repzo_transfer_item.product_id} was not found In Repzo`
89
- );
95
+ // console.log(
96
+ // `Product with _id: ${repzo_transfer_item.product_id} was not found In Repzo`,
97
+ // );
90
98
  throw new Error(
91
99
  `Product with _id: ${repzo_transfer_item.product_id} was not found in Repzo`
92
100
  );
@@ -95,9 +103,9 @@ export const create_transfer = async (event: EVENT, options: Config) => {
95
103
  const repzo_measure_unit = repzo_product.sv_measureUnit;
96
104
 
97
105
  if (!repzo_measure_unit?._id) {
98
- console.log(
99
- `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`
100
- );
106
+ // console.log(
107
+ // `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
108
+ // );
101
109
  throw new Error(
102
110
  `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`
103
111
  );
@@ -155,6 +163,14 @@ export const create_transfer = async (event: EVENT, options: Config) => {
155
163
  //@ts-ignore
156
164
  console.error(e?.response || e);
157
165
  await actionLog.setStatus("fail", e).setBody(body).commit();
166
+ if (options?.data?.transfers?.adjustInventoryInFailedTransfer) {
167
+ send_command_to_marketplace({
168
+ command: "adjust_inventory",
169
+ app_id: options.app_id,
170
+ env: options.env,
171
+ repzoApiKey: options.data?.repzoApiKey,
172
+ });
173
+ }
158
174
  throw e;
159
175
  }
160
176
  };
@@ -37,7 +37,7 @@ export const adjust_inventory = async (commandEvent: CommandEvent) => {
37
37
  commandEvent.command
38
38
  );
39
39
  try {
40
- console.log("adjust_inventory");
40
+ // console.log("adjust_inventory");
41
41
 
42
42
  await commandLog.load(commandEvent.sync_id);
43
43
  await commandLog
@@ -140,9 +140,9 @@ export const adjust_inventory = async (commandEvent: CommandEvent) => {
140
140
  variant.integration_meta?.ITEMCODE == sap_item.ITEMID
141
141
  );
142
142
  if (!variant) {
143
- console.log(
144
- `Variant with ITEMCODE: ${sap_item.ITEMID} was not found`
145
- );
143
+ // console.log(
144
+ // `Variant with ITEMCODE: ${sap_item.ITEMID} was not found`
145
+ // );
146
146
  throw `Variant with ITEMCODE: ${sap_item.ITEMID} was not found`;
147
147
  }
148
148
 
@@ -154,9 +154,9 @@ export const adjust_inventory = async (commandEvent: CommandEvent) => {
154
154
  )?.sv_measureUnit?.toString()
155
155
  );
156
156
  if (!measureUnit) {
157
- console.log(
158
- `MeasureUnit with UNITNAME: ${sap_item.UNITNAME} & ALTUOMID: ${sap_item.UNITID} was not found`
159
- );
157
+ // console.log(
158
+ // `MeasureUnit with UNITNAME: ${sap_item.UNITNAME} & ALTUOMID: ${sap_item.UNITID} was not found`
159
+ // );
160
160
  throw `MeasureUnit with UNITNAME: ${sap_item.UNITNAME} & ALTUOMID: ${sap_item.UNITID} was not found`;
161
161
  }
162
162
 
@@ -179,7 +179,7 @@ export const adjust_inventory = async (commandEvent: CommandEvent) => {
179
179
 
180
180
  return { variant: variant._id, qty: diff_qty };
181
181
  } catch (e) {
182
- console.log(e);
182
+ // console.log(e);
183
183
  failed_docs_report.push({
184
184
  method: "fetchingData",
185
185
  doc_id: sap_item.UNITNAME,
@@ -35,7 +35,7 @@ export const sync_bank = async (commandEvent: CommandEvent) => {
35
35
  commandEvent.command
36
36
  );
37
37
  try {
38
- console.log("sync_bank");
38
+ // console.log("sync_bank");
39
39
 
40
40
  const new_bench_time = new Date().toISOString();
41
41
  const bench_time_key = "bench_time_bank";
@@ -124,7 +124,7 @@ export const sync_bank = async (commandEvent: CommandEvent) => {
124
124
  );
125
125
  result.created++;
126
126
  } catch (e: any) {
127
- console.log("Create Bank Failed >> ", e?.response, body);
127
+ // console.log("Create Bank Failed >> ", e?.response, body);
128
128
  failed_docs_report.push({
129
129
  method: "create",
130
130
  doc: body,
@@ -149,7 +149,7 @@ export const sync_bank = async (commandEvent: CommandEvent) => {
149
149
  );
150
150
  result.updated++;
151
151
  } catch (e: any) {
152
- console.log("Update Bank Failed >> ", e?.response?.data, body);
152
+ // console.log("Update Bank Failed >> ", e?.response?.data, body);
153
153
  failed_docs_report.push({
154
154
  method: "update",
155
155
  doc_id: repzo_bank?._id,
@@ -1,5 +1,5 @@
1
1
  import Repzo from "repzo";
2
- import { EVENT, Config, CommandEvent } from "../types";
2
+ import { EVENT, Config, CommandEvent, CommandType } from "../types";
3
3
  import { _fetch, _create, _update, _delete } from "../util.js";
4
4
 
5
5
  import { commands, commandsList } from "./index.js";
@@ -14,13 +14,12 @@ export const basic = async (commandEvent: CommandEvent) => {
14
14
  commandEvent.command
15
15
  );
16
16
  try {
17
- console.log("basic sync");
17
+ // console.log("basic sync");
18
18
 
19
19
  await commandLog.load(commandEvent.sync_id);
20
20
  await commandLog.addDetail("Repzo SAP: Basic Sync").commit();
21
21
 
22
- const required_syncing_commands: string[] = [
23
- "join",
22
+ const required_syncing_commands: CommandType[] = [
24
23
  "warehouse",
25
24
  "rep",
26
25
  "tax",
@@ -34,7 +34,7 @@ export const sync_category = async (commandEvent: CommandEvent) => {
34
34
  commandEvent.command
35
35
  );
36
36
  try {
37
- console.log("sync_category");
37
+ // console.log("sync_category");
38
38
 
39
39
  const new_bench_time = new Date().toISOString();
40
40
  const bench_time_key = "bench_time_category";
@@ -95,7 +95,7 @@ export const sync_category = async (commandEvent: CommandEvent) => {
95
95
  );
96
96
  result.created++;
97
97
  } catch (e: any) {
98
- console.log("Create Product Category Failed >> ", e?.response, body);
98
+ // console.log("Create Product Category Failed >> ", e?.response, body);
99
99
  failed_docs_report.push({
100
100
  method: "create",
101
101
  doc: body,
@@ -119,11 +119,11 @@ export const sync_category = async (commandEvent: CommandEvent) => {
119
119
  );
120
120
  result.updated++;
121
121
  } catch (e: any) {
122
- console.log(
123
- "Update Product Category Failed >> ",
124
- e?.response?.data,
125
- body
126
- );
122
+ // console.log(
123
+ // "Update Product Category Failed >> ",
124
+ // e?.response?.data,
125
+ // body
126
+ // );
127
127
  failed_docs_report.push({
128
128
  method: "update",
129
129
  doc_id: repzo_category?._id,
@@ -60,7 +60,7 @@ export const sync_channel = async (commandEvent: CommandEvent) => {
60
60
  commandEvent.command
61
61
  );
62
62
  try {
63
- console.log("sync_channel");
63
+ // console.log("sync_channel");
64
64
 
65
65
  const new_bench_time = new Date().toISOString();
66
66
  const bench_time_key = "bench_time_channel";
@@ -135,7 +135,7 @@ export const sync_channel = async (commandEvent: CommandEvent) => {
135
135
  );
136
136
  result.created++;
137
137
  } catch (e: any) {
138
- console.log("Create Client Channel Failed >> ", e?.response, body);
138
+ // console.log("Create Client Channel Failed >> ", e?.response, body);
139
139
  failed_docs_report.push({
140
140
  method: "create",
141
141
  doc: body,
@@ -157,11 +157,11 @@ export const sync_channel = async (commandEvent: CommandEvent) => {
157
157
  );
158
158
  result.updated++;
159
159
  } catch (e: any) {
160
- console.log(
161
- "Update Client Channel Failed >> ",
162
- e?.response?.data,
163
- body
164
- );
160
+ // console.log(
161
+ // "Update Client Channel Failed >> ",
162
+ // e?.response?.data,
163
+ // body
164
+ // );
165
165
  failed_docs_report.push({
166
166
  method: "update",
167
167
  doc_id: repzo_channel?._id,
@@ -59,7 +59,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
59
59
  commandEvent.command
60
60
  );
61
61
  try {
62
- console.log("sync_client");
62
+ // console.log("sync_client");
63
63
 
64
64
  const new_bench_time = new Date().toISOString();
65
65
  const bench_time_key = "bench_time_client";
@@ -231,7 +231,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
231
231
  );
232
232
  result.created++;
233
233
  } catch (e: any) {
234
- console.log("Create Client Failed >> ", e?.response, body);
234
+ // console.log("Create Client Failed >> ", e?.response, body);
235
235
  failed_docs_report.push({
236
236
  method: "create",
237
237
  doc: body,
@@ -253,7 +253,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
253
253
  );
254
254
  result.updated++;
255
255
  } catch (e: any) {
256
- console.log("Update Client Failed >> ", e?.response?.data, body);
256
+ // console.log("Update Client Failed >> ", e?.response?.data, body);
257
257
  failed_docs_report.push({
258
258
  method: "update",
259
259
  doc_id: repzo_client?._id,
@@ -329,7 +329,7 @@ const is_matched = (
329
329
  "formatted_address",
330
330
  "tags",
331
331
  "credit_limit",
332
- "financials",
332
+ // "financials",
333
333
  "channel",
334
334
  "paymentTerm",
335
335
  "sv_priceList",
@@ -361,6 +361,12 @@ const is_matched = (
361
361
  return false;
362
362
  }
363
363
  }
364
+ if (
365
+ body_1?.integration_meta?.["financials"]?.credit_limit !==
366
+ body_2?.integration_meta?.["financials"]?.credit_limit
367
+ ) {
368
+ return false;
369
+ }
364
370
  return true;
365
371
  } catch (e) {
366
372
  throw e;
@@ -25,7 +25,7 @@ export const sync_disabled_client = async (commandEvent: CommandEvent) => {
25
25
  commandEvent.command
26
26
  );
27
27
  try {
28
- console.log("sync_disabled_client");
28
+ // console.log("sync_disabled_client");
29
29
 
30
30
  const new_bench_time = new Date().toISOString();
31
31
  const bench_time_key = "bench_time_disabled_client";
@@ -98,9 +98,9 @@ export const sync_disabled_client = async (commandEvent: CommandEvent) => {
98
98
  const disabled_client = await repzo.client.remove(repzo_client._id);
99
99
  result.updated++;
100
100
  } catch (e: any) {
101
- console.log("Disable Client Failed >> ", e?.response?.data, {
102
- CLIENTID: sap_client.CLIENTID,
103
- });
101
+ // console.log("Disable Client Failed >> ", e?.response?.data, {
102
+ // CLIENTID: sap_client.CLIENTID,
103
+ // });
104
104
  failed_docs_report.push({
105
105
  method: "delete",
106
106
  doc_id: repzo_client?._id,
@@ -14,7 +14,7 @@ export const join = async (commandEvent: CommandEvent) => {
14
14
  commandEvent.command
15
15
  );
16
16
  try {
17
- console.log("join");
17
+ // console.log("join");
18
18
 
19
19
  await commandLog.load(commandEvent.sync_id);
20
20
  await commandLog.addDetail("Repzo SAP: Join").commit();
@@ -23,7 +23,8 @@ export const join = async (commandEvent: CommandEvent) => {
23
23
  data: [
24
24
  // invoice
25
25
  {
26
- app: "repzo-sap",
26
+ app: "repzo-sap-absjo",
27
+ app_id: commandEvent?.app?._id,
27
28
  action: "create_invoice",
28
29
  event: "invoiceItems.create",
29
30
  join:
@@ -31,7 +32,8 @@ export const join = async (commandEvent: CommandEvent) => {
31
32
  },
32
33
  // return_invoice
33
34
  {
34
- app: "repzo-sap",
35
+ app: "repzo-sap-absjo",
36
+ app_id: commandEvent?.app?._id,
35
37
  action: "create_return_invoice",
36
38
  event: "returnItems.create",
37
39
  join:
@@ -40,7 +42,8 @@ export const join = async (commandEvent: CommandEvent) => {
40
42
  },
41
43
  // payment
42
44
  {
43
- app: "repzo-sap",
45
+ app: "repzo-sap-absjo",
46
+ app_id: commandEvent?.app?._id,
44
47
  action: "create_payment",
45
48
  event: "payment.create",
46
49
  join:
@@ -48,7 +51,8 @@ export const join = async (commandEvent: CommandEvent) => {
48
51
  },
49
52
  // proforma
50
53
  {
51
- app: "repzo-sap",
54
+ app: "repzo-sap-absjo",
55
+ app_id: commandEvent?.app?._id,
52
56
  action: "create_proforma",
53
57
  event: "salesorder.approve",
54
58
  join:
@@ -57,7 +61,8 @@ export const join = async (commandEvent: CommandEvent) => {
57
61
  },
58
62
  // transfer
59
63
  {
60
- app: "repzo-sap",
64
+ app: "repzo-sap-absjo",
65
+ app_id: commandEvent?.app?._id,
61
66
  action: "create_transfer",
62
67
  event: "transfer.approve",
63
68
  join:
@@ -42,7 +42,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
42
42
  commandEvent.command
43
43
  );
44
44
  try {
45
- console.log("sync_measureunit");
45
+ // console.log("sync_measureunit");
46
46
 
47
47
  const new_bench_time = new Date().toISOString();
48
48
  const bench_time_key = "bench_time_measureunit";
@@ -118,11 +118,11 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
118
118
  (u) => u.ALTUOMCODE == "PC"
119
119
  );
120
120
  if (!max_unit.default_unit) {
121
- console.log(
122
- "Create/Update Measure Unit Failed >> ",
123
- `${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit`,
124
- units
125
- );
121
+ // console.log(
122
+ // "Create/Update Measure Unit Failed >> ",
123
+ // `${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit`,
124
+ // units
125
+ // );
126
126
  failed_docs_report.push({
127
127
  method: "create",
128
128
  doc_id:
@@ -196,7 +196,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
196
196
  );
197
197
  result.created++;
198
198
  } catch (e: any) {
199
- console.log("Create Measure Unit Failed >> ", e?.response, body);
199
+ // console.log("Create Measure Unit Failed >> ", e?.response, body);
200
200
  failed_docs_report.push({
201
201
  method: "create",
202
202
  doc: body,
@@ -220,11 +220,11 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
220
220
  );
221
221
  result.updated++;
222
222
  } catch (e: any) {
223
- console.log(
224
- "Update Measure Unit Failed >> ",
225
- e?.response?.data,
226
- body
227
- );
223
+ // console.log(
224
+ // "Update Measure Unit Failed >> ",
225
+ // e?.response?.data,
226
+ // body
227
+ // );
228
228
  failed_docs_report.push({
229
229
  method: "update",
230
230
  doc_id: repzo_UoM?._id,