repzo-sap-absjo 1.0.8 → 1.0.10
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.
- package/lib/actions/create_invoice.js +1 -9
- package/lib/actions/create_payment.js +1 -9
- package/lib/actions/create_proforma.js +25 -35
- package/lib/actions/create_return_invoice.js +1 -9
- package/lib/actions/create_transfer.js +37 -44
- package/package.json +1 -1
- package/src/actions/create_invoice.ts +4 -13
- package/src/actions/create_payment.ts +4 -13
- package/src/actions/create_proforma.ts +28 -40
- package/src/actions/create_return_invoice.ts +4 -16
- package/src/actions/create_transfer.ts +26 -38
|
@@ -31,9 +31,6 @@ export const create_invoice = async (event, options) => {
|
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
33
|
console.error(e);
|
|
34
|
-
await actionLog
|
|
35
|
-
.addDetail(`Failed updating integration_meta of Invoice: ${repzo_serial_number}`)
|
|
36
|
-
.commit();
|
|
37
34
|
}
|
|
38
35
|
await actionLog
|
|
39
36
|
.addDetail(`Invoice - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
|
|
@@ -179,9 +176,7 @@ export const create_invoice = async (event, options) => {
|
|
|
179
176
|
LinesDetails: items,
|
|
180
177
|
};
|
|
181
178
|
// console.dir(sap_invoice, { depth: null });
|
|
182
|
-
|
|
183
|
-
.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`, sap_invoice)
|
|
184
|
-
.commit();
|
|
179
|
+
actionLog.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`, sap_invoice);
|
|
185
180
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
186
181
|
// console.log(result);
|
|
187
182
|
try {
|
|
@@ -195,9 +190,6 @@ export const create_invoice = async (event, options) => {
|
|
|
195
190
|
}
|
|
196
191
|
catch (e) {
|
|
197
192
|
console.error(e);
|
|
198
|
-
await actionLog
|
|
199
|
-
.addDetail(`Failed updating integration_meta of Invoice: ${repzo_serial_number}`)
|
|
200
|
-
.commit();
|
|
201
193
|
}
|
|
202
194
|
await actionLog
|
|
203
195
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -32,9 +32,6 @@ export const create_payment = async (event, options) => {
|
|
|
32
32
|
}
|
|
33
33
|
catch (e) {
|
|
34
34
|
console.error(e);
|
|
35
|
-
await actionLog
|
|
36
|
-
.addDetail(`Failed updating integration_meta of Payment: ${repzo_serial_number}`)
|
|
37
|
-
.commit();
|
|
38
35
|
}
|
|
39
36
|
await actionLog
|
|
40
37
|
.addDetail(`Payment - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
|
|
@@ -99,9 +96,7 @@ export const create_payment = async (event, options) => {
|
|
|
99
96
|
sap_payment.CashAccount = (_q = repzo_rep === null || repzo_rep === void 0 ? void 0 : repzo_rep.integration_meta) === null || _q === void 0 ? void 0 : _q.USERCASHACCOUNT;
|
|
100
97
|
}
|
|
101
98
|
// console.dir(sap_payment, { depth: null });
|
|
102
|
-
|
|
103
|
-
.addDetail(`Repzo => SAP: Payment - ${repzo_serial_number}`, sap_payment)
|
|
104
|
-
.commit();
|
|
99
|
+
actionLog.addDetail(`Repzo => SAP: Payment - ${repzo_serial_number}`, sap_payment);
|
|
105
100
|
const result = await _create(SAP_HOST_URL, "/AddPayment", sap_payment);
|
|
106
101
|
// console.log(result);
|
|
107
102
|
try {
|
|
@@ -115,9 +110,6 @@ export const create_payment = async (event, options) => {
|
|
|
115
110
|
}
|
|
116
111
|
catch (e) {
|
|
117
112
|
console.error(e);
|
|
118
|
-
await actionLog
|
|
119
|
-
.addDetail(`Failed updating integration_meta of Payment: ${repzo_serial_number}`)
|
|
120
|
-
.commit();
|
|
121
113
|
}
|
|
122
114
|
await actionLog
|
|
123
115
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -18,23 +18,19 @@ export const create_proforma = async (event, options) => {
|
|
|
18
18
|
}
|
|
19
19
|
catch (e) { }
|
|
20
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await actionLog
|
|
35
|
-
.addDetail(`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`)
|
|
36
|
-
.commit();
|
|
37
|
-
}
|
|
21
|
+
// try {
|
|
22
|
+
// if (body?._id) {
|
|
23
|
+
// body.integration_meta = 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
|
+
// } catch (e) {
|
|
32
|
+
// console.error(e);
|
|
33
|
+
// }
|
|
38
34
|
await actionLog
|
|
39
35
|
.addDetail(`SalesOrder - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
|
|
40
36
|
.addDetail(`Repzo => SAP: Started Create SalesOrder - ${repzo_serial_number}`)
|
|
@@ -139,26 +135,20 @@ export const create_proforma = async (event, options) => {
|
|
|
139
135
|
LinesDetails: items,
|
|
140
136
|
};
|
|
141
137
|
// console.dir(sap_invoice, { depth: null });
|
|
142
|
-
|
|
143
|
-
.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`, sap_invoice)
|
|
144
|
-
.commit();
|
|
138
|
+
actionLog.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`, sap_invoice); // .commit();
|
|
145
139
|
const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
146
140
|
// console.log(result);
|
|
147
|
-
try {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
await actionLog
|
|
159
|
-
.addDetail(`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`)
|
|
160
|
-
.commit();
|
|
161
|
-
}
|
|
141
|
+
// try {
|
|
142
|
+
// if (body?._id) {
|
|
143
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
144
|
+
// body.integration_meta.sync_to_sap_succeeded = true;
|
|
145
|
+
// await repzo.proforma.update(body._id, {
|
|
146
|
+
// integration_meta: body.integration_meta,
|
|
147
|
+
// });
|
|
148
|
+
// }
|
|
149
|
+
// } catch (e) {
|
|
150
|
+
// console.error(e);
|
|
151
|
+
// }
|
|
162
152
|
await actionLog
|
|
163
153
|
.addDetail(`SAP Responded with `, result)
|
|
164
154
|
.addDetail(`Repzo => SAP: SalesOrder - ${repzo_serial_number}`)
|
|
@@ -31,9 +31,6 @@ export const create_return_invoice = async (event, options) => {
|
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
33
|
console.error(e);
|
|
34
|
-
await actionLog
|
|
35
|
-
.addDetail(`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`)
|
|
36
|
-
.commit();
|
|
37
34
|
}
|
|
38
35
|
await actionLog
|
|
39
36
|
.addDetail(`Return Invoice - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
|
|
@@ -151,9 +148,7 @@ export const create_return_invoice = async (event, options) => {
|
|
|
151
148
|
LinesDetails: return_items,
|
|
152
149
|
};
|
|
153
150
|
// console.dir(sap_return_invoice, { depth: null });
|
|
154
|
-
|
|
155
|
-
.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`, sap_return_invoice)
|
|
156
|
-
.commit();
|
|
151
|
+
actionLog.addDetail(`Repzo => SAP: Invoice - ${repzo_serial_number}`, sap_return_invoice);
|
|
157
152
|
const result = await _create(SAP_HOST_URL, "/AddCreditMemo", sap_return_invoice);
|
|
158
153
|
// console.log(result);
|
|
159
154
|
try {
|
|
@@ -167,9 +162,6 @@ export const create_return_invoice = async (event, options) => {
|
|
|
167
162
|
}
|
|
168
163
|
catch (e) {
|
|
169
164
|
console.error(e);
|
|
170
|
-
await actionLog
|
|
171
|
-
.addDetail(`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`)
|
|
172
|
-
.commit();
|
|
173
165
|
}
|
|
174
166
|
await actionLog
|
|
175
167
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -2,56 +2,54 @@ import Repzo from "repzo";
|
|
|
2
2
|
import { _create, send_command_to_marketplace, } from "../util.js";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
export const create_transfer = async (event, options) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
6
6
|
const repzo = new Repzo((_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey, { env: options.env });
|
|
7
7
|
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();
|
|
8
8
|
const actionLog = new Repzo.ActionLogs(repzo, action_sync_id);
|
|
9
9
|
let body;
|
|
10
10
|
try {
|
|
11
11
|
// console.log("create_transfer");
|
|
12
|
-
await actionLog.load(action_sync_id);
|
|
13
12
|
body = event.body;
|
|
14
13
|
try {
|
|
15
14
|
if (body)
|
|
16
15
|
body = JSON.parse(body);
|
|
17
16
|
}
|
|
18
17
|
catch (e) { }
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
18
|
+
if ((_c = body === null || body === void 0 ? void 0 : body.integration_meta) === null || _c === void 0 ? void 0 : _c.sync_to_sap_started)
|
|
19
|
+
return;
|
|
20
|
+
await actionLog.load(action_sync_id);
|
|
21
|
+
const repzo_serial_number = (_d = body === null || body === void 0 ? void 0 : body.serial_number) === null || _d === void 0 ? void 0 : _d.formatted;
|
|
22
|
+
// try {
|
|
23
|
+
// if (body?._id) {
|
|
24
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
25
|
+
// body.integration_meta.sync_to_sap_started = true;
|
|
26
|
+
// body.integration_meta.sync_to_sap_succeeded =
|
|
27
|
+
// body.integration_meta.sync_to_sap_succeeded || false;
|
|
28
|
+
// await repzo.transfer.update(body._id, {
|
|
29
|
+
// integration_meta: body.integration_meta,
|
|
30
|
+
// });
|
|
31
|
+
// }
|
|
32
|
+
// } catch (e) {
|
|
33
|
+
// console.error(e);
|
|
34
|
+
// }
|
|
37
35
|
await actionLog
|
|
38
36
|
.addDetail(`Transfer - ${repzo_serial_number} => ${body === null || body === void 0 ? void 0 : body.sync_id}`)
|
|
39
37
|
.addDetail(`Repzo => SAP: Started Create Transfer - ${repzo_serial_number}`)
|
|
40
38
|
.commit();
|
|
41
|
-
const SAP_HOST_URL = (
|
|
39
|
+
const SAP_HOST_URL = (_e = options.data) === null || _e === void 0 ? void 0 : _e.sapHostUrl;
|
|
42
40
|
if (!SAP_HOST_URL)
|
|
43
41
|
throw `SAP Host Url is missing and Required: ${SAP_HOST_URL}`;
|
|
44
42
|
const repzo_transfer = body;
|
|
45
43
|
// Get Repzo Rep
|
|
46
44
|
let repzo_rep;
|
|
47
45
|
if (repzo_transfer.creator.type == "rep") {
|
|
48
|
-
repzo_rep = await repzo.rep.get((
|
|
46
|
+
repzo_rep = await repzo.rep.get((_f = repzo_transfer === null || repzo_transfer === void 0 ? void 0 : repzo_transfer.creator) === null || _f === void 0 ? void 0 : _f._id);
|
|
49
47
|
if (!repzo_rep)
|
|
50
48
|
throw `Rep with _id: ${repzo_transfer.creator._id} not found in Repzo`;
|
|
51
49
|
}
|
|
52
50
|
// Get Repzo Products with its own Populated MeasureUnit
|
|
53
51
|
const repzo_product_ids = {};
|
|
54
|
-
(
|
|
52
|
+
(_g = repzo_transfer.variants) === null || _g === void 0 ? void 0 : _g.forEach((item) => {
|
|
55
53
|
if (item === null || item === void 0 ? void 0 : item.product_id) {
|
|
56
54
|
repzo_product_ids[item.product_id.toString()] = true;
|
|
57
55
|
}
|
|
@@ -68,9 +66,9 @@ export const create_transfer = async (event, options) => {
|
|
|
68
66
|
}, { per_page: 50000, populatedKeys: ["measureunit"] });
|
|
69
67
|
// Prepare Transfer Items
|
|
70
68
|
const variants = [];
|
|
71
|
-
for (let i = 0; i < ((
|
|
69
|
+
for (let i = 0; i < ((_h = repzo_transfer.variants) === null || _h === void 0 ? void 0 : _h.length); i++) {
|
|
72
70
|
const repzo_transfer_item = repzo_transfer.variants[i];
|
|
73
|
-
const repzo_product = (
|
|
71
|
+
const repzo_product = (_j = repzo_products === null || repzo_products === void 0 ? void 0 : repzo_products.data) === null || _j === void 0 ? void 0 : _j.find(
|
|
74
72
|
//@ts-ignore
|
|
75
73
|
(p) => { var _a; return p._id.toString() == ((_a = repzo_transfer_item.product_id) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
76
74
|
if (!repzo_product) {
|
|
@@ -84,47 +82,42 @@ export const create_transfer = async (event, options) => {
|
|
|
84
82
|
// console.log(
|
|
85
83
|
// `Measureunit with _id: ${repzo_product.sv_measureUnit?.toString()} was not found`,
|
|
86
84
|
// );
|
|
87
|
-
throw new Error(`Measureunit with _id: ${(
|
|
85
|
+
throw new Error(`Measureunit with _id: ${(_k = repzo_product.sv_measureUnit) === null || _k === void 0 ? void 0 : _k.toString()} was not found`);
|
|
88
86
|
}
|
|
89
87
|
variants.push({
|
|
90
88
|
//@ts-ignore
|
|
91
89
|
ItemCode: repzo_transfer_item.variant_name,
|
|
92
90
|
Quantity: repzo_transfer_item.qty / Number(repzo_measure_unit.factor),
|
|
93
91
|
//@ts-ignore
|
|
94
|
-
FromWarehouse: (
|
|
92
|
+
FromWarehouse: (_l = repzo_transfer.from) === null || _l === void 0 ? void 0 : _l.code,
|
|
95
93
|
//@ts-ignore
|
|
96
|
-
ToWarehouse: (
|
|
94
|
+
ToWarehouse: (_m = repzo_transfer.to) === null || _m === void 0 ? void 0 : _m.code,
|
|
97
95
|
});
|
|
98
96
|
}
|
|
99
97
|
const sap_transfer = {
|
|
100
98
|
StockTransferID: body.serial_number.formatted,
|
|
101
99
|
SalesPersonCode: repzo_rep
|
|
102
100
|
? repzo_rep.integration_id
|
|
103
|
-
: (
|
|
101
|
+
: (_o = options.data) === null || _o === void 0 ? void 0 : _o.SalesPersonCode,
|
|
104
102
|
FromWarehouse: body.from.code,
|
|
105
103
|
ToWarehouse: body.to.code,
|
|
106
104
|
RepzoStockTransferLines: variants,
|
|
107
105
|
};
|
|
108
106
|
// console.dir(sap_transfer, { depth: null });
|
|
109
|
-
|
|
110
|
-
.addDetail(`Repzo => SAP: Transfer - ${repzo_serial_number}`, sap_transfer)
|
|
111
|
-
.commit();
|
|
107
|
+
actionLog.addDetail(`Repzo => SAP: Transfer - ${repzo_serial_number}`, sap_transfer);
|
|
112
108
|
const result = await _create(SAP_HOST_URL, "/AddStockTransfer", sap_transfer);
|
|
113
109
|
// console.log(result);
|
|
114
110
|
try {
|
|
115
|
-
if (body
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
111
|
+
// if (body?._id) {
|
|
112
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
113
|
+
// body.integration_meta.sync_to_sap_succeeded = true;
|
|
114
|
+
// await repzo.transfer.update(body._id, {
|
|
115
|
+
// integration_meta: body.integration_meta,
|
|
116
|
+
// });
|
|
117
|
+
// }
|
|
122
118
|
}
|
|
123
119
|
catch (e) {
|
|
124
120
|
console.error(e);
|
|
125
|
-
await actionLog
|
|
126
|
-
.addDetail(`Failed updating integration_meta of Transfer: ${repzo_serial_number}`)
|
|
127
|
-
.commit();
|
|
128
121
|
}
|
|
129
122
|
await actionLog
|
|
130
123
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -138,12 +131,12 @@ export const create_transfer = async (event, options) => {
|
|
|
138
131
|
//@ts-ignore
|
|
139
132
|
console.error((e === null || e === void 0 ? void 0 : e.response) || e);
|
|
140
133
|
await actionLog.setStatus("fail", e).setBody(body).commit();
|
|
141
|
-
if ((
|
|
134
|
+
if ((_q = (_p = options === null || options === void 0 ? void 0 : options.data) === null || _p === void 0 ? void 0 : _p.transfers) === null || _q === void 0 ? void 0 : _q.adjustInventoryInFailedTransfer) {
|
|
142
135
|
send_command_to_marketplace({
|
|
143
136
|
command: "adjust_inventory",
|
|
144
137
|
app_id: options.app_id,
|
|
145
138
|
env: options.env,
|
|
146
|
-
repzoApiKey: (
|
|
139
|
+
repzoApiKey: (_r = options.data) === null || _r === void 0 ? void 0 : _r.repzoApiKey,
|
|
147
140
|
});
|
|
148
141
|
}
|
|
149
142
|
throw e;
|
package/package.json
CHANGED
|
@@ -74,11 +74,6 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
74
74
|
}
|
|
75
75
|
} catch (e) {
|
|
76
76
|
console.error(e);
|
|
77
|
-
await actionLog
|
|
78
|
-
.addDetail(
|
|
79
|
-
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
80
|
-
)
|
|
81
|
-
.commit();
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
await actionLog
|
|
@@ -276,9 +271,10 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
276
271
|
|
|
277
272
|
// console.dir(sap_invoice, { depth: null });
|
|
278
273
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
274
|
+
actionLog.addDetail(
|
|
275
|
+
`Repzo => SAP: Invoice - ${repzo_serial_number}`,
|
|
276
|
+
sap_invoice
|
|
277
|
+
);
|
|
282
278
|
|
|
283
279
|
const result = await _create(SAP_HOST_URL, "/AddInvoice", sap_invoice);
|
|
284
280
|
|
|
@@ -294,11 +290,6 @@ export const create_invoice = async (event: EVENT, options: Config) => {
|
|
|
294
290
|
}
|
|
295
291
|
} catch (e) {
|
|
296
292
|
console.error(e);
|
|
297
|
-
await actionLog
|
|
298
|
-
.addDetail(
|
|
299
|
-
`Failed updating integration_meta of Invoice: ${repzo_serial_number}`
|
|
300
|
-
)
|
|
301
|
-
.commit();
|
|
302
293
|
}
|
|
303
294
|
|
|
304
295
|
await actionLog
|
|
@@ -49,11 +49,6 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
49
49
|
}
|
|
50
50
|
} catch (e) {
|
|
51
51
|
console.error(e);
|
|
52
|
-
await actionLog
|
|
53
|
-
.addDetail(
|
|
54
|
-
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
55
|
-
)
|
|
56
|
-
.commit();
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
await actionLog
|
|
@@ -133,9 +128,10 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
133
128
|
|
|
134
129
|
// console.dir(sap_payment, { depth: null });
|
|
135
130
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
actionLog.addDetail(
|
|
132
|
+
`Repzo => SAP: Payment - ${repzo_serial_number}`,
|
|
133
|
+
sap_payment
|
|
134
|
+
);
|
|
139
135
|
|
|
140
136
|
const result = await _create(SAP_HOST_URL, "/AddPayment", sap_payment);
|
|
141
137
|
|
|
@@ -151,11 +147,6 @@ export const create_payment = async (event: EVENT, options: Config) => {
|
|
|
151
147
|
}
|
|
152
148
|
} catch (e) {
|
|
153
149
|
console.error(e);
|
|
154
|
-
await actionLog
|
|
155
|
-
.addDetail(
|
|
156
|
-
`Failed updating integration_meta of Payment: ${repzo_serial_number}`
|
|
157
|
-
)
|
|
158
|
-
.commit();
|
|
159
150
|
}
|
|
160
151
|
|
|
161
152
|
await actionLog
|
|
@@ -44,24 +44,19 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
44
44
|
} catch (e) {}
|
|
45
45
|
|
|
46
46
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
47
|
-
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} catch (e) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.addDetail(
|
|
61
|
-
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
62
|
-
)
|
|
63
|
-
.commit();
|
|
64
|
-
}
|
|
47
|
+
// try {
|
|
48
|
+
// if (body?._id) {
|
|
49
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
50
|
+
// body.integration_meta.sync_to_sap_started = true;
|
|
51
|
+
// body.integration_meta.sync_to_sap_succeeded =
|
|
52
|
+
// body.integration_meta.sync_to_sap_succeeded || false;
|
|
53
|
+
// await repzo.proforma.update(body._id, {
|
|
54
|
+
// integration_meta: body.integration_meta,
|
|
55
|
+
// });
|
|
56
|
+
// }
|
|
57
|
+
// } catch (e) {
|
|
58
|
+
// console.error(e);
|
|
59
|
+
// }
|
|
65
60
|
|
|
66
61
|
await actionLog
|
|
67
62
|
.addDetail(`SalesOrder - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -204,33 +199,26 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
204
199
|
|
|
205
200
|
// console.dir(sap_invoice, { depth: null });
|
|
206
201
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
212
|
-
.commit();
|
|
202
|
+
actionLog.addDetail(
|
|
203
|
+
`Repzo => SAP: SalesOrder - ${repzo_serial_number}`,
|
|
204
|
+
sap_invoice
|
|
205
|
+
); // .commit();
|
|
213
206
|
|
|
214
207
|
const result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
215
208
|
|
|
216
209
|
// console.log(result);
|
|
217
210
|
|
|
218
|
-
try {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
} catch (e) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
.addDetail(
|
|
230
|
-
`Failed updating integration_meta of SalesOrder: ${repzo_serial_number}`
|
|
231
|
-
)
|
|
232
|
-
.commit();
|
|
233
|
-
}
|
|
211
|
+
// try {
|
|
212
|
+
// if (body?._id) {
|
|
213
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
214
|
+
// body.integration_meta.sync_to_sap_succeeded = true;
|
|
215
|
+
// await repzo.proforma.update(body._id, {
|
|
216
|
+
// integration_meta: body.integration_meta,
|
|
217
|
+
// });
|
|
218
|
+
// }
|
|
219
|
+
// } catch (e) {
|
|
220
|
+
// console.error(e);
|
|
221
|
+
// }
|
|
234
222
|
|
|
235
223
|
await actionLog
|
|
236
224
|
.addDetail(`SAP Responded with `, result)
|
|
@@ -64,11 +64,6 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
64
64
|
}
|
|
65
65
|
} catch (e) {
|
|
66
66
|
console.error(e);
|
|
67
|
-
await actionLog
|
|
68
|
-
.addDetail(
|
|
69
|
-
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
70
|
-
)
|
|
71
|
-
.commit();
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
await actionLog
|
|
@@ -231,12 +226,10 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
231
226
|
|
|
232
227
|
// console.dir(sap_return_invoice, { depth: null });
|
|
233
228
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
)
|
|
239
|
-
.commit();
|
|
229
|
+
actionLog.addDetail(
|
|
230
|
+
`Repzo => SAP: Invoice - ${repzo_serial_number}`,
|
|
231
|
+
sap_return_invoice
|
|
232
|
+
);
|
|
240
233
|
|
|
241
234
|
const result = await _create(
|
|
242
235
|
SAP_HOST_URL,
|
|
@@ -256,11 +249,6 @@ export const create_return_invoice = async (event: EVENT, options: Config) => {
|
|
|
256
249
|
}
|
|
257
250
|
} catch (e) {
|
|
258
251
|
console.error(e);
|
|
259
|
-
await actionLog
|
|
260
|
-
.addDetail(
|
|
261
|
-
`Failed updating integration_meta of Return Invoice: ${repzo_serial_number}`
|
|
262
|
-
)
|
|
263
|
-
.commit();
|
|
264
252
|
}
|
|
265
253
|
|
|
266
254
|
await actionLog
|
|
@@ -33,32 +33,27 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
33
33
|
let body: Service.Transfer.Schema | any;
|
|
34
34
|
try {
|
|
35
35
|
// console.log("create_transfer");
|
|
36
|
-
await actionLog.load(action_sync_id);
|
|
37
36
|
|
|
38
37
|
body = event.body;
|
|
39
38
|
try {
|
|
40
39
|
if (body) body = JSON.parse(body);
|
|
41
40
|
} catch (e) {}
|
|
42
|
-
|
|
41
|
+
if (body?.integration_meta?.sync_to_sap_started) return;
|
|
42
|
+
await actionLog.load(action_sync_id);
|
|
43
43
|
const repzo_serial_number = body?.serial_number?.formatted;
|
|
44
|
-
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} catch (e) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.addDetail(
|
|
58
|
-
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
59
|
-
)
|
|
60
|
-
.commit();
|
|
61
|
-
}
|
|
44
|
+
// try {
|
|
45
|
+
// if (body?._id) {
|
|
46
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
47
|
+
// body.integration_meta.sync_to_sap_started = true;
|
|
48
|
+
// body.integration_meta.sync_to_sap_succeeded =
|
|
49
|
+
// body.integration_meta.sync_to_sap_succeeded || false;
|
|
50
|
+
// await repzo.transfer.update(body._id, {
|
|
51
|
+
// integration_meta: body.integration_meta,
|
|
52
|
+
// });
|
|
53
|
+
// }
|
|
54
|
+
// } catch (e) {
|
|
55
|
+
// console.error(e);
|
|
56
|
+
// }
|
|
62
57
|
|
|
63
58
|
await actionLog
|
|
64
59
|
.addDetail(`Transfer - ${repzo_serial_number} => ${body?.sync_id}`)
|
|
@@ -161,12 +156,10 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
161
156
|
|
|
162
157
|
// console.dir(sap_transfer, { depth: null });
|
|
163
158
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
169
|
-
.commit();
|
|
159
|
+
actionLog.addDetail(
|
|
160
|
+
`Repzo => SAP: Transfer - ${repzo_serial_number}`,
|
|
161
|
+
sap_transfer
|
|
162
|
+
);
|
|
170
163
|
|
|
171
164
|
const result = await _create(
|
|
172
165
|
SAP_HOST_URL,
|
|
@@ -176,20 +169,15 @@ export const create_transfer = async (event: EVENT, options: Config) => {
|
|
|
176
169
|
|
|
177
170
|
// console.log(result);
|
|
178
171
|
try {
|
|
179
|
-
if (body?._id) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
172
|
+
// if (body?._id) {
|
|
173
|
+
// body.integration_meta = body?.integration_meta || {};
|
|
174
|
+
// body.integration_meta.sync_to_sap_succeeded = true;
|
|
175
|
+
// await repzo.transfer.update(body._id, {
|
|
176
|
+
// integration_meta: body.integration_meta,
|
|
177
|
+
// });
|
|
178
|
+
// }
|
|
186
179
|
} catch (e) {
|
|
187
180
|
console.error(e);
|
|
188
|
-
await actionLog
|
|
189
|
-
.addDetail(
|
|
190
|
-
`Failed updating integration_meta of Transfer: ${repzo_serial_number}`
|
|
191
|
-
)
|
|
192
|
-
.commit();
|
|
193
181
|
}
|
|
194
182
|
|
|
195
183
|
await actionLog
|