repzo-sap-absjo 1.0.8 → 1.0.9

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 (77) hide show
  1. package/lib/actions/create_invoice.d.ts +19 -13
  2. package/lib/actions/create_invoice.js +363 -214
  3. package/lib/actions/create_payment.d.ts +4 -1
  4. package/lib/actions/create_payment.js +200 -125
  5. package/lib/actions/create_proforma.d.ts +4 -1
  6. package/lib/actions/create_proforma.js +290 -165
  7. package/lib/actions/create_return_invoice.d.ts +4 -1
  8. package/lib/actions/create_return_invoice.js +321 -177
  9. package/lib/actions/create_transfer.d.ts +4 -1
  10. package/lib/actions/create_transfer.js +220 -143
  11. package/lib/actions/index.js +23 -15
  12. package/lib/commands/adjust_inventory.d.ts +4 -2
  13. package/lib/commands/adjust_inventory.js +290 -160
  14. package/lib/commands/bank.d.ts +4 -2
  15. package/lib/commands/bank.js +279 -157
  16. package/lib/commands/basic.js +66 -47
  17. package/lib/commands/category.d.ts +3 -1
  18. package/lib/commands/category.js +178 -104
  19. package/lib/commands/channel.d.ts +3 -1
  20. package/lib/commands/channel.js +198 -117
  21. package/lib/commands/client.d.ts +34 -32
  22. package/lib/commands/client.js +404 -244
  23. package/lib/commands/client_disabled.d.ts +3 -1
  24. package/lib/commands/client_disabled.js +163 -94
  25. package/lib/commands/index.d.ts +15 -11
  26. package/lib/commands/index.js +60 -60
  27. package/lib/commands/join.js +192 -66
  28. package/lib/commands/measureunit.d.ts +19 -14
  29. package/lib/commands/measureunit.js +289 -191
  30. package/lib/commands/measureunit_family.d.ts +10 -8
  31. package/lib/commands/measureunit_family.js +250 -138
  32. package/lib/commands/payment_term.d.ts +3 -1
  33. package/lib/commands/payment_term.js +202 -123
  34. package/lib/commands/price_list.d.ts +15 -15
  35. package/lib/commands/price_list.js +612 -326
  36. package/lib/commands/product.d.ts +32 -30
  37. package/lib/commands/product.js +425 -243
  38. package/lib/commands/product_disabled.d.ts +3 -1
  39. package/lib/commands/product_disabled.js +164 -94
  40. package/lib/commands/rep.js +221 -141
  41. package/lib/commands/tag.js +174 -109
  42. package/lib/commands/tax.js +177 -112
  43. package/lib/commands/warehouse.d.ts +3 -1
  44. package/lib/commands/warehouse.js +207 -119
  45. package/lib/index.d.ts +21 -12
  46. package/lib/test/actions/create_invoice.js +193 -188
  47. package/lib/test/actions/create_payment.js +112 -107
  48. package/lib/test/actions/create_proforma.js +220 -216
  49. package/lib/test/actions/create_return_invoice.js +205 -200
  50. package/lib/test/actions/create_transfer.js +120 -115
  51. package/lib/test/commands/adjust_inventory.js +90 -90
  52. package/lib/test/commands/bank.js +90 -90
  53. package/lib/test/commands/basic.js +328 -327
  54. package/lib/test/commands/category.js +90 -90
  55. package/lib/test/commands/channel.js +90 -90
  56. package/lib/test/commands/client.js +355 -353
  57. package/lib/test/commands/client_disabled.js +90 -90
  58. package/lib/test/commands/join.js +328 -327
  59. package/lib/test/commands/measureunit.js +90 -90
  60. package/lib/test/commands/measureunit_family.js +90 -90
  61. package/lib/test/commands/payment_term.js +90 -90
  62. package/lib/test/commands/price_list.js +337 -334
  63. package/lib/test/commands/product.js +90 -90
  64. package/lib/test/commands/product_disabled.js +90 -90
  65. package/lib/test/commands/rep.js +346 -344
  66. package/lib/test/commands/tag.js +90 -90
  67. package/lib/test/commands/tax.js +90 -90
  68. package/lib/test/commands/warehouse.js +90 -90
  69. package/lib/types.d.ts +83 -60
  70. package/lib/util.d.ts +70 -19
  71. package/lib/util.js +170 -144
  72. package/package.json +1 -1
  73. package/src/actions/create_invoice.ts +4 -13
  74. package/src/actions/create_payment.ts +4 -13
  75. package/src/actions/create_proforma.ts +28 -40
  76. package/src/actions/create_return_invoice.ts +4 -16
  77. package/src/actions/create_transfer.ts +24 -36
