repzo-sap-absjo 1.0.3 → 1.0.5

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.
@@ -6,7 +6,7 @@ import {
6
6
  set_error,
7
7
  } from "../util.js";
8
8
  export const sync_disabled_client = async (commandEvent) => {
9
- var _a, _b, _c;
9
+ var _a, _b, _c, _d;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -61,30 +61,24 @@ export const sync_disabled_client = async (commandEvent) => {
61
61
  : sap_disabled_clients.map(
62
62
  (client) => `${nameSpace}_${client.CLIENTID}`
63
63
  );
64
- const repzo_disabled_clients = [];
65
- const per_page = 200;
66
- const pages = Math.ceil(sap_client_query.length / per_page);
67
- for (let i = 0; i < pages; i += per_page) {
68
- const repzo_clients_per_page = await repzo.client.find({
69
- disabled: false,
70
- project: ["_id", "integration_meta"],
71
- per_page: 50000,
72
- "integration_meta.id": sap_client_query.slice(i, i + per_page),
73
- });
74
- if (
75
- (_b =
76
- repzo_clients_per_page === null || repzo_clients_per_page === void 0
77
- ? void 0
78
- : repzo_clients_per_page.data) === null || _b === void 0
79
- ? void 0
80
- : _b.length
81
- )
82
- repzo_disabled_clients.push(...repzo_clients_per_page.data);
83
- }
64
+ const repzo_disabled_clients = await repzo.patchAction.create(
65
+ {
66
+ slug: "client",
67
+ readQuery: [
68
+ { key: "disabled", value: [false], operator: "eq" },
69
+ {
70
+ key: "integration_meta.id",
71
+ value: sap_client_query,
72
+ operator: "in",
73
+ },
74
+ ],
75
+ },
76
+ { per_page: 50000, project: ["_id", "integration_meta"] }
77
+ );
84
78
  result.repzo_total =
85
- repzo_disabled_clients === null || repzo_disabled_clients === void 0
79
+ (_b = repzo_disabled_clients.data) === null || _b === void 0
86
80
  ? void 0
87
- : repzo_disabled_clients.length;
81
+ : _b.length;
88
82
  await commandLog
89
83
  .addDetail(`${result.repzo_total} Matched Active Clients in Repzo`)
90
84
  .commit();
@@ -98,9 +92,9 @@ export const sync_disabled_client = async (commandEvent) => {
98
92
  ) {
99
93
  const sap_client = sap_disabled_clients[i];
100
94
  const repzo_client =
101
- repzo_disabled_clients === null || repzo_disabled_clients === void 0
95
+ (_c = repzo_disabled_clients.data) === null || _c === void 0
102
96
  ? void 0
103
- : repzo_disabled_clients.find((r_client) => {
97
+ : _c.find((r_client) => {
104
98
  var _a;
105
99
  return (
106
100
  ((_a = r_client.integration_meta) === null || _a === void 0
@@ -148,10 +142,10 @@ export const sync_disabled_client = async (commandEvent) => {
148
142
  } catch (e) {
149
143
  //@ts-ignore
150
144
  console.error(
151
- ((_c = e === null || e === void 0 ? void 0 : e.response) === null ||
152
- _c === void 0
145
+ ((_d = e === null || e === void 0 ? void 0 : e.response) === null ||
146
+ _d === void 0
153
147
  ? void 0
154
- : _c.data) || e
148
+ : _d.data) || e
155
149
  );
156
150
  await commandLog.setStatus("fail", e).commit();
157
151
  throw e;
@@ -175,6 +175,13 @@ export const join = async (commandEvent) => {
175
175
  };
176
176
  const result = await repzo.joinActionsWebHook.update(null, body);
177
177
  // console.log(result);
178
+ if (
179
+ (result === null || result === void 0 ? void 0 : result.status) ==
180
+ "failure"
181
+ ) {
182
+ await commandLog.setStatus("fail", result.error).setBody(result).commit();
183
+ return;
184
+ }
178
185
  await commandLog.setStatus("success").setBody(result).commit();
179
186
  } catch (e) {
180
187
  //@ts-ignore
@@ -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_rep = async (commandEvent) => {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
6
  const repzo = new Repzo(
7
7
  (_a = commandEvent.app.formData) === null || _a === void 0
8
8
  ? void 0
@@ -43,21 +43,17 @@ export const sync_rep = async (commandEvent) => {
43
43
  : _b.length;
44
44
  await commandLog.addDetail(`${result.sap_total} reps in SAP`).commit();
45
45
  // hard code ************************************
46
- (_c =
47
- sap_reps === null || sap_reps === void 0 ? void 0 : sap_reps.Users) ===
48
- null || _c === void 0
49
- ? void 0
50
- : _c.forEach((sap_rep) => {
51
- if (
52
- sap_rep.USERDESC.startsWith("WS ") ||
53
- sap_rep.USERDESC.startsWith("RET ")
54
- ) {
55
- sap_rep.USERWHSCODE = "1";
56
- }
57
- if (sap_rep.USERDESC.startsWith("MT ")) {
58
- sap_rep.USERWHSCODE = "K.A";
59
- }
60
- });
46
+ // sap_reps?.Users?.forEach((sap_rep) => {
47
+ // if (
48
+ // sap_rep.USERDESC.startsWith("WS ") ||
49
+ // sap_rep.USERDESC.startsWith("RET ")
50
+ // ) {
51
+ // sap_rep.USERWHSCODE = "1";
52
+ // }
53
+ // if (sap_rep.USERDESC.startsWith("MT ")) {
54
+ // sap_rep.USERWHSCODE = "K.A";
55
+ // }
56
+ // });
61
57
  // **********************************************
62
58
  const db = new DataSet([], { autoIndex: false });
63
59
  db.createIndex({
@@ -71,32 +67,32 @@ export const sync_rep = async (commandEvent) => {
71
67
  db.load(sap_reps === null || sap_reps === void 0 ? void 0 : sap_reps.Users);
72
68
  const repzo_reps = await repzo.rep.find({ per_page: 50000 });
73
69
  result.repzo_total =
74
- (_d =
70
+ (_c =
75
71
  repzo_reps === null || repzo_reps === void 0
76
72
  ? void 0
77
- : repzo_reps.data) === null || _d === void 0
73
+ : repzo_reps.data) === null || _c === void 0
78
74
  ? void 0
79
- : _d.length;
75
+ : _c.length;
80
76
  await commandLog
81
77
  .addDetail(
82
78
  `${
83
- (_e =
79
+ (_d =
84
80
  repzo_reps === null || repzo_reps === void 0
85
81
  ? void 0
86
- : repzo_reps.data) === null || _e === void 0
82
+ : repzo_reps.data) === null || _d === void 0
87
83
  ? void 0
88
- : _e.length
84
+ : _d.length
89
85
  } reps in Repzo`
90
86
  )
91
87
  .commit();
92
88
  for (
93
89
  let i = 0;
94
90
  i <
95
- ((_f =
91
+ ((_e =
96
92
  sap_reps === null || sap_reps === void 0 ? void 0 : sap_reps.Users) ===
97
- null || _f === void 0
93
+ null || _e === void 0
98
94
  ? void 0
99
- : _f.length);
95
+ : _e.length);
100
96
  i++
101
97
  ) {
102
98
  const sap_rep = sap_reps.Users[i];
@@ -114,12 +110,12 @@ export const sync_rep = async (commandEvent) => {
114
110
  code: sap_rep.USERWHSCODE,
115
111
  });
116
112
  if (
117
- (_g =
113
+ (_f =
118
114
  warehouse_res === null || warehouse_res === void 0
119
115
  ? void 0
120
- : warehouse_res.data) === null || _g === void 0
116
+ : warehouse_res.data) === null || _f === void 0
121
117
  ? void 0
122
- : _g.length
118
+ : _f.length
123
119
  )
124
120
  warehouse = warehouse_res.data[0]._id;
125
121
  }
@@ -128,9 +124,9 @@ export const sync_rep = async (commandEvent) => {
128
124
  password: Math.round(Math.random() * (9999 - 1000) + 1000).toString(),
129
125
  username: nameSpace + sap_rep.USERID,
130
126
  integration_id:
131
- (_h = sap_rep.USERID) === null || _h === void 0
127
+ (_g = sap_rep.USERID) === null || _g === void 0
132
128
  ? void 0
133
- : _h.toString(),
129
+ : _g.toString(),
134
130
  integration_meta: {
135
131
  DEPARTMENTCODE: sap_rep.DEPARTMENTCODE,
136
132
  USERCASHACCOUNT: sap_rep.USERCASHACCOUNT,
@@ -160,21 +156,21 @@ export const sync_rep = async (commandEvent) => {
160
156
  USERID: repzo_rep.integration_id,
161
157
  USERDESC: repzo_rep.name,
162
158
  DEPARTMENTCODE:
163
- (_j = repzo_rep.integration_meta) === null || _j === void 0
159
+ (_h = repzo_rep.integration_meta) === null || _h === void 0
164
160
  ? void 0
165
- : _j.DEPARTMENTCODE,
161
+ : _h.DEPARTMENTCODE,
166
162
  USERCASHACCOUNT:
167
- (_k = repzo_rep.integration_meta) === null || _k === void 0
163
+ (_j = repzo_rep.integration_meta) === null || _j === void 0
168
164
  ? void 0
169
- : _k.USERCASHACCOUNT,
165
+ : _j.USERCASHACCOUNT,
170
166
  USERCHECKACCTCODE:
171
- (_l = repzo_rep.integration_meta) === null || _l === void 0
167
+ (_k = repzo_rep.integration_meta) === null || _k === void 0
172
168
  ? void 0
173
- : _l.USERCHECKACCTCODE,
169
+ : _k.USERCHECKACCTCODE,
174
170
  USERWHSCODE:
175
- (_m = repzo_rep.integration_meta) === null || _m === void 0
171
+ (_l = repzo_rep.integration_meta) === null || _l === void 0
176
172
  ? void 0
177
- : _m.USERWHSCODE,
173
+ : _l.USERWHSCODE,
178
174
  });
179
175
  if (found_identical_docs.length) continue;
180
176
  // Update
@@ -216,10 +212,10 @@ export const sync_rep = async (commandEvent) => {
216
212
  } catch (e) {
217
213
  //@ts-ignore
218
214
  console.error(
219
- ((_o = e === null || e === void 0 ? void 0 : e.response) === null ||
220
- _o === void 0
215
+ ((_m = e === null || e === void 0 ? void 0 : e.response) === null ||
216
+ _m === void 0
221
217
  ? void 0
222
- : _o.data) || e
218
+ : _m.data) || e
223
219
  );
224
220
  await commandLog.setStatus("fail", e).commit();
225
221
  throw e;
package/lib/types.d.ts CHANGED
@@ -30,7 +30,7 @@ export type EVENT = AWSLambda.APIGatewayEvent & {
30
30
  };
31
31
  export interface Action {
32
32
  name: string;
33
- action: ActionType;
33
+ action: ActionType | string;
34
34
  description: string;
35
35
  }
36
36
  export type ActionType =
@@ -59,7 +59,7 @@ export type CommandType =
59
59
  | "disabled_client"
60
60
  | "adjust_inventory";
61
61
  export interface Command {
62
- command: CommandType;
62
+ command: CommandType | string;
63
63
  description: string;
64
64
  name: string;
65
65
  }
@@ -78,7 +78,7 @@ export interface AvailableApp {
78
78
  }
79
79
  export interface CommandEvent {
80
80
  app: Service.App.Schema_with_populated_AvailableApp;
81
- command: CommandType;
81
+ command: CommandType | string;
82
82
  nameSpace: NameSpaces;
83
83
  meta?: any;
84
84
  sync_id?: string;
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.3",
4
+ "version": "1.0.5",
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.22",
48
+ "repzo": "^1.0.23",
49
49
  "uuid": "^8.3.2"
50
50
  }
51
51
  }
@@ -1,6 +1,6 @@
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 { _fetch, _create, _update, _delete } from "../util.js";
4
4
  import { Service } from "repzo/src/types";
5
5
  import { v4 as uuid } from "uuid";
6
6
  import moment from "moment-timezone";
@@ -156,20 +156,46 @@ export const create_invoice = async (event: EVENT, options: Config) => {
156
156
  }
157
157
  });
158
158
 
159
- const repzo_taxes = await get_data(
160
- repzo.tax,
161
- "_id",
162
- Object.keys(repzo_tax_ids)
159
+ const repzo_taxes = await repzo.patchAction.create(
160
+ {
161
+ slug: "tax",
162
+ readQuery: [
163
+ {
164
+ key: "_id",
165
+ value: Object.keys(repzo_tax_ids),
166
+ operator: "in",
167
+ },
168
+ ],
169
+ },
170
+ { per_page: 50000 }
163
171
  );
164
- const repzo_measureunits = await get_data(
165
- repzo.measureunit,
166
- "_id",
167
- Object.keys(repzo_measureunit_ids)
172
+
173
+ const repzo_measureunits = await repzo.patchAction.create(
174
+ {
175
+ slug: "measureunits",
176
+ readQuery: [
177
+ {
178
+ key: "_id",
179
+ value: Object.keys(repzo_measureunit_ids),
180
+ operator: "in",
181
+ },
182
+ ],
183
+ },
184
+ { per_page: 50000 }
168
185
  );
169
- const repzo_products = await get_data(
170
- repzo.product,
171
- "_id",
172
- Object.keys(repzo_product_ids)
186
+
187
+ const repzo_products = await repzo.patchAction.create(
188
+ {
189
+ slug: "product",
190
+ readQuery: [
191
+ {
192
+ key: "_id",
193
+ value: Object.keys(repzo_product_ids),
194
+ operator: "in",
195
+ },
196
+ ],
197
+ },
198
+ { per_page: 50000 }
173
199
  );
174
200
 
175
201
  // Prepare SAP_invoice_items
@@ -179,20 +205,20 @@ export const create_invoice = async (event: EVENT, options: Config) => {
179
205
  const item = repzo_invoice.items[i];
180
206
 
181
207
  // Get Repzo Tax
182
- const repzo_tax = repzo_taxes?.find(
208
+ const repzo_tax = repzo_taxes?.data?.find(
183
209
  (t) => t._id?.toString() == item.tax?._id?.toString()
184
210
  );
185
211
  if (!repzo_tax) throw `Tax with _id: ${item.tax._id} not found in Repzo`;
186
212
 
187
213
  // Get Repzo UoM
188
- const repzo_measureunit = repzo_measureunits?.find(
214
+ const repzo_measureunit = repzo_measureunits?.data?.find(
189
215
  (m) => m._id?.toString() == item.measureunit?._id?.toString()
190
216
  );
191
217
  if (!repzo_measureunit)
192
218
  throw `Uom with _id: ${item.measureunit?._id} not found in Repzo`;
193
219
 
194
220
  // Get Repzo Product
195
- const repzo_product = repzo_products?.find(
221
+ const repzo_product = repzo_products?.data?.find(
196
222
  (p) => p._id?.toString() == item.variant?.product_id?.toString()
197
223
  );
198
224
  if (!repzo_product)
@@ -1,6 +1,6 @@
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 { _fetch, _create, _update, _delete } from "../util.js";
4
4
  import { Service } from "repzo/src/types";
5
5
  import { v4 as uuid } from "uuid";
6
6
  import moment from "moment-timezone";
@@ -1,6 +1,6 @@
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 { _fetch, _create, _update, _delete } from "../util.js";
4
4
  import { Service } from "repzo/src/types";
5
5
  import { v4 as uuid } from "uuid";
6
6
  import moment from "moment-timezone";
@@ -83,20 +83,45 @@ export const create_proforma = async (event: EVENT, options: Config) => {
83
83
  }
84
84
  });
85
85
 
86
- const repzo_taxes = await get_data(
87
- repzo.tax,
88
- "_id",
89
- Object.keys(repzo_tax_ids)
86
+ const repzo_taxes = await repzo.patchAction.create(
87
+ {
88
+ slug: "tax",
89
+ readQuery: [
90
+ {
91
+ key: "_id",
92
+ value: Object.keys(repzo_tax_ids),
93
+ operator: "in",
94
+ },
95
+ ],
96
+ },
97
+ { per_page: 50000 }
90
98
  );
91
- const repzo_measureunits = await get_data(
92
- repzo.measureunit,
93
- "_id",
94
- Object.keys(repzo_measureunit_ids)
99
+ const repzo_measureunits = await repzo.patchAction.create(
100
+ {
101
+ slug: "measureunits",
102
+ readQuery: [
103
+ {
104
+ key: "_id",
105
+ value: Object.keys(repzo_measureunit_ids),
106
+ operator: "in",
107
+ },
108
+ ],
109
+ },
110
+ { per_page: 50000 }
95
111
  );
96
- const repzo_products = await get_data(
97
- repzo.product,
98
- "_id",
99
- Object.keys(repzo_product_ids)
112
+
113
+ const repzo_products = await repzo.patchAction.create(
114
+ {
115
+ slug: "product",
116
+ readQuery: [
117
+ {
118
+ key: "_id",
119
+ value: Object.keys(repzo_product_ids),
120
+ operator: "in",
121
+ },
122
+ ],
123
+ },
124
+ { per_page: 50000 }
100
125
  );
101
126
 
102
127
  // Prepare SAP_invoice_items
@@ -106,20 +131,20 @@ export const create_proforma = async (event: EVENT, options: Config) => {
106
131
  const item = repzo_proforma.items[i];
107
132
 
108
133
  // Get Repzo Tax
109
- const repzo_tax = repzo_taxes?.find(
134
+ const repzo_tax = repzo_taxes?.data?.find(
110
135
  (t) => t._id?.toString() == item.tax?._id?.toString()
111
136
  );
112
137
  if (!repzo_tax) throw `Tax with _id: ${item.tax._id} not found in Repzo`;
113
138
 
114
139
  // Get Repzo UoM
115
- const repzo_measureunit = repzo_measureunits?.find(
140
+ const repzo_measureunit = repzo_measureunits?.data?.find(
116
141
  (m) => m._id?.toString() == item.measureunit?._id?.toString()
117
142
  );
118
143
  if (!repzo_measureunit)
119
144
  throw `Uom with _id: ${item.measureunit?._id} not found in Repzo`;
120
145
 
121
146
  // Get Repzo Product
122
- const repzo_product = repzo_products?.find(
147
+ const repzo_product = repzo_products?.data?.find(
123
148
  (p) => p._id?.toString() == item.variant?.product_id?.toString()
124
149
  );
125
150
  if (!repzo_product)
@@ -1,6 +1,6 @@
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 { _fetch, _create, _update, _delete } from "../util.js";
4
4
  import { Service } from "repzo/src/types";
5
5
  import { v4 as uuid } from "uuid";
6
6
  import moment from "moment-timezone";
@@ -105,20 +105,46 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
105
105
  }
106
106
  });
107
107
 
108
- const repzo_taxes = await get_data(
109
- repzo.tax,
110
- "_id",
111
- Object.keys(repzo_tax_ids)
108
+ const repzo_taxes = await repzo.patchAction.create(
109
+ {
110
+ slug: "tax",
111
+ readQuery: [
112
+ {
113
+ key: "_id",
114
+ value: Object.keys(repzo_tax_ids),
115
+ operator: "in",
116
+ },
117
+ ],
118
+ },
119
+ { per_page: 50000 }
112
120
  );
113
- const repzo_measureunits = await get_data(
114
- repzo.measureunit,
115
- "_id",
116
- Object.keys(repzo_measureunit_ids)
121
+
122
+ const repzo_measureunits = await repzo.patchAction.create(
123
+ {
124
+ slug: "measureunits",
125
+ readQuery: [
126
+ {
127
+ key: "_id",
128
+ value: Object.keys(repzo_measureunit_ids),
129
+ operator: "in",
130
+ },
131
+ ],
132
+ },
133
+ { per_page: 50000 }
117
134
  );
118
- const repzo_products = await get_data(
119
- repzo.product,
120
- "_id",
121
- Object.keys(repzo_product_ids)
135
+
136
+ const repzo_products = await repzo.patchAction.create(
137
+ {
138
+ slug: "product",
139
+ readQuery: [
140
+ {
141
+ key: "_id",
142
+ value: Object.keys(repzo_product_ids),
143
+ operator: "in",
144
+ },
145
+ ],
146
+ },
147
+ { per_page: 50000 }
122
148
  );
123
149
 
124
150
  // Prepare SAP_invoice_items
@@ -128,20 +154,20 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
128
154
  const item = repzo_invoice.return_items[i];
129
155
 
130
156
  // Get Repzo Tax
131
- const repzo_tax = repzo_taxes?.find(
157
+ const repzo_tax = repzo_taxes?.data?.find(
132
158
  (t) => t._id?.toString() == item.tax?._id?.toString()
133
159
  );
134
160
  if (!repzo_tax) throw `Tax with _id: ${item.tax._id} not found in Repzo`;
135
161
 
136
162
  // Get Repzo UoM
137
- const repzo_measureunit = repzo_measureunits?.find(
163
+ const repzo_measureunit = repzo_measureunits?.data?.find(
138
164
  (m) => m._id?.toString() == item.measureunit?._id?.toString()
139
165
  );
140
166
  if (!repzo_measureunit)
141
167
  throw `Uom with _id: ${item.measureunit?._id} not found in Repzo`;
142
168
 
143
169
  // Get Repzo Product
144
- const repzo_product = repzo_products?.find(
170
+ const repzo_product = repzo_products?.data?.find(
145
171
  (p) => p._id?.toString() == item.variant?.product_id?.toString()
146
172
  );
147
173
  if (!repzo_product)
@@ -5,7 +5,6 @@ import {
5
5
  _create,
6
6
  _update,
7
7
  _delete,
8
- get_data,
9
8
  send_command_to_marketplace,
10
9
  } from "../util.js";
11
10
  import { Service } from "repzo/src/types";
@@ -74,11 +73,18 @@ export const create_transfer = async (event: EVENT, options: Config) => {
74
73
  }
75
74
  }
76
75
  );
77
- const repzo_products = await get_data(
78
- repzo.product,
79
- "_id",
80
- Object.keys(repzo_product_ids),
81
- { populatedKeys: ["measureunit"] }
76
+ const repzo_products = await repzo.patchAction.create(
77
+ {
78
+ slug: "product",
79
+ readQuery: [
80
+ {
81
+ key: "_id",
82
+ value: Object.keys(repzo_product_ids),
83
+ operator: "in",
84
+ },
85
+ ],
86
+ },
87
+ { per_page: 50000, populatedKeys: ["measureunit"] }
82
88
  );
83
89
 
84
90
  // Prepare Transfer Items
@@ -87,7 +93,7 @@ export const create_transfer = async (event: EVENT, options: Config) => {
87
93
  for (let i = 0; i < repzo_transfer.variants?.length; i++) {
88
94
  const repzo_transfer_item = repzo_transfer.variants[i];
89
95
 
90
- const repzo_product = repzo_products.find(
96
+ const repzo_product = repzo_products?.data?.find(
91
97
  //@ts-ignore
92
98
  (p) => p._id.toString() == repzo_transfer_item.product_id?.toString()
93
99
  );
@@ -19,7 +19,7 @@ export interface SAPClient {
19
19
  CLIENTCOUNTRY?: string; // null;
20
20
  CLIENTCOUNTY?: string; // null;
21
21
  CLIENTGROUPCODE: number; // 123;
22
- CLIENTGROUP: string; // "Cash Van";
22
+ CLIENTGROUP: string; // "Cash Van" | "Retail" | "Wholesale" | "HORECA" | "K-Accounts" | "HORECA - Van" | "Sub D - Wholesale" | "Petrol Stations" | "Pharmacy" | "GENERAL" | "Est. - MCE" | "Est. - CCE" | "E-commerce" | "Sub D - Pharmacy" | "Near to expire" | "Coops" | "Legal action customers";
23
23
  PAYMENTTERM: number; // 0;
24
24
  CLIENTCONTACTPERSON?: string; // null;
25
25
  CLIENTPHONE1?: string; // null;
@@ -204,21 +204,19 @@ export const sync_client = async (commandEvent: CommandEvent) => {
204
204
  comment: sap_client.CLIENTNOTE,
205
205
  formatted_address: sap_client.CLIENTADDRESSID,
206
206
  tags: tag ? [tag._id] : [],
207
- credit_limit:
208
- sap_client.CLIENTGROUP == "Cash Van"
209
- ? 1000000000
210
- : credit_limit && Math.round(credit_limit * 1000),
207
+ credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
208
+ ? credit_limit && Math.round(credit_limit * 1000)
209
+ : 1000000000,
211
210
  financials: {
212
- credit_limit:
213
- sap_client.CLIENTGROUP == "Cash Van"
214
- ? 1000000000
215
- : credit_limit && Math.round(credit_limit * 1000),
211
+ credit_limit: sap_client.PAYMENTTERM // sap_client.CLIENTGROUP == "Cash Van"
212
+ ? credit_limit && Math.round(credit_limit * 1000)
213
+ : 1000000000,
216
214
  },
217
215
  channel: channel ? channel._id : undefined,
218
216
  paymentTerm: paymentTerm ? paymentTerm._id : undefined,
219
217
  sv_priceList: priceList ? priceList._id : undefined,
220
218
  disabled: sap_client.ACTIVE == "Y" ? false : true,
221
- payment_type: sap_client.CLIENTGROUP == "Cash Van" ? "cash" : "credit",
219
+ payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
222
220
  integrated_client_balance:
223
221
  client_credit_consumed && Math.round(client_credit_consumed * 1000),
224
222
  };