repzo-sap-absjo 1.0.23 → 1.0.25
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 +2 -0
- package/lib/commands/measureunit.js +8 -3
- package/lib/commands/product.js +1 -1
- package/lib/commands/rep.js +24 -25
- package/lib/commands/tax.js +1 -1
- package/lib/test/actions/create_invoice.js +1 -1
- package/lib/test/actions/create_payment.js +1 -1
- package/lib/test/actions/create_proforma.js +1 -1
- package/lib/test/actions/create_return_invoice.js +1 -1
- package/lib/test/actions/create_transfer.js +1 -1
- package/lib/test/commands/brand.js +1 -1
- package/lib/test/commands/category.js +1 -1
- package/lib/test/commands/channel.js +1 -1
- package/lib/test/commands/payment_term.js +1 -1
- package/lib/test/commands/price_list.js +1 -1
- package/lib/test/commands/price_list_disabled.js +1 -1
- package/lib/test/commands/warehouse.js +1 -1
- package/lib/util.js +33 -1
- package/package.json +1 -1
- package/src/commands/measureunit.ts +17 -11
- package/src/commands/rep.ts +11 -4
- package/src/util.ts +11 -0
package/changelog.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
- [util] in method: getUniqueConcatenatedValues, also add the promotions for items.buy @maramalshen
|
|
7
8
|
- [actions/***] add 2 keys in integration_meta: sync_to_sap_started & sync_to_sap_succeeded @maramalshen
|
|
8
9
|
- [commands/product] assign Foreign Name (ITEMDESCF) in SAP to local_name in Repzo @maramalshen
|
|
9
10
|
- [actions/payment] add the field UserId where it equals USERID of the SAP API REP @maramalshen
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
|
|
18
19
|
### Fixed
|
|
19
20
|
|
|
21
|
+
- [command/measureunit] if product has multi measureUnits, the base_measureunit should be PC, POUCH or CARD @maramalshen
|
|
20
22
|
- [command/measureunit-family] use _.xor instead or _.difference @maramalshen
|
|
21
23
|
- [command/price_list] fix bug in priceList-item @maramalshen
|
|
22
24
|
- [actions/**] don't update integration_meta.sync_to_sap_succeeded if it is already true @maramalshen
|
|
@@ -101,9 +101,14 @@ export const sync_measureunit = async (commandEvent) => {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
if (max_unit.sap_product_UoMs.length > 1) {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const PC = max_unit.sap_product_UoMs.find((u) => u.ALTUOMCODE == "PC");
|
|
105
|
+
const POUCH = max_unit.sap_product_UoMs.find(
|
|
106
|
+
(u) => u.ALTUOMCODE == "POUCH"
|
|
106
107
|
);
|
|
108
|
+
const CARD = max_unit.sap_product_UoMs.find(
|
|
109
|
+
(u) => u.ALTUOMCODE == "CARD"
|
|
110
|
+
);
|
|
111
|
+
max_unit.default_unit = PC || POUCH || CARD;
|
|
107
112
|
if (!max_unit.default_unit) {
|
|
108
113
|
// console.log(
|
|
109
114
|
// "Create/Update Measure Unit Failed >> ",
|
|
@@ -197,7 +202,7 @@ export const sync_measureunit = async (commandEvent) => {
|
|
|
197
202
|
const body = {
|
|
198
203
|
parent: repzo_parent_id,
|
|
199
204
|
name: sap_UoM.ALTUOMCODE,
|
|
200
|
-
factor: sap_UoM.repzo_factor || 0,
|
|
205
|
+
factor: sap_UoM.repzo_factor || 0,
|
|
201
206
|
disabled: false,
|
|
202
207
|
integration_meta: {
|
|
203
208
|
id: `${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
|
package/lib/commands/product.js
CHANGED
|
@@ -299,7 +299,7 @@ export const sync_product = async (commandEvent) => {
|
|
|
299
299
|
{
|
|
300
300
|
disabled: false,
|
|
301
301
|
name: sap_product.ITEMCODE,
|
|
302
|
-
price: 0,
|
|
302
|
+
price: 0,
|
|
303
303
|
integration_meta: {
|
|
304
304
|
id: `${nameSpace}_${sap_product.ITEMCODE}`,
|
|
305
305
|
ITEMCODE: sap_product.ITEMCODE,
|
package/lib/commands/rep.js
CHANGED
|
@@ -2,7 +2,7 @@ import Repzo from "repzo";
|
|
|
2
2
|
import DataSet from "data-set-query";
|
|
3
3
|
import { _create, update_bench_time, set_error } from "../util.js";
|
|
4
4
|
export const sync_rep = async (commandEvent) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6
6
|
const repzo = new Repzo(
|
|
7
7
|
(_a = commandEvent.app.formData) === null || _a === void 0
|
|
8
8
|
? void 0
|
|
@@ -85,6 +85,11 @@ export const sync_rep = async (commandEvent) => {
|
|
|
85
85
|
} reps in Repzo`
|
|
86
86
|
)
|
|
87
87
|
.commit();
|
|
88
|
+
// Get Repzo Warehouse
|
|
89
|
+
const repzo_warehouses = await repzo.warehouse.find({
|
|
90
|
+
per_page: 50000,
|
|
91
|
+
disabled: false,
|
|
92
|
+
});
|
|
88
93
|
for (
|
|
89
94
|
let i = 0;
|
|
90
95
|
i <
|
|
@@ -106,27 +111,21 @@ export const sync_rep = async (commandEvent) => {
|
|
|
106
111
|
});
|
|
107
112
|
let warehouse;
|
|
108
113
|
if (sap_rep.USERWHSCODE && sap_rep.USERWHSCODE != "") {
|
|
109
|
-
const warehouse_res =
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
if (
|
|
113
|
-
(_f =
|
|
114
|
-
warehouse_res === null || warehouse_res === void 0
|
|
115
|
-
? void 0
|
|
116
|
-
: warehouse_res.data) === null || _f === void 0
|
|
114
|
+
const warehouse_res =
|
|
115
|
+
repzo_warehouses === null || repzo_warehouses === void 0
|
|
117
116
|
? void 0
|
|
118
|
-
:
|
|
119
|
-
)
|
|
120
|
-
|
|
117
|
+
: repzo_warehouses.data.find((w) => w.code == sap_rep.USERWHSCODE);
|
|
118
|
+
// await repzo.warehouse.find({ code: sap_rep.USERWHSCODE });
|
|
119
|
+
if (warehouse_res) warehouse = warehouse_res._id;
|
|
121
120
|
}
|
|
122
121
|
const body = {
|
|
123
122
|
name: sap_rep.USERDESC,
|
|
124
123
|
password: Math.round(Math.random() * (9999 - 1000) + 1000).toString(),
|
|
125
124
|
username: nameSpace + sap_rep.USERID,
|
|
126
125
|
integration_id:
|
|
127
|
-
(
|
|
126
|
+
(_f = sap_rep.USERID) === null || _f === void 0
|
|
128
127
|
? void 0
|
|
129
|
-
:
|
|
128
|
+
: _f.toString(),
|
|
130
129
|
integration_meta: {
|
|
131
130
|
DEPARTMENTCODE: sap_rep.DEPARTMENTCODE,
|
|
132
131
|
USERCASHACCOUNT: sap_rep.USERCASHACCOUNT,
|
|
@@ -156,21 +155,21 @@ export const sync_rep = async (commandEvent) => {
|
|
|
156
155
|
USERID: repzo_rep.integration_id,
|
|
157
156
|
USERDESC: repzo_rep.name,
|
|
158
157
|
DEPARTMENTCODE:
|
|
159
|
-
(
|
|
158
|
+
(_g = repzo_rep.integration_meta) === null || _g === void 0
|
|
160
159
|
? void 0
|
|
161
|
-
:
|
|
160
|
+
: _g.DEPARTMENTCODE,
|
|
162
161
|
USERCASHACCOUNT:
|
|
163
|
-
(
|
|
162
|
+
(_h = repzo_rep.integration_meta) === null || _h === void 0
|
|
164
163
|
? void 0
|
|
165
|
-
:
|
|
164
|
+
: _h.USERCASHACCOUNT,
|
|
166
165
|
USERCHECKACCTCODE:
|
|
167
|
-
(
|
|
166
|
+
(_j = repzo_rep.integration_meta) === null || _j === void 0
|
|
168
167
|
? void 0
|
|
169
|
-
:
|
|
168
|
+
: _j.USERCHECKACCTCODE,
|
|
170
169
|
USERWHSCODE:
|
|
171
|
-
(
|
|
170
|
+
(_k = repzo_rep.integration_meta) === null || _k === void 0
|
|
172
171
|
? void 0
|
|
173
|
-
:
|
|
172
|
+
: _k.USERWHSCODE,
|
|
174
173
|
});
|
|
175
174
|
if (found_identical_docs.length) continue;
|
|
176
175
|
// Update
|
|
@@ -212,10 +211,10 @@ export const sync_rep = async (commandEvent) => {
|
|
|
212
211
|
} catch (e) {
|
|
213
212
|
//@ts-ignore
|
|
214
213
|
console.error(
|
|
215
|
-
((
|
|
216
|
-
|
|
214
|
+
((_l = e === null || e === void 0 ? void 0 : e.response) === null ||
|
|
215
|
+
_l === void 0
|
|
217
216
|
? void 0
|
|
218
|
-
:
|
|
217
|
+
: _l.data) || e
|
|
219
218
|
);
|
|
220
219
|
await commandLog.setStatus("fail", e).commit();
|
|
221
220
|
throw e;
|
package/lib/commands/tax.js
CHANGED
|
@@ -96,7 +96,7 @@ export const sync_tax = async (commandEvent) => {
|
|
|
96
96
|
const body = {
|
|
97
97
|
name: sap_tax.TaxName,
|
|
98
98
|
rate: Number(sap_tax.TaxRate / 100),
|
|
99
|
-
type: "additive",
|
|
99
|
+
type: "additive",
|
|
100
100
|
disabled: sap_tax.Inactive === "N" ? false : true,
|
|
101
101
|
integration_meta: {
|
|
102
102
|
id: `${nameSpace}_${sap_tax.TaxCode}`,
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_invoice",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000001",
|
|
9
|
+
action_sync_id: "Actions-0000001",
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_payment",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000004",
|
|
9
|
+
action_sync_id: "Actions-0000004",
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_proforma",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000003",
|
|
9
|
+
action_sync_id: "Actions-0000003",
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_return_invoice",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000002",
|
|
9
|
+
action_sync_id: "Actions-0000002",
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -6,7 +6,7 @@ Actions(
|
|
|
6
6
|
rawPath: "/actions",
|
|
7
7
|
rawQueryString: "app=repzo-sap-absjo&action=create_transfer",
|
|
8
8
|
headers: {
|
|
9
|
-
action_sync_id: "Actions-0000005",
|
|
9
|
+
action_sync_id: "Actions-0000005",
|
|
10
10
|
accept: "*/*",
|
|
11
11
|
"accept-encoding": "gzip, deflate",
|
|
12
12
|
"content-length": "3658",
|
|
@@ -341,7 +341,7 @@ let commandEvent = {
|
|
|
341
341
|
timezone: "Asia/Amman",
|
|
342
342
|
meta: "",
|
|
343
343
|
env: "staging",
|
|
344
|
-
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767",
|
|
344
|
+
sync_id: "9811c42a-d26e-41e0-bee5-e75260c04767",
|
|
345
345
|
command: "price_list",
|
|
346
346
|
};
|
|
347
347
|
Commands(commandEvent);
|
|
@@ -353,7 +353,7 @@ let commandEvent = {
|
|
|
353
353
|
timezone: "Asia/Amman",
|
|
354
354
|
meta: "",
|
|
355
355
|
env: "staging",
|
|
356
|
-
sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54",
|
|
356
|
+
sync_id: "a7e620b6-c5a2-44f7-b44b-3599b3ea1b54",
|
|
357
357
|
command: "price_list_disabled",
|
|
358
358
|
};
|
|
359
359
|
Commands(commandEvent);
|
package/lib/util.js
CHANGED
|
@@ -198,7 +198,7 @@ export const getUniqueConcatenatedValues = function (
|
|
|
198
198
|
delimiter,
|
|
199
199
|
all_promos
|
|
200
200
|
) {
|
|
201
|
-
var _a, _b, _c;
|
|
201
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
202
202
|
item.general_promotions = item.general_promotions || [];
|
|
203
203
|
item.used_promotions = item.used_promotions || [];
|
|
204
204
|
const allPromotions = [...item.general_promotions, ...item.used_promotions];
|
|
@@ -212,6 +212,38 @@ export const getUniqueConcatenatedValues = function (
|
|
|
212
212
|
: _c.promotion;
|
|
213
213
|
if (promo_id && all_promos[promo_id])
|
|
214
214
|
allPromotions.push(all_promos[promo_id]);
|
|
215
|
+
} else if (
|
|
216
|
+
(_e =
|
|
217
|
+
(_d = item.promotions) === null || _d === void 0
|
|
218
|
+
? void 0
|
|
219
|
+
: _d.bookings) === null || _e === void 0
|
|
220
|
+
? void 0
|
|
221
|
+
: _e.length
|
|
222
|
+
) {
|
|
223
|
+
const promos = {};
|
|
224
|
+
(_g =
|
|
225
|
+
(_f = item.promotions) === null || _f === void 0
|
|
226
|
+
? void 0
|
|
227
|
+
: _f.bookings) === null || _g === void 0
|
|
228
|
+
? void 0
|
|
229
|
+
: _g.forEach((booking) => {
|
|
230
|
+
if (
|
|
231
|
+
booking === null || booking === void 0 ? void 0 : booking.promotion
|
|
232
|
+
) {
|
|
233
|
+
promos[
|
|
234
|
+
booking === null || booking === void 0
|
|
235
|
+
? void 0
|
|
236
|
+
: booking.promotion
|
|
237
|
+
] =
|
|
238
|
+
booking === null || booking === void 0
|
|
239
|
+
? void 0
|
|
240
|
+
: booking.promotion;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
for (let promo_id in promos) {
|
|
244
|
+
if (promo_id && all_promos[promo_id])
|
|
245
|
+
allPromotions.push(all_promos[promo_id]);
|
|
246
|
+
}
|
|
215
247
|
}
|
|
216
248
|
const uniqueValues = new Set(
|
|
217
249
|
allPromotions.map((promotion) => promotion[key]).filter((value) => value)
|
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
39
39
|
const commandLog = new Repzo.CommandLog(
|
|
40
40
|
repzo,
|
|
41
41
|
commandEvent.app,
|
|
42
|
-
commandEvent.command
|
|
42
|
+
commandEvent.command,
|
|
43
43
|
);
|
|
44
44
|
try {
|
|
45
45
|
// console.log("sync_measureunit");
|
|
@@ -64,7 +64,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
64
64
|
|
|
65
65
|
const sap_UoMs: SAPUoM[] = await get_sap_UoMs(
|
|
66
66
|
commandEvent.app.formData.sapHostUrl,
|
|
67
|
-
{}
|
|
67
|
+
{},
|
|
68
68
|
);
|
|
69
69
|
result.sap_total = sap_UoMs?.length;
|
|
70
70
|
|
|
@@ -114,9 +114,15 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
if (max_unit.sap_product_UoMs.length > 1) {
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const PC = max_unit.sap_product_UoMs.find((u) => u.ALTUOMCODE == "PC");
|
|
118
|
+
const POUCH = max_unit.sap_product_UoMs.find(
|
|
119
|
+
(u) => u.ALTUOMCODE == "POUCH",
|
|
119
120
|
);
|
|
121
|
+
const CARD = max_unit.sap_product_UoMs.find(
|
|
122
|
+
(u) => u.ALTUOMCODE == "CARD",
|
|
123
|
+
);
|
|
124
|
+
max_unit.default_unit = PC || POUCH || CARD;
|
|
125
|
+
|
|
120
126
|
if (!max_unit.default_unit) {
|
|
121
127
|
// console.log(
|
|
122
128
|
// "Create/Update Measure Unit Failed >> ",
|
|
@@ -129,7 +135,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
129
135
|
max_unit?.sap_product_UoMs[0]?.ITEMCODE || units[0]?.ITEMCODE,
|
|
130
136
|
doc: units,
|
|
131
137
|
error_message: set_error(
|
|
132
|
-
`Create/Update Measure Unit Failed >> ${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit
|
|
138
|
+
`Create/Update Measure Unit Failed >> ${max_unit?.sap_product_UoMs[0]?.ITEMCODE} Could not found the base_unit`,
|
|
133
139
|
),
|
|
134
140
|
});
|
|
135
141
|
result.failed++;
|
|
@@ -170,7 +176,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
170
176
|
const repzo_UoM = repzo_UoMs.data.find(
|
|
171
177
|
(r_UoM) =>
|
|
172
178
|
r_UoM.integration_meta?.id ==
|
|
173
|
-
`${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}
|
|
179
|
+
`${nameSpace}_${sap_UoM.UOMGROUPENTRY}_${sap_UoM.ALTUOMID}`,
|
|
174
180
|
);
|
|
175
181
|
|
|
176
182
|
const body:
|
|
@@ -192,7 +198,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
192
198
|
// Create
|
|
193
199
|
try {
|
|
194
200
|
const created_UoM = await repzo.measureunit.create(
|
|
195
|
-
body as Service.MeasureUnit.Create.Body
|
|
201
|
+
body as Service.MeasureUnit.Create.Body,
|
|
196
202
|
);
|
|
197
203
|
result.created++;
|
|
198
204
|
} catch (e: any) {
|
|
@@ -216,7 +222,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
216
222
|
try {
|
|
217
223
|
const updated_UoM = await repzo.measureunit.update(
|
|
218
224
|
repzo_UoM._id,
|
|
219
|
-
body as Service.MeasureUnit.Update.Body
|
|
225
|
+
body as Service.MeasureUnit.Update.Body,
|
|
220
226
|
);
|
|
221
227
|
result.updated++;
|
|
222
228
|
} catch (e: any) {
|
|
@@ -242,12 +248,12 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
242
248
|
repzo,
|
|
243
249
|
commandEvent.app._id,
|
|
244
250
|
bench_time_key,
|
|
245
|
-
new_bench_time
|
|
251
|
+
new_bench_time,
|
|
246
252
|
);
|
|
247
253
|
await commandLog
|
|
248
254
|
.setStatus(
|
|
249
255
|
"success",
|
|
250
|
-
failed_docs_report.length ? failed_docs_report : null
|
|
256
|
+
failed_docs_report.length ? failed_docs_report : null,
|
|
251
257
|
)
|
|
252
258
|
.setBody(result)
|
|
253
259
|
.commit();
|
|
@@ -262,7 +268,7 @@ export const sync_measureunit = async (commandEvent: CommandEvent) => {
|
|
|
262
268
|
|
|
263
269
|
export const get_sap_UoMs = async (
|
|
264
270
|
serviceEndPoint: string,
|
|
265
|
-
query?: { updateAt?: string }
|
|
271
|
+
query?: { updateAt?: string },
|
|
266
272
|
): Promise<SAPUoM[]> => {
|
|
267
273
|
try {
|
|
268
274
|
const sap_UoMs: SAPUoMs = await _create(serviceEndPoint, "/Uom", {
|
package/src/commands/rep.ts
CHANGED
|
@@ -93,6 +93,12 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
93
93
|
.addDetail(`${repzo_reps?.data?.length} reps in Repzo`)
|
|
94
94
|
.commit();
|
|
95
95
|
|
|
96
|
+
// Get Repzo Warehouse
|
|
97
|
+
const repzo_warehouses = await repzo.warehouse.find({
|
|
98
|
+
per_page: 50000,
|
|
99
|
+
disabled: false,
|
|
100
|
+
});
|
|
101
|
+
|
|
96
102
|
for (let i = 0; i < sap_reps?.Users?.length; i++) {
|
|
97
103
|
const sap_rep: SAPRep = sap_reps.Users[i];
|
|
98
104
|
const repzo_rep = repzo_reps.data.find(
|
|
@@ -102,10 +108,11 @@ export const sync_rep = async (commandEvent: CommandEvent) => {
|
|
|
102
108
|
|
|
103
109
|
let warehouse;
|
|
104
110
|
if (sap_rep.USERWHSCODE && sap_rep.USERWHSCODE != "") {
|
|
105
|
-
const warehouse_res =
|
|
106
|
-
code
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
const warehouse_res = repzo_warehouses?.data.find(
|
|
112
|
+
(w) => w.code == sap_rep.USERWHSCODE
|
|
113
|
+
);
|
|
114
|
+
// await repzo.warehouse.find({ code: sap_rep.USERWHSCODE });
|
|
115
|
+
if (warehouse_res) warehouse = warehouse_res._id;
|
|
109
116
|
}
|
|
110
117
|
|
|
111
118
|
const body: Service.Rep.Create.Body | Service.Rep.Update.Body = {
|
package/src/util.ts
CHANGED
|
@@ -260,6 +260,17 @@ export const getUniqueConcatenatedValues = function (
|
|
|
260
260
|
const promo_id = item.promotions.bookings?.[0]?.promotion;
|
|
261
261
|
if (promo_id && all_promos[promo_id])
|
|
262
262
|
allPromotions.push(all_promos[promo_id]);
|
|
263
|
+
} else if (item.promotions?.bookings?.length) {
|
|
264
|
+
const promos: { [promo_id: string]: string } = {};
|
|
265
|
+
item.promotions?.bookings?.forEach((booking) => {
|
|
266
|
+
if (booking?.promotion) {
|
|
267
|
+
promos[booking?.promotion] = booking?.promotion;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
for (let promo_id in promos) {
|
|
271
|
+
if (promo_id && all_promos[promo_id])
|
|
272
|
+
allPromotions.push(all_promos[promo_id]);
|
|
273
|
+
}
|
|
263
274
|
}
|
|
264
275
|
const uniqueValues = new Set(
|
|
265
276
|
allPromotions.map((promotion) => promotion[key]).filter((value) => value)
|