@@ -3,174 +3,299 @@ import { _create } 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) => {
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
7
- const repzo = new Repzo((_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey, { env: options.env });
8
- const action_sync_id = ((_b = event === null || event === void 0 ? void 0 : event.headers) === null || _b === void 0 ? void 0 : _b.action_sync_id) || uuid();
9
- const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
10
- let body;
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
7
+ const repzo = new Repzo(
8
+ (_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
9
+ { env: options.env }
10
+ );
11
+ const action_sync_id =
12
+ ((_b = event === null || event === void 0 ? void 0 : event.headers) ===
13
+ null || _b === void 0
14
+ ? void 0
15
+ : _b.action_sync_id) || uuid();
16
+ const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
17
+ let body;
18
+ try {
19
+ // console.log("create_proforma");
20
+ await actionLog.load(action_sync_id);
21
+ body = event.body;
11
22
  try {
12
- // console.log("create_proforma");
13
- await actionLog.load(action_sync_id);
14
- body = event.body;
15
- try {
16
- if (body)
17
- body = JSON.parse(body);
18
- }
19
- catch (e) { }
20
- const repzo_serial_number = (_c = body === null || body === void 0 ? void 0 : body.serial_number) === null || _c === void 0 ? void 0 : _c.formatted;
21
- try {
22
- if (body === null || body === void 0 ? void 0 : body._id) {
23
- body.integration_meta = (body === null || body === void 0 ? void 0 : body.integration_meta) || {};
24
- body.integration_meta.sync_to_sap_started = true;
25
- body.integration_meta.sync_to_sap_succeeded =
26
- body.integration_meta.sync_to_sap_succeeded || false;
27
- await repzo.proforma.update(body._id, {
28
- integration_meta: body.integration_meta,
29
- });
30
- }
31
- }
32
- catch (e) {
33
- console.error(e);
34
- await actionLog
35
- .addDetail(`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`)
36
- .commit();
37
- }
38
- await actionLog
39
- .addDetail(`SalesOrder - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
40
- .addDetail(`Repzo => SAP: Started Create SalesOrder - ${repzo_serial_number}`)
41
- .commit();
42
- const SAP_HOST_URL = (_d = options.data) === null || _d === void 0 ? void 0 : _d.sapHostUrl;
43
- if (!SAP_HOST_URL)
44
- throw `SAP Host Url is missing and Required: ${SAP_HOST_URL}`;
45
- const repzo_proforma = body;
46
- // Get Repzo Rep
47
- let repzo_rep;
48
- if (repzo_proforma.creator.type == "rep") {
49
- repzo_rep = await repzo.rep.get((_e = repzo_proforma === null || repzo_proforma === void 0 ? void 0 : repzo_proforma.creator) === null || _e === void 0 ? void 0 : _e._id);
50
- if (!repzo_rep)
51
- throw `Rep with _id: ${repzo_proforma.creator._id} not found in Repzo`;
52
- }
53
- // Get Repzo Client
54
- const repzo_client = await repzo.client.get(repzo_proforma === null || repzo_proforma === void 0 ? void 0 : repzo_proforma.client_id);
55
- if (!repzo_client)
56
- throw `Client with _id: ${repzo_proforma.client_id} not found in Repzo`;
57
- const repzo_tax_ids = {};
58
- const repzo_measureunit_ids = {};
59
- const repzo_product_ids = {};
60
- (_f = repzo_proforma.items) === null || _f === void 0 ? void 0 : _f.forEach((item) => {
61
- var _a, _b, _c;
62
- if (item) {
63
- repzo_tax_ids[(_a = item.tax) === null || _a === void 0 ? void 0 : _a._id] = true;
64
- repzo_measureunit_ids[(_b = item.measureunit) === null || _b === void 0 ? void 0 : _b._id] = true;
65
- repzo_product_ids[(_c = item.variant) === null || _c === void 0 ? void 0 : _c.product_id] = true;
66
- }
23
+ if (body) body = JSON.parse(body);
24
+ } catch (e) {}
25
+ const repzo_serial_number =
26
+ (_c = body === null || body === void 0 ? void 0 : body.serial_number) ===
27
+ null || _c === void 0
28
+ ? void 0
29
+ : _c.formatted;
30
+ // try {
31
+ // if (body?._id) {
32
+ // body.integration_meta = body?.integration_meta || {};
33
+ // body.integration_meta.sync_to_sap_started = true;
34
+ // body.integration_meta.sync_to_sap_succeeded =
35
+ // body.integration_meta.sync_to_sap_succeeded || false;
36
+ // await repzo.proforma.update(body._id, {
37
+ // integration_meta: body.integration_meta,
38
+ // });
39
+ // }
40
+ // } catch (e) {
41
+ // console.error(e);
42
+ // }
43
+ await actionLog
44
+ .addDetail(
45
+ `SalesOrder - ${repzo_serial_number} => ${
46
+ body === null || body === void 0 ? void 0 : body.sync_id
47
+ }`
48
+ )
49
+ .addDetail(
50
+ `Repzo => SAP: Started Create SalesOrder - ${repzo_serial_number}`
51
+ )
52
+ .commit();
53
+ const SAP_HOST_URL =
54
+ (_d = options.data) === null || _d === void 0 ? void 0 : _d.sapHostUrl;
55
+ if (!SAP_HOST_URL)
56
+ throw `SAP Host Url is missing and Required: ${SAP_HOST_URL}`;
57
+ const repzo_proforma = body;
58
+ // Get Repzo Rep
59
+ let repzo_rep;
60
+ if (repzo_proforma.creator.type == "rep") {
61
+ repzo_rep = await repzo.rep.get(
62
+ (_e =
63
+ repzo_proforma === null || repzo_proforma === void 0
64
+ ? void 0
65
+ : repzo_proforma.creator) === null || _e === void 0
66
+ ? void 0
67
+ : _e._id
68
+ );
69
+ if (!repzo_rep)
70
+ throw `Rep with _id: ${repzo_proforma.creator._id} not found in Repzo`;
71
+ }
72
+ // Get Repzo Client
73
+ const repzo_client = await repzo.client.get(
74
+ repzo_proforma === null || repzo_proforma === void 0
75
+ ? void 0
76
+ : repzo_proforma.client_id
77
+ );
78
+ if (!repzo_client)
79
+ throw `Client with _id: ${repzo_proforma.client_id} not found in Repzo`;
80
+ const repzo_tax_ids = {};
81
+ const repzo_measureunit_ids = {};
82
+ const repzo_product_ids = {};
83
+ (_f = repzo_proforma.items) === null || _f === void 0
84
+ ? void 0
85
+ : _f.forEach((item) => {
86
+ var _a, _b, _c;
87
+ if (item) {
88
+ repzo_tax_ids[
89
+ (_a = item.tax) === null || _a === void 0 ? void 0 : _a._id
90
+ ] = true;
91
+ repzo_measureunit_ids[
92
+ (_b = item.measureunit) === null || _b === void 0
93
+ ? void 0
94
+ : _b._id
95
+ ] = true;
96
+ repzo_product_ids[
97
+ (_c = item.variant) === null || _c === void 0
98
+ ? void 0
99
+ : _c.product_id
100
+ ] = true;
101
+ }
67
102
  });
68
- const repzo_taxes = await repzo.patchAction.create({
69
- slug: "tax",
70
- readQuery: [
71
- {
72
- key: "_id",
73
- value: Object.keys(repzo_tax_ids),
74
- operator: "in",
75
- },
76
- ],
77
- }, { per_page: 50000 });
78
- const repzo_measureunits = await repzo.patchAction.create({
79
- slug: "measureunits",
80
- readQuery: [
81
- {
82
- key: "_id",
83
- value: Object.keys(repzo_measureunit_ids),
84
- operator: "in",
85
- },
86
- ],
87
- }, { per_page: 50000 });
88
- const repzo_products = await repzo.patchAction.create({
89
- slug: "product",
90
- readQuery: [
91
- {
92
- key: "_id",
93
- value: Object.keys(repzo_product_ids),
94
- operator: "in",
95
- },
96
- ],
97
- }, { per_page: 50000 });
98
- // Prepare SAP_invoice_items
99
- const items = [];
100
- for (let i = 0; i < ((_g = repzo_proforma === null || repzo_proforma === void 0 ? void 0 : repzo_proforma.items) === null || _g === void 0 ? void 0 : _g.length); i++) {
101
- const item = repzo_proforma.items[i];
102
- // Get Repzo Tax
103
- const repzo_tax = (_h = repzo_taxes === null || repzo_taxes === void 0 ? void 0 : repzo_taxes.data) === null || _h === void 0 ? void 0 : _h.find((t) => { var _a, _b, _c; return ((_a = t._id) === null || _a === void 0 ? void 0 : _a.toString()) == ((_c = (_b = item.tax) === null || _b === void 0 ? void 0 : _b._id) === null || _c === void 0 ? void 0 : _c.toString()); });
104
- if (!repzo_tax)
105
- throw `Tax with _id: ${item.tax._id} not found in Repzo`;
106
- // Get Repzo UoM
107
- const repzo_measureunit = (_j = repzo_measureunits === null || repzo_measureunits === void 0 ? void 0 : repzo_measureunits.data) === null || _j === void 0 ? void 0 : _j.find((m) => { var _a, _b, _c; return ((_a = m._id) === null || _a === void 0 ? void 0 : _a.toString()) == ((_c = (_b = item.measureunit) === null || _b === void 0 ? void 0 : _b._id) === null || _c === void 0 ? void 0 : _c.toString()); });
108
- if (!repzo_measureunit)
109
- throw `Uom with _id: ${(_k = item.measureunit) === null || _k === void 0 ? void 0 : _k._id} not found in Repzo`;
110
- // Get Repzo Product
111
- const repzo_product = (_l = repzo_products === null || repzo_products === void 0 ? void 0 : repzo_products.data) === null || _l === void 0 ? void 0 : _l.find((p) => { var _a, _b, _c; return ((_a = p._id) === null || _a === void 0 ? void 0 : _a.toString()) == ((_c = (_b = item.variant) === null || _b === void 0 ? void 0 : _b.product_id) === null || _c === void 0 ? void 0 : _c.toString()); });
112
- if (!repzo_product)
113
- throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
114
- items.push({
115
- ItemCode: item.variant.variant_name,
116
- Quantity: item.qty,
117
- TaxCode: repzo_tax.integration_meta.TaxCode,
118
- UnitPrice: (item.price * repzo_measureunit.factor) / 1000,
119
- DiscountPerc: "0",
120
- //@ts-ignore
121
- LineTotal: item.total_before_tax / 1000,
122
- UomCode: repzo_measureunit.integration_meta.ALTUOMID,
123
- Brand: (_m = repzo_product.integration_meta) === null || _m === void 0 ? void 0 : _m.BRAND,
124
- Department: ((_o = repzo_rep === null || repzo_rep === void 0 ? void 0 : repzo_rep.integration_meta) === null || _o === void 0 ? void 0 : _o.DEPARTMENTCODE) ||
125
- ((_p = options.data) === null || _p === void 0 ? void 0 : _p.DepartmentCode), // "D2"
103
+ const repzo_taxes = await repzo.patchAction.create(
104
+ {
105
+ slug: "tax",
106
+ readQuery: [
107
+ {
108
+ key: "_id",
109
+ value: Object.keys(repzo_tax_ids),
110
+ operator: "in",
111
+ },
112
+ ],
113
+ },
114
+ { per_page: 50000 }
115
+ );
116
+ const repzo_measureunits = await repzo.patchAction.create(
117
+ {
118
+ slug: "measureunits",
119
+ readQuery: [
120
+ {
121
+ key: "_id",
122
+ value: Object.keys(repzo_measureunit_ids),
123
+ operator: "in",
124
+ },
125
+ ],
126
+ },
127
+ { per_page: 50000 }
128
+ );
129
+ const repzo_products = await repzo.patchAction.create(
130
+ {
131
+ slug: "product",
132
+ readQuery: [
133
+ {
134
+ key: "_id",
135
+ value: Object.keys(repzo_product_ids),
136
+ operator: "in",
137
+ },
138
+ ],
139
+ },
140
+ { per_page: 50000 }
141
+ );
142
+ // Prepare SAP_invoice_items
143
+ const items = [];
144
+ for (
145
+ let i = 0;
146
+ i <
147
+ ((_g =
148
+ repzo_proforma === null || repzo_proforma === void 0
149
+ ? void 0
150
+ : repzo_proforma.items) === null || _g === void 0
151
+ ? void 0
152
+ : _g.length);
153
+ i++
154
+ ) {
155
+ const item = repzo_proforma.items[i];
156
+ // Get Repzo Tax
157
+ const repzo_tax =
158
+ (_h =
159
+ repzo_taxes === null || repzo_taxes === void 0
160
+ ? void 0
161
+ : repzo_taxes.data) === null || _h === void 0
162
+ ? void 0
163
+ : _h.find((t) => {
164
+ var _a, _b, _c;
165
+ return (
166
+ ((_a = t._id) === null || _a === void 0
167
+ ? void 0
168
+ : _a.toString()) ==
169
+ ((_c =
170
+ (_b = item.tax) === null || _b === void 0
171
+ ? void 0
172
+ : _b._id) === null || _c === void 0
173
+ ? void 0
174
+ : _c.toString())
175
+ );
126
176
  });
127
- }
128
- const sap_invoice = {
129
- RefNum: repzo_proforma.serial_number.formatted,
130
- SalPersCode: repzo_rep
131
- ? repzo_rep.integration_id
132
- : (_q = options.data) === null || _q === void 0 ? void 0 : _q.SalPersCode,
133
- DocDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format("YYYYMMDD"),
134
- DocDueDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format("YYYYMMDD"),
135
- ClientCode: repzo_client.client_code,
136
- DiscountPerc: "0",
137
- Note: repzo_proforma.comment,
138
- // WarehouseCode: "1",
139
- LinesDetails: items,
140
- };
141
- // console.dir(sap_invoice, { depth: null });
142
- await actionLog
143
- .addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`, sap_invoice)
144
- .commit();
145
- const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
146
- // console.log(result);
147
- try {
148
- if (body === null || body === void 0 ? void 0 : body._id) {
149
- body.integration_meta = (body === null || body === void 0 ? void 0 : body.integration_meta) || {};
150
- body.integration_meta.sync_to_sap_succeeded = true;
151
- await repzo.proforma.update(body._id, {
152
- integration_meta: body.integration_meta,
153
- });
154
- }
155
- }
156
- catch (e) {
157
- console.error(e);
158
- await actionLog
159
- .addDetail(`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`)
160
- .commit();
161
- }
162
- await actionLog
163
- .addDetail(`SAP Responded with `, result)
164
- .addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
165
- .setStatus("success")
166
- .setBody(repzo_proforma)
167
- .commit();
168
- return result;
169
- }
170
- catch (e) {
177
+ if (!repzo_tax) throw `Tax with _id: ${item.tax._id} not found in Repzo`;
178
+ // Get Repzo UoM
179
+ const repzo_measureunit =
180
+ (_j =
181
+ repzo_measureunits === null || repzo_measureunits === void 0
182
+ ? void 0
183
+ : repzo_measureunits.data) === null || _j === void 0
184
+ ? void 0
185
+ : _j.find((m) => {
186
+ var _a, _b, _c;
187
+ return (
188
+ ((_a = m._id) === null || _a === void 0
189
+ ? void 0
190
+ : _a.toString()) ==
191
+ ((_c =
192
+ (_b = item.measureunit) === null || _b === void 0
193
+ ? void 0
194
+ : _b._id) === null || _c === void 0
195
+ ? void 0
196
+ : _c.toString())
197
+ );
198
+ });
199
+ if (!repzo_measureunit)
200
+ throw `Uom with _id: ${
201
+ (_k = item.measureunit) === null || _k === void 0 ? void 0 : _k._id
202
+ } not found in Repzo`;
203
+ // Get Repzo Product
204
+ const repzo_product =
205
+ (_l =
206
+ repzo_products === null || repzo_products === void 0
207
+ ? void 0
208
+ : repzo_products.data) === null || _l === void 0
209
+ ? void 0
210
+ : _l.find((p) => {
211
+ var _a, _b, _c;
212
+ return (
213
+ ((_a = p._id) === null || _a === void 0
214
+ ? void 0
215
+ : _a.toString()) ==
216
+ ((_c =
217
+ (_b = item.variant) === null || _b === void 0
218
+ ? void 0
219
+ : _b.product_id) === null || _c === void 0
220
+ ? void 0
221
+ : _c.toString())
222
+ );
223
+ });
224
+ if (!repzo_product)
225
+ throw `Product with _id: ${item.measureunit._id} not found in Repzo`;
226
+ items.push({
227
+ ItemCode: item.variant.variant_name,
228
+ Quantity: item.qty,
229
+ TaxCode: repzo_tax.integration_meta.TaxCode,
230
+ UnitPrice: (item.price * repzo_measureunit.factor) / 1000,
231
+ DiscountPerc: "0",
171
232
  //@ts-ignore
172
- console.error((e === null || e === void 0 ? void 0 : e.response) || e);
173
- await actionLog.setStatus("fail", e).setBody(body).commit();
174
- throw e;
233
+ LineTotal: item.total_before_tax / 1000,
234
+ UomCode: repzo_measureunit.integration_meta.ALTUOMID,
235
+ Brand:
236
+ (_m = repzo_product.integration_meta) === null || _m === void 0
237
+ ? void 0
238
+ : _m.BRAND,
239
+ Department:
240
+ ((_o =
241
+ repzo_rep === null || repzo_rep === void 0
242
+ ? void 0
243
+ : repzo_rep.integration_meta) === null || _o === void 0
244
+ ? void 0
245
+ : _o.DEPARTMENTCODE) ||
246
+ ((_p = options.data) === null || _p === void 0
247
+ ? void 0
248
+ : _p.DepartmentCode), // "D2"
249
+ });
175
250
  }
251
+ const sap_invoice = {
252
+ RefNum: repzo_proforma.serial_number.formatted,
253
+ SalPersCode: repzo_rep
254
+ ? repzo_rep.integration_id
255
+ : (_q = options.data) === null || _q === void 0
256
+ ? void 0
257
+ : _q.SalPersCode,
258
+ DocDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format(
259
+ "YYYYMMDD"
260
+ ),
261
+ DocDueDate: moment(repzo_proforma.issue_date, "YYYY-MM-DD").format(
262
+ "YYYYMMDD"
263
+ ),
264
+ ClientCode: repzo_client.client_code,
265
+ DiscountPerc: "0",
266
+ Note: repzo_proforma.comment,
267
+ // WarehouseCode: "1",
268
+ LinesDetails: items,
269
+ };
270
+ // console.dir(sap_invoice, { depth: null });
271
+ actionLog.addDetail(
272
+ `Repzo => SAP: SalesOrder - ${repzo_serial_number}`,
273
+ sap_invoice
274
+ ); // .commit();
275
+ const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
276
+ // console.log(result);
277
+ // try {
278
+ // if (body?._id) {
279
+ // body.integration_meta = body?.integration_meta || {};
280
+ // body.integration_meta.sync_to_sap_succeeded = true;
281
+ // await repzo.proforma.update(body._id, {
282
+ // integration_meta: body.integration_meta,
283
+ // });
284
+ // }
285
+ // } catch (e) {
286
+ // console.error(e);
287
+ // }
288
+ await actionLog
289
+ .addDetail(`SAP Responded with `, result)
290
+ .addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
291
+ .setStatus("success")
292
+ .setBody(repzo_proforma)
293
+ .commit();
294
+ return result;
295
+ } catch (e) {
296
+ //@ts-ignore
297
+ console.error((e === null || e === void 0 ? void 0 : e.response) || e);
298
+ await actionLog.setStatus("fail", e).setBody(body).commit();
299
+ throw e;
300
+ }
176
301
  };
@@ -1,2 +1,5 @@
1
1
  import { EVENT, Config } from "../types";
2
- export declare const create_return_invoice: (event: EVENT, options: Config) => Promise<any>;
2
+ export declare const create_return_invoice: (
3
+ event: EVENT,
4
+ options: Config
5
+ ) => Promise<any>;