repzo-sap-absjo 1.0.66 → 1.0.68

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_client = async (commandEvent) => {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
10
10
  const repzo = new Repzo(
11
11
  (_a = commandEvent.app.formData) === null || _a === void 0
12
12
  ? void 0
@@ -112,6 +112,55 @@ export const sync_client = async (commandEvent) => {
112
112
  } Clients in Repzo`
113
113
  )
114
114
  .commit();
115
+ // Get Enforce Credit for Client Group from formData and parse it to array if it's string
116
+ let enforce_credit_for_client_group;
117
+ try {
118
+ if (
119
+ (_f = commandEvent.app.formData) === null || _f === void 0
120
+ ? void 0
121
+ : _f.enforce_credit_for_client_group
122
+ ) {
123
+ if (
124
+ typeof commandEvent.app.formData.enforce_credit_for_client_group ===
125
+ "string"
126
+ ) {
127
+ enforce_credit_for_client_group = JSON.parse(
128
+ commandEvent.app.formData.enforce_credit_for_client_group
129
+ );
130
+ } else if (
131
+ Array.isArray(
132
+ commandEvent.app.formData.enforce_credit_for_client_group
133
+ )
134
+ ) {
135
+ enforce_credit_for_client_group =
136
+ commandEvent.app.formData.enforce_credit_for_client_group;
137
+ }
138
+ }
139
+ } catch (e) {
140
+ console.error(
141
+ "Failed to parse enforce_credit_for_client_group:",
142
+ (_g = commandEvent.app.formData) === null || _g === void 0
143
+ ? void 0
144
+ : _g.enforce_credit_for_client_group,
145
+ e
146
+ );
147
+ await commandLog
148
+ .addDetail(
149
+ `Failed to parse Enforce Credit for Client Group: ${
150
+ (_h = commandEvent.app.formData) === null || _h === void 0
151
+ ? void 0
152
+ : _h.enforce_credit_for_client_group
153
+ }`,
154
+ {
155
+ enforce_credit_for_client_group:
156
+ (_j = commandEvent.app.formData) === null || _j === void 0
157
+ ? void 0
158
+ : _j.enforce_credit_for_client_group,
159
+ error_message: set_error(e),
160
+ }
161
+ )
162
+ .commit();
163
+ }
115
164
  for (
116
165
  let i = 0;
117
166
  i <
@@ -130,12 +179,12 @@ export const sync_client = async (commandEvent) => {
130
179
  );
131
180
  });
132
181
  const tag =
133
- (_f =
182
+ (_k =
134
183
  repzo_tags === null || repzo_tags === void 0
135
184
  ? void 0
136
- : repzo_tags.data) === null || _f === void 0
185
+ : repzo_tags.data) === null || _k === void 0
137
186
  ? void 0
138
- : _f.find((tag) => {
187
+ : _k.find((tag) => {
139
188
  var _a;
140
189
  return (
141
190
  ((_a = tag.integration_meta) === null || _a === void 0
@@ -144,12 +193,12 @@ export const sync_client = async (commandEvent) => {
144
193
  );
145
194
  });
146
195
  const channel =
147
- (_g =
196
+ (_l =
148
197
  repzo_channels === null || repzo_channels === void 0
149
198
  ? void 0
150
- : repzo_channels.data) === null || _g === void 0
199
+ : repzo_channels.data) === null || _l === void 0
151
200
  ? void 0
152
- : _g.find((channel) => {
201
+ : _l.find((channel) => {
153
202
  var _a;
154
203
  return (
155
204
  ((_a = channel.integration_meta) === null || _a === void 0
@@ -158,12 +207,12 @@ export const sync_client = async (commandEvent) => {
158
207
  );
159
208
  });
160
209
  const paymentTerm =
161
- (_h =
210
+ (_m =
162
211
  repzo_payment_terms === null || repzo_payment_terms === void 0
163
212
  ? void 0
164
- : repzo_payment_terms.data) === null || _h === void 0
213
+ : repzo_payment_terms.data) === null || _m === void 0
165
214
  ? void 0
166
- : _h.find((paymentTerm) => {
215
+ : _m.find((paymentTerm) => {
167
216
  var _a;
168
217
  return (
169
218
  ((_a = paymentTerm.integration_meta) === null || _a === void 0
@@ -172,12 +221,12 @@ export const sync_client = async (commandEvent) => {
172
221
  );
173
222
  });
174
223
  const priceList =
175
- (_j =
224
+ (_o =
176
225
  repzo_price_lists === null || repzo_price_lists === void 0
177
226
  ? void 0
178
- : repzo_price_lists.data) === null || _j === void 0
227
+ : repzo_price_lists.data) === null || _o === void 0
179
228
  ? void 0
180
- : _j.find((pricelist) => {
229
+ : _o.find((pricelist) => {
181
230
  var _a;
182
231
  return (
183
232
  ((_a = pricelist.integration_meta) === null || _a === void 0
@@ -236,7 +285,16 @@ export const sync_client = async (commandEvent) => {
236
285
  paymentTerm: paymentTerm ? paymentTerm._id : undefined,
237
286
  sv_priceList: priceList ? priceList._id : undefined,
238
287
  disabled: sap_client.ACTIVE == "Y" ? false : true,
239
- payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
288
+ payment_type: (
289
+ enforce_credit_for_client_group === null ||
290
+ enforce_credit_for_client_group === void 0
291
+ ? void 0
292
+ : enforce_credit_for_client_group.includes(sap_client.CLIENTGROUP)
293
+ )
294
+ ? "credit"
295
+ : sap_client.PAYMENTTERM
296
+ ? "credit"
297
+ : "cash", // sap_client.CLIENTGROUP == "Cash Van"
240
298
  integrated_client_balance:
241
299
  client_credit_consumed && Math.round(client_credit_consumed * 1000),
242
300
  company_namespace: [nameSpace],
@@ -318,10 +376,10 @@ export const sync_client = async (commandEvent) => {
318
376
  } catch (e) {
319
377
  //@ts-ignore
320
378
  console.error(
321
- ((_k = e === null || e === void 0 ? void 0 : e.response) === null ||
322
- _k === void 0
379
+ ((_p = e === null || e === void 0 ? void 0 : e.response) === null ||
380
+ _p === void 0
323
381
  ? void 0
324
- : _k.data) || e
382
+ : _p.data) || e
325
383
  );
326
384
  await commandLog.setStatus("fail", e).commit();
327
385
  throw e;
@@ -17,7 +17,6 @@ export const sync_measureunit_disabled = async (commandEvent) => {
17
17
  commandEvent.command
18
18
  );
19
19
  try {
20
- // console.log("sync_measureunit_disabled");
21
20
  const new_bench_time = new Date().toISOString();
22
21
  const bench_time_key = "bench_time_measureunit_disabled";
23
22
  await commandLog.load(commandEvent.sync_id);
package/lib/types.d.ts CHANGED
@@ -93,6 +93,7 @@ export interface FormData {
93
93
  repzo_id: StringId;
94
94
  }[]
95
95
  | string;
96
+ enforce_credit_for_client_group?: string[] | string;
96
97
  defaultWarehouseForSalesOrder?: string;
97
98
  SalPersCode?: string;
98
99
  SalesPersonCode?: 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.66",
4
+ "version": "1.0.68",
5
5
  "homepage": "",
6
6
  "keywords": [],
7
7
  "author": {
@@ -135,6 +135,44 @@ export const sync_client = async (commandEvent: CommandEvent) => {
135
135
  .addDetail(`${repzo_clients?.data?.length} Clients in Repzo`)
136
136
  .commit();
137
137
 
138
+ // Get Enforce Credit for Client Group from formData and parse it to array if it's string
139
+ let enforce_credit_for_client_group: string[] | undefined;
140
+ try {
141
+ if (commandEvent.app.formData?.enforce_credit_for_client_group) {
142
+ if (
143
+ typeof commandEvent.app.formData.enforce_credit_for_client_group ===
144
+ "string"
145
+ ) {
146
+ enforce_credit_for_client_group = JSON.parse(
147
+ commandEvent.app.formData.enforce_credit_for_client_group
148
+ );
149
+ } else if (
150
+ Array.isArray(
151
+ commandEvent.app.formData.enforce_credit_for_client_group
152
+ )
153
+ ) {
154
+ enforce_credit_for_client_group =
155
+ commandEvent.app.formData.enforce_credit_for_client_group;
156
+ }
157
+ }
158
+ } catch (e) {
159
+ console.error(
160
+ "Failed to parse enforce_credit_for_client_group:",
161
+ commandEvent.app.formData?.enforce_credit_for_client_group,
162
+ e
163
+ );
164
+ await commandLog
165
+ .addDetail(
166
+ `Failed to parse Enforce Credit for Client Group: ${commandEvent.app.formData?.enforce_credit_for_client_group}`,
167
+ {
168
+ enforce_credit_for_client_group:
169
+ commandEvent.app.formData?.enforce_credit_for_client_group,
170
+ error_message: set_error(e),
171
+ }
172
+ )
173
+ .commit();
174
+ }
175
+
138
176
  for (let i = 0; i < sap_clients?.length; i++) {
139
177
  const sap_client: SAPClient = sap_clients[i];
140
178
  const repzo_client = repzo_clients.data.find(
@@ -216,7 +254,13 @@ export const sync_client = async (commandEvent: CommandEvent) => {
216
254
  paymentTerm: paymentTerm ? paymentTerm._id : undefined,
217
255
  sv_priceList: priceList ? priceList._id : undefined,
218
256
  disabled: sap_client.ACTIVE == "Y" ? false : true,
219
- payment_type: sap_client.PAYMENTTERM ? "credit" : "cash", // sap_client.CLIENTGROUP == "Cash Van"
257
+ payment_type: enforce_credit_for_client_group?.includes(
258
+ sap_client.CLIENTGROUP
259
+ )
260
+ ? "credit"
261
+ : sap_client.PAYMENTTERM
262
+ ? "credit"
263
+ : "cash", // sap_client.CLIENTGROUP == "Cash Van"
220
264
  integrated_client_balance:
221
265
  client_credit_consumed && Math.round(client_credit_consumed * 1000),
222
266
  company_namespace: [nameSpace],
@@ -14,8 +14,6 @@ export const sync_measureunit_disabled = async (commandEvent: CommandEvent) => {
14
14
  commandEvent.command
15
15
  );
16
16
  try {
17
- // console.log("sync_measureunit_disabled");
18
-
19
17
  const new_bench_time = new Date().toISOString();
20
18
  const bench_time_key = "bench_time_measureunit_disabled";
21
19
 
package/src/types.ts CHANGED
@@ -93,6 +93,7 @@ export interface FormData {
93
93
  repzo_id: StringId;
94
94
  }[]
95
95
  | string;
96
+ enforce_credit_for_client_group?: string[] | string;
96
97
  defaultWarehouseForSalesOrder?: string; // "1";
97
98
  SalPersCode?: string; // "111";
98
99
  SalesPersonCode?: string; // "111";