Skip to content

Commit 5e55e53

Browse files
author
VuXfi
committed
fix for search modifier
1 parent 4e97f0f commit 5e55e53

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

adapters/rms/RMSAdapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class RMSAdapter {
9292
const rmsGroupIds = currentRMSGroupsFlatTree.map((group) => group.rmsId);
9393
// Set all groups not in the list to inactive
9494
await Group.update({ where: { rmsId: { "!=": rmsGroupIds } } }, { isDeleted: true }).fetch();
95-
sails.log.debug("ADAPTER RMS > syncProducts Groups:", JSON.stringify(rmsGroupIds));
95+
sails.log.silly("ADAPTER RMS > syncProducts Groups:", JSON.stringify(rmsGroupIds));
9696
for (const group of currentRMSGroupsFlatTree) {
9797
emitter.emit("rms-sync:before-each-group-item", group);
9898
group.concept = group.concept ?? "origin";
@@ -117,7 +117,7 @@ class RMSAdapter {
117117
let createdProduct = await Dish.createOrUpdate(productData);
118118
// Set isDeleted for absent products in ERP
119119
await Dish.update({ id: { nin: allProductIds }, parentGroup: group.id }, { isDeleted: true }).fetch();
120-
sails.log.debug(`ADAPTER RMS > syncProducts sync Group [${group.id}] '${group.name}' dishes:`, JSON.stringify(productIds));
120+
sails.log.silly(`ADAPTER RMS > syncProducts sync Group [${group.id}] '${group.name}' dishes:`, JSON.stringify(productIds));
121121
const SKIP_LOAD_PRODUCT_IMAGES = (await Settings.get("SKIP_LOAD_PRODUCT_IMAGES")) ?? false;
122122
// Load images
123123
if (product.images && product.images.length && !SKIP_LOAD_PRODUCT_IMAGES) {

adapters/rms/RMSAdapter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default abstract class RMSAdapter {
123123
// Set all groups not in the list to inactive
124124
await Group.update({ where: { rmsId: { "!=": rmsGroupIds } } }, { isDeleted: true }).fetch();
125125

126-
sails.log.debug("ADAPTER RMS > syncProducts Groups:", JSON.stringify(rmsGroupIds))
126+
sails.log.silly("ADAPTER RMS > syncProducts Groups:", JSON.stringify(rmsGroupIds))
127127

128128
for (const group of currentRMSGroupsFlatTree) {
129129
emitter.emit("rms-sync:before-each-group-item", group);
@@ -157,7 +157,7 @@ export default abstract class RMSAdapter {
157157

158158
// Set isDeleted for absent products in ERP
159159
await Dish.update({id: { nin: allProductIds }, parentGroup: group.id}, {isDeleted: true}).fetch();
160-
sails.log.debug(`ADAPTER RMS > syncProducts sync Group [${group.id}] '${group.name}' dishes:`, JSON.stringify(productIds))
160+
sails.log.silly(`ADAPTER RMS > syncProducts sync Group [${group.id}] '${group.name}' dishes:`, JSON.stringify(productIds))
161161

162162
const SKIP_LOAD_PRODUCT_IMAGES = (await Settings.get("SKIP_LOAD_PRODUCT_IMAGES")) ?? false;
163163
// Load images

models/Order.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,11 @@ let Model = {
11521152
whereConditions.push({ id: selectedModifier.id });
11531153
}
11541154
if (selectedModifier.rmsId) {
1155-
whereConditions.push({ rmsId: selectedModifier.id });
11561155
whereConditions.push({ rmsId: selectedModifier.rmsId });
11571156
}
1157+
else {
1158+
whereConditions.push({ rmsId: selectedModifier.id });
1159+
}
11581160
let dishes = await Dish.find({
11591161
where: { or: whereConditions },
11601162
}).limit(2);
@@ -1169,9 +1171,10 @@ let Model = {
11691171
},
11701172
}).limit(1);
11711173
}
1172-
const modifierObj = dishes[0];
1174+
const old_modifierObj = (await Dish.find({ where: { or: [{ id: selectedModifier.id }, { rmsId: selectedModifier.id }] } }).limit(1))[0];
1175+
const modifierObj = dishes[0] || old_modifierObj;
11731176
if (!modifierObj) {
1174-
throw "Dish with id " + selectedModifier.id + " not found!";
1177+
throw "Modifier with id " + selectedModifier.id + " not found!";
11751178
}
11761179
// let opts: any = {}
11771180
// await emitter.emit("core:order-countcart-before-calc-modifier", modifier, modifierObj, opts);

models/Order.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,9 @@ let Model = {
14051405
}
14061406

14071407
if (selectedModifier.rmsId) {
1408-
whereConditions.push({ rmsId: selectedModifier.id });
14091408
whereConditions.push({ rmsId: selectedModifier.rmsId });
1409+
} else {
1410+
whereConditions.push({ rmsId: selectedModifier.id });
14101411
}
14111412

14121413
let dishes = await Dish.find({
@@ -1425,10 +1426,11 @@ let Model = {
14251426
}).limit(1);
14261427
}
14271428

1428-
const modifierObj = dishes[0];
1429+
const old_modifierObj = (await Dish.find({ where: { or: [{ id: selectedModifier.id }, { rmsId: selectedModifier.id }] } }).limit(1))[0];
1430+
const modifierObj = dishes[0] || old_modifierObj;
14291431

14301432
if (!modifierObj) {
1431-
throw "Dish with id " + selectedModifier.id + " not found!";
1433+
throw "Modifier with id " + selectedModifier.id + " not found!";
14321434
}
14331435

14341436
// let opts: any = {}

0 commit comments

Comments
 (0)