repzo-sap-absjo 1.0.9 → 1.0.11
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/changelog.md
CHANGED
|
@@ -2,7 +2,7 @@ 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(
|
|
7
7
|
(_a = options.data) === null || _a === void 0 ? void 0 : _a.repzoApiKey,
|
|
8
8
|
{ env: options.env }
|
|
@@ -16,16 +16,24 @@ export const create_transfer = async (event, options) => {
|
|
|
16
16
|
let body;
|
|
17
17
|
try {
|
|
18
18
|
// console.log("create_transfer");
|
|
19
|
-
await actionLog.load(action_sync_id);
|
|
20
19
|
body = event.body;
|
|
21
20
|
try {
|
|
22
21
|
if (body) body = JSON.parse(body);
|
|
23
22
|
} catch (e) {}
|
|
24
|
-
|
|
25
|
-
(_c =
|
|
23
|
+
if (
|
|
24
|
+
(_c =
|
|
25
|
+
body === null || body === void 0 ? void 0 : body.integration_meta) ===
|
|
26
26
|
null || _c === void 0
|
|
27
27
|
? void 0
|
|
28
|
-
: _c.
|
|
28
|
+
: _c.sync_to_sap_started
|
|
29
|
+
)
|
|
30
|
+
return;
|
|
31
|
+
await actionLog.load(action_sync_id);
|
|
32
|
+
const repzo_serial_number =
|
|
33
|
+
(_d = body === null || body === void 0 ? void 0 : body.serial_number) ===
|
|
34
|
+
null || _d === void 0
|
|
35
|
+
? void 0
|
|
36
|
+
: _d.formatted;
|
|
29
37
|
// try {
|
|
30
38
|
// if (body?._id) {
|
|
31
39
|
// body.integration_meta = body?.integration_meta || {};
|
|
@@ -50,7 +58,7 @@ export const create_transfer = async (event, options) => {
|
|
|
50
58
|
)
|
|
51
59
|
.commit();
|
|
52
60
|
const SAP_HOST_URL =
|
|
53
|
-
(
|
|
61
|
+
(_e = options.data) === null || _e === void 0 ? void 0 : _e.sapHostUrl;
|
|
54
62
|
if (!SAP_HOST_URL)
|
|
55
63
|
throw `SAP Host Url is missing and Required: ${SAP_HOST_URL}`;
|
|
56
64
|
const repzo_transfer = body;
|
|
@@ -58,21 +66,21 @@ export const create_transfer = async (event, options) => {
|
|
|
58
66
|
let repzo_rep;
|
|
59
67
|
if (repzo_transfer.creator.type == "rep") {
|
|
60
68
|
repzo_rep = await repzo.rep.get(
|
|
61
|
-
(
|
|
69
|
+
(_f =
|
|
62
70
|
repzo_transfer === null || repzo_transfer === void 0
|
|
63
71
|
? void 0
|
|
64
|
-
: repzo_transfer.creator) === null ||
|
|
72
|
+
: repzo_transfer.creator) === null || _f === void 0
|
|
65
73
|
? void 0
|
|
66
|
-
:
|
|
74
|
+
: _f._id
|
|
67
75
|
);
|
|
68
76
|
if (!repzo_rep)
|
|
69
77
|
throw `Rep with _id: ${repzo_transfer.creator._id} not found in Repzo`;
|
|
70
78
|
}
|
|
71
79
|
// Get Repzo Products with its own Populated MeasureUnit
|
|
72
80
|
const repzo_product_ids = {};
|
|
73
|
-
(
|
|
81
|
+
(_g = repzo_transfer.variants) === null || _g === void 0
|
|
74
82
|
? void 0
|
|
75
|
-
:
|
|
83
|
+
: _g.forEach((item) => {
|
|
76
84
|
if (item === null || item === void 0 ? void 0 : item.product_id) {
|
|
77
85
|
repzo_product_ids[item.product_id.toString()] = true;
|
|
78
86
|
}
|
|
@@ -95,19 +103,19 @@ export const create_transfer = async (event, options) => {
|
|
|
95
103
|
for (
|
|
96
104
|
let i = 0;
|
|
97
105
|
i <
|
|
98
|
-
((
|
|
106
|
+
((_h = repzo_transfer.variants) === null || _h === void 0
|
|
99
107
|
? void 0
|
|
100
|
-
:
|
|
108
|
+
: _h.length);
|
|
101
109
|
i++
|
|
102
110
|
) {
|
|
103
111
|
const repzo_transfer_item = repzo_transfer.variants[i];
|
|
104
112
|
const repzo_product =
|
|
105
|
-
(
|
|
113
|
+
(_j =
|
|
106
114
|
repzo_products === null || repzo_products === void 0
|
|
107
115
|
? void 0
|
|
108
|
-
: repzo_products.data) === null ||
|
|
116
|
+
: repzo_products.data) === null || _j === void 0
|
|
109
117
|
? void 0
|
|
110
|
-
:
|
|
118
|
+
: _j.find(
|
|
111
119
|
//@ts-ignore
|
|
112
120
|
(p) => {
|
|
113
121
|
var _a;
|
|
@@ -139,9 +147,9 @@ export const create_transfer = async (event, options) => {
|
|
|
139
147
|
// );
|
|
140
148
|
throw new Error(
|
|
141
149
|
`Measureunit with _id: ${
|
|
142
|
-
(
|
|
150
|
+
(_k = repzo_product.sv_measureUnit) === null || _k === void 0
|
|
143
151
|
? void 0
|
|
144
|
-
:
|
|
152
|
+
: _k.toString()
|
|
145
153
|
} was not found`
|
|
146
154
|
);
|
|
147
155
|
}
|
|
@@ -151,21 +159,21 @@ export const create_transfer = async (event, options) => {
|
|
|
151
159
|
Quantity: repzo_transfer_item.qty / Number(repzo_measure_unit.factor),
|
|
152
160
|
//@ts-ignore
|
|
153
161
|
FromWarehouse:
|
|
154
|
-
(
|
|
162
|
+
(_l = repzo_transfer.from) === null || _l === void 0
|
|
155
163
|
? void 0
|
|
156
|
-
:
|
|
164
|
+
: _l.code,
|
|
157
165
|
//@ts-ignore
|
|
158
166
|
ToWarehouse:
|
|
159
|
-
(
|
|
167
|
+
(_m = repzo_transfer.to) === null || _m === void 0 ? void 0 : _m.code,
|
|
160
168
|
});
|
|
161
169
|
}
|
|
162
170
|
const sap_transfer = {
|
|
163
171
|
StockTransferID: body.serial_number.formatted,
|
|
164
172
|
SalesPersonCode: repzo_rep
|
|
165
173
|
? repzo_rep.integration_id
|
|
166
|
-
: (
|
|
174
|
+
: (_o = options.data) === null || _o === void 0
|
|
167
175
|
? void 0
|
|
168
|
-
:
|
|
176
|
+
: _o.SalesPersonCode,
|
|
169
177
|
FromWarehouse: body.from.code,
|
|
170
178
|
ToWarehouse: body.to.code,
|
|
171
179
|
RepzoStockTransferLines: variants,
|
|
@@ -204,23 +212,23 @@ export const create_transfer = async (event, options) => {
|
|
|
204
212
|
console.error((e === null || e === void 0 ? void 0 : e.response) || e);
|
|
205
213
|
await actionLog.setStatus("fail", e).setBody(body).commit();
|
|
206
214
|
if (
|
|
207
|
-
(
|
|
208
|
-
(
|
|
215
|
+
(_q =
|
|
216
|
+
(_p =
|
|
209
217
|
options === null || options === void 0 ? void 0 : options.data) ===
|
|
210
|
-
null ||
|
|
218
|
+
null || _p === void 0
|
|
211
219
|
? void 0
|
|
212
|
-
:
|
|
220
|
+
: _p.transfers) === null || _q === void 0
|
|
213
221
|
? void 0
|
|
214
|
-
:
|
|
222
|
+
: _q.adjustInventoryInFailedTransfer
|
|
215
223
|
) {
|
|
216
224
|
send_command_to_marketplace({
|
|
217
225
|
command: "adjust_inventory",
|
|
218
226
|
app_id: options.app_id,
|
|
219
227
|
env: options.env,
|
|
220
228
|
repzoApiKey:
|
|
221
|
-
(
|
|
229
|
+
(_r = options.data) === null || _r === void 0
|
|
222
230
|
? void 0
|
|
223
|
-
:
|
|
231
|
+
: _r.repzoApiKey,
|
|
224
232
|
});
|
|
225
233
|
}
|
|
226
234
|
throw e;
|
package/lib/commands/product.js
CHANGED
|
@@ -224,6 +224,7 @@ export const sync_product = async (commandEvent) => {
|
|
|
224
224
|
const body = {
|
|
225
225
|
active: true,
|
|
226
226
|
name: sap_product.ITEMDESC,
|
|
227
|
+
local_name: sap_product.ITEMDESCF,
|
|
227
228
|
barcode: sap_product.ITEMBARCODE,
|
|
228
229
|
sku: sap_product.ITEMCODE,
|
|
229
230
|
sv_tax: product_tax,
|
package/package.json
CHANGED
|
@@ -33,13 +33,13 @@ 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
44
|
// try {
|
|
45
45
|
// if (body?._id) {
|
package/src/commands/product.ts
CHANGED
|
@@ -186,6 +186,7 @@ export const sync_product = async (commandEvent: CommandEvent) => {
|
|
|
186
186
|
{
|
|
187
187
|
active: true,
|
|
188
188
|
name: sap_product.ITEMDESC,
|
|
189
|
+
local_name: sap_product.ITEMDESCF,
|
|
189
190
|
barcode: sap_product.ITEMBARCODE,
|
|
190
191
|
sku: sap_product.ITEMCODE,
|
|
191
192
|
sv_tax: product_tax,
|