repzo-sap-absjo 1.0.39 → 1.0.40
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_proforma.js +42 -3
- package/lib/commands/channel.js +17 -12
- package/lib/commands/client.js +29 -24
- package/lib/commands/client_disabled.js +15 -10
- package/lib/commands/payment_term.js +17 -12
- package/lib/commands/price_list.js +65 -56
- package/lib/commands/product.js +63 -54
- package/lib/commands/product_disabled.js +13 -6
- package/lib/commands/rep.js +13 -5
- package/lib/commands/warehouse.js +25 -21
- package/lib/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/create_proforma.ts +14 -1
- package/src/commands/channel.ts +2 -2
- package/src/commands/client.ts +2 -2
- package/src/commands/client_disabled.ts +2 -2
- package/src/commands/payment_term.ts +2 -2
- package/src/commands/price_list.ts +2 -2
- package/src/commands/product.ts +2 -2
- package/src/commands/product_disabled.ts +2 -2
- package/src/commands/rep.ts +7 -1
- package/src/commands/warehouse.ts +2 -2
- package/src/types.ts +1 -1
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
set_error,
|
|
8
8
|
} from "../util.js";
|
|
9
9
|
export const sync_warehouse = async (commandEvent) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
11
11
|
const repzo = new Repzo(
|
|
12
12
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
13
13
|
? void 0
|
|
@@ -43,28 +43,32 @@ export const sync_warehouse = async (commandEvent) => {
|
|
|
43
43
|
{
|
|
44
44
|
updateAt:
|
|
45
45
|
commandEvent.app.formData.warehouseDefaultUpdateDate ||
|
|
46
|
-
commandEvent.app.options_formData
|
|
46
|
+
((_b = commandEvent.app.options_formData) === null || _b === void 0
|
|
47
|
+
? void 0
|
|
48
|
+
: _b[bench_time_key]),
|
|
47
49
|
}
|
|
48
50
|
);
|
|
49
51
|
result.sap_total =
|
|
50
|
-
(
|
|
52
|
+
(_c =
|
|
51
53
|
sap_warehouses === null || sap_warehouses === void 0
|
|
52
54
|
? void 0
|
|
53
|
-
: sap_warehouses.Warehouses) === null ||
|
|
55
|
+
: sap_warehouses.Warehouses) === null || _c === void 0
|
|
54
56
|
? void 0
|
|
55
|
-
:
|
|
57
|
+
: _c.length;
|
|
56
58
|
await commandLog
|
|
57
59
|
.addDetail(
|
|
58
60
|
`${
|
|
59
|
-
(
|
|
61
|
+
(_d =
|
|
60
62
|
sap_warehouses === null || sap_warehouses === void 0
|
|
61
63
|
? void 0
|
|
62
|
-
: sap_warehouses.Warehouses) === null ||
|
|
64
|
+
: sap_warehouses.Warehouses) === null || _d === void 0
|
|
63
65
|
? void 0
|
|
64
|
-
:
|
|
66
|
+
: _d.length
|
|
65
67
|
} warehouses changed since ${
|
|
66
68
|
commandEvent.app.formData.warehouseDefaultUpdateDate ||
|
|
67
|
-
commandEvent.app.options_formData
|
|
69
|
+
((_e = commandEvent.app.options_formData) === null || _e === void 0
|
|
70
|
+
? void 0
|
|
71
|
+
: _e[bench_time_key]) ||
|
|
68
72
|
"ever"
|
|
69
73
|
}`
|
|
70
74
|
)
|
|
@@ -81,33 +85,33 @@ export const sync_warehouse = async (commandEvent) => {
|
|
|
81
85
|
);
|
|
82
86
|
const repzo_warehouses = await repzo.warehouse.find({ per_page: 50000 });
|
|
83
87
|
result.repzo_total =
|
|
84
|
-
(
|
|
88
|
+
(_f =
|
|
85
89
|
repzo_warehouses === null || repzo_warehouses === void 0
|
|
86
90
|
? void 0
|
|
87
|
-
: repzo_warehouses.data) === null ||
|
|
91
|
+
: repzo_warehouses.data) === null || _f === void 0
|
|
88
92
|
? void 0
|
|
89
|
-
:
|
|
93
|
+
: _f.length;
|
|
90
94
|
await commandLog
|
|
91
95
|
.addDetail(
|
|
92
96
|
`${
|
|
93
|
-
(
|
|
97
|
+
(_g =
|
|
94
98
|
repzo_warehouses === null || repzo_warehouses === void 0
|
|
95
99
|
? void 0
|
|
96
|
-
: repzo_warehouses.data) === null ||
|
|
100
|
+
: repzo_warehouses.data) === null || _g === void 0
|
|
97
101
|
? void 0
|
|
98
|
-
:
|
|
102
|
+
: _g.length
|
|
99
103
|
} warehouses in Repzo`
|
|
100
104
|
)
|
|
101
105
|
.commit();
|
|
102
106
|
for (
|
|
103
107
|
let i = 0;
|
|
104
108
|
i <
|
|
105
|
-
((
|
|
109
|
+
((_h =
|
|
106
110
|
sap_warehouses === null || sap_warehouses === void 0
|
|
107
111
|
? void 0
|
|
108
|
-
: sap_warehouses.Warehouses) === null ||
|
|
112
|
+
: sap_warehouses.Warehouses) === null || _h === void 0
|
|
109
113
|
? void 0
|
|
110
|
-
:
|
|
114
|
+
: _h.length);
|
|
111
115
|
i++
|
|
112
116
|
) {
|
|
113
117
|
const sap_warehouse = sap_warehouses.Warehouses[i];
|
|
@@ -191,10 +195,10 @@ export const sync_warehouse = async (commandEvent) => {
|
|
|
191
195
|
} catch (e) {
|
|
192
196
|
//@ts-ignore
|
|
193
197
|
console.error(
|
|
194
|
-
((
|
|
195
|
-
|
|
198
|
+
((_j = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
199
|
+
_j === void 0
|
|
196
200
|
? void 0
|
|
197
|
-
:
|
|
201
|
+
: _j.data) || e
|
|
198
202
|
);
|
|
199
203
|
await commandLog.setStatus("fail", e).commit();
|
|
200
204
|
throw e === null || e === void 0 ? void 0 : e.response;
|
package/lib/types.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ interface OptionsFormData {
|
|
|
136
136
|
interface AppWithCustomFormData
|
|
137
137
|
extends Service.App.Schema_with_populated_AvailableApp {
|
|
138
138
|
formData: FormData;
|
|
139
|
-
options_formData
|
|
139
|
+
options_formData?: OptionsFormData;
|
|
140
140
|
}
|
|
141
141
|
export interface CommandEvent {
|
|
142
142
|
app: AppWithCustomFormData;
|
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.
|
|
4
|
+
"version": "1.0.40",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"jsonwebtoken": "^8.5.1",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"moment-timezone": "^0.5.34",
|
|
48
|
-
"repzo": "^1.0.
|
|
48
|
+
"repzo": "^1.0.184",
|
|
49
49
|
"uuid": "^8.3.2"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
_update,
|
|
7
7
|
_delete,
|
|
8
8
|
getUniqueConcatenatedValues,
|
|
9
|
+
set_error,
|
|
9
10
|
} from "../util.js";
|
|
10
11
|
import { Service } from "repzo/src/types";
|
|
11
12
|
import { v4 as uuid } from "uuid";
|
|
@@ -248,7 +249,19 @@ export const create_proforma = async (event: EVENT, options: Config) => {
|
|
|
248
249
|
sap_invoice
|
|
249
250
|
); // .commit();
|
|
250
251
|
|
|
251
|
-
|
|
252
|
+
let result;
|
|
253
|
+
try {
|
|
254
|
+
result = await _create(SAP_HOST_URL, "/AddOrder", sap_invoice);
|
|
255
|
+
} catch (e: any) {
|
|
256
|
+
if (
|
|
257
|
+
typeof set_error(e)?.message === "string" &&
|
|
258
|
+
set_error(e)?.message?.includes("this Sales Order is allready existed")
|
|
259
|
+
) {
|
|
260
|
+
result = { success: true, message: "Sales Order already exists" };
|
|
261
|
+
} else {
|
|
262
|
+
throw e;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
252
265
|
|
|
253
266
|
// console.log(result);
|
|
254
267
|
|
package/src/commands/channel.ts
CHANGED
|
@@ -83,7 +83,7 @@ export const sync_channel = async (commandEvent: CommandEvent) => {
|
|
|
83
83
|
const sap_clients: SAPClient[] = await get_sap_clients(
|
|
84
84
|
commandEvent.app.formData.sapHostUrl,
|
|
85
85
|
{
|
|
86
|
-
updateAt: commandEvent.app.options_formData[bench_time_key],
|
|
86
|
+
updateAt: commandEvent.app.options_formData?.[bench_time_key],
|
|
87
87
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
88
88
|
}
|
|
89
89
|
);
|
|
@@ -100,7 +100,7 @@ export const sync_channel = async (commandEvent: CommandEvent) => {
|
|
|
100
100
|
await commandLog
|
|
101
101
|
.addDetail(
|
|
102
102
|
`${result.sap_total} Client Channels in SAP changed since ${
|
|
103
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
103
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
104
104
|
}`
|
|
105
105
|
)
|
|
106
106
|
.commit();
|
package/src/commands/client.ts
CHANGED
|
@@ -81,7 +81,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
|
|
|
81
81
|
const sap_clients: SAPClient[] = await get_sap_clients(
|
|
82
82
|
commandEvent.app.formData.sapHostUrl,
|
|
83
83
|
{
|
|
84
|
-
updateAt: commandEvent.app.options_formData[bench_time_key],
|
|
84
|
+
updateAt: commandEvent.app.options_formData?.[bench_time_key],
|
|
85
85
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
86
86
|
}
|
|
87
87
|
);
|
|
@@ -89,7 +89,7 @@ export const sync_client = async (commandEvent: CommandEvent) => {
|
|
|
89
89
|
await commandLog
|
|
90
90
|
.addDetail(
|
|
91
91
|
`${result.sap_total} Customers in SAP changed since ${
|
|
92
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
92
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
93
93
|
}`
|
|
94
94
|
)
|
|
95
95
|
.commit();
|
|
@@ -48,7 +48,7 @@ export const sync_disabled_client = async (commandEvent: CommandEvent) => {
|
|
|
48
48
|
const sap_disabled_clients: SAPClient[] = await get_sap_clients(
|
|
49
49
|
commandEvent.app.formData.sapHostUrl,
|
|
50
50
|
{
|
|
51
|
-
updateAt: commandEvent.app.options_formData[bench_time_key],
|
|
51
|
+
updateAt: commandEvent.app.options_formData?.[bench_time_key],
|
|
52
52
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
53
53
|
}
|
|
54
54
|
);
|
|
@@ -57,7 +57,7 @@ export const sync_disabled_client = async (commandEvent: CommandEvent) => {
|
|
|
57
57
|
await commandLog
|
|
58
58
|
.addDetail(
|
|
59
59
|
`${result.sap_total} Disabled Clients in SAP changed since ${
|
|
60
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
60
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
61
61
|
}`
|
|
62
62
|
)
|
|
63
63
|
.commit();
|
|
@@ -83,7 +83,7 @@ export const sync_payment_term = async (commandEvent: CommandEvent) => {
|
|
|
83
83
|
const sap_clients: SAPClient[] = await get_sap_clients(
|
|
84
84
|
commandEvent.app.formData.sapHostUrl,
|
|
85
85
|
{
|
|
86
|
-
updateAt: commandEvent.app.options_formData[bench_time_key],
|
|
86
|
+
updateAt: commandEvent.app.options_formData?.[bench_time_key],
|
|
87
87
|
GroupCode: commandEvent.app.formData.GroupCode,
|
|
88
88
|
}
|
|
89
89
|
);
|
|
@@ -100,7 +100,7 @@ export const sync_payment_term = async (commandEvent: CommandEvent) => {
|
|
|
100
100
|
await commandLog
|
|
101
101
|
.addDetail(
|
|
102
102
|
`${result.sap_total} Payments Term in SAP changed since ${
|
|
103
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
103
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
104
104
|
}`
|
|
105
105
|
)
|
|
106
106
|
.commit();
|
|
@@ -64,14 +64,14 @@ export const sync_price_list = async (commandEvent: CommandEvent) => {
|
|
|
64
64
|
// Get SAP Price Lists
|
|
65
65
|
const sap_price_lists: SAPPriceListItem[] = await get_sap_price_list(
|
|
66
66
|
commandEvent.app.formData.sapHostUrl,
|
|
67
|
-
{ updateAt: commandEvent.app.options_formData[bench_time_key] }
|
|
67
|
+
{ updateAt: commandEvent.app.options_formData?.[bench_time_key] }
|
|
68
68
|
);
|
|
69
69
|
result.sap_total = sap_price_lists?.length;
|
|
70
70
|
|
|
71
71
|
await commandLog
|
|
72
72
|
.addDetail(
|
|
73
73
|
`${result.sap_total} Price Lists in SAP changed since ${
|
|
74
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
74
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
75
75
|
}`
|
|
76
76
|
)
|
|
77
77
|
.commit();
|
package/src/commands/product.ts
CHANGED
|
@@ -85,14 +85,14 @@ export const sync_product = async (commandEvent: CommandEvent) => {
|
|
|
85
85
|
|
|
86
86
|
const sap_products: SAPProduct[] = await get_sap_products(
|
|
87
87
|
commandEvent.app.formData.sapHostUrl,
|
|
88
|
-
{ updateAt: commandEvent.app.options_formData[bench_time_key] }
|
|
88
|
+
{ updateAt: commandEvent.app.options_formData?.[bench_time_key] }
|
|
89
89
|
);
|
|
90
90
|
result.sap_total = sap_products?.length;
|
|
91
91
|
|
|
92
92
|
await commandLog
|
|
93
93
|
.addDetail(
|
|
94
94
|
`${result.sap_total} Items in SAP changed since ${
|
|
95
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
95
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
96
96
|
}`
|
|
97
97
|
)
|
|
98
98
|
.commit();
|
|
@@ -46,14 +46,14 @@ export const sync_disabled_product = async (commandEvent: CommandEvent) => {
|
|
|
46
46
|
|
|
47
47
|
const sap_products: SAPProduct[] = await get_sap_disabled_products(
|
|
48
48
|
commandEvent.app.formData.sapHostUrl,
|
|
49
|
-
{ updateAt: commandEvent.app.options_formData[bench_time_key] }
|
|
49
|
+
{ updateAt: commandEvent.app.options_formData?.[bench_time_key] }
|
|
50
50
|
);
|
|
51
51
|
result.sap_total = sap_products?.length;
|
|
52
52
|
|
|
53
53
|
await commandLog
|
|
54
54
|
.addDetail(
|
|
55
55
|
`${result.sap_total} Disabled Products in SAP changed since ${
|
|
56
|
-
commandEvent.app.options_formData[bench_time_key] || "ever"
|
|
56
|
+
commandEvent.app.options_formData?.[bench_time_key] || "ever"
|
|
57
57
|
}`
|
|
58
58
|
)
|
|
59
59
|
.commit();
|
package/src/commands/rep.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface SAPRep {
|
|
|
19
19
|
USERCASHACCOUNT: string; // "124020002";
|
|
20
20
|
USERCHECKACCTCODE: string; // "124020003";
|
|
21
21
|
USERWHSCODE: string; // "MToffers";
|
|
22
|
+
INVOICESTATUS: "Y" | "N";
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface SAPReps {
|
|
@@ -36,7 +37,7 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
36
37
|
commandEvent.command
|
|
37
38
|
);
|
|
38
39
|
try {
|
|
39
|
-
|
|
40
|
+
console.log("sync_rep");
|
|
40
41
|
|
|
41
42
|
const new_bench_time = new Date().toISOString();
|
|
42
43
|
const bench_time_key = "bench_time_rep";
|
|
@@ -84,6 +85,7 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
84
85
|
USERCASHACCOUNT: true,
|
|
85
86
|
USERCHECKACCTCODE: true,
|
|
86
87
|
USERWHSCODE: true,
|
|
88
|
+
INVOICESTATUS: true,
|
|
87
89
|
});
|
|
88
90
|
db.load(sap_reps?.Users);
|
|
89
91
|
|
|
@@ -125,10 +127,13 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
125
127
|
USERCASHACCOUNT: sap_rep.USERCASHACCOUNT,
|
|
126
128
|
USERCHECKACCTCODE: sap_rep.USERCHECKACCTCODE,
|
|
127
129
|
USERWHSCODE: sap_rep.USERWHSCODE,
|
|
130
|
+
INVOICESTATUS: sap_rep.INVOICESTATUS,
|
|
128
131
|
id: `${nameSpace}_${sap_rep.USERID}`,
|
|
129
132
|
},
|
|
130
133
|
assigned_warehouse: warehouse,
|
|
131
134
|
company_namespace: [nameSpace],
|
|
135
|
+
"settings.treating_invoice_as_proforma_for_etax":
|
|
136
|
+
sap_rep.INVOICESTATUS === "N" ? true : false,
|
|
132
137
|
};
|
|
133
138
|
|
|
134
139
|
if (!repzo_rep) {
|
|
@@ -155,6 +160,7 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
155
160
|
USERCASHACCOUNT: repzo_rep.integration_meta?.USERCASHACCOUNT,
|
|
156
161
|
USERCHECKACCTCODE: repzo_rep.integration_meta?.USERCHECKACCTCODE,
|
|
157
162
|
USERWHSCODE: repzo_rep.integration_meta?.USERWHSCODE,
|
|
163
|
+
INVOICESTATUS: repzo_rep.integration_meta?.INVOICESTATUS,
|
|
158
164
|
});
|
|
159
165
|
if (found_identical_docs.length) continue;
|
|
160
166
|
// Update
|
|
@@ -68,7 +68,7 @@ export const sync_warehouse = async (commandEvent: CommandEvent) => {
|
|
|
68
68
|
{
|
|
69
69
|
updateAt:
|
|
70
70
|
commandEvent.app.formData.warehouseDefaultUpdateDate ||
|
|
71
|
-
commandEvent.app.options_formData[bench_time_key],
|
|
71
|
+
commandEvent.app.options_formData?.[bench_time_key],
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
result.sap_total = sap_warehouses?.Warehouses?.length;
|
|
@@ -77,7 +77,7 @@ export const sync_warehouse = async (commandEvent: CommandEvent) => {
|
|
|
77
77
|
.addDetail(
|
|
78
78
|
`${sap_warehouses?.Warehouses?.length} warehouses changed since ${
|
|
79
79
|
commandEvent.app.formData.warehouseDefaultUpdateDate ||
|
|
80
|
-
commandEvent.app.options_formData[bench_time_key] ||
|
|
80
|
+
commandEvent.app.options_formData?.[bench_time_key] ||
|
|
81
81
|
"ever"
|
|
82
82
|
}`
|
|
83
83
|
)
|
package/src/types.ts
CHANGED
|
@@ -131,7 +131,7 @@ interface OptionsFormData {
|
|
|
131
131
|
interface AppWithCustomFormData
|
|
132
132
|
extends Service.App.Schema_with_populated_AvailableApp {
|
|
133
133
|
formData: FormData;
|
|
134
|
-
options_formData
|
|
134
|
+
options_formData?: OptionsFormData;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
export interface CommandEvent {
|