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