@darkpos/pricing 1.0.46 → 1.0.47

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.
@@ -26,7 +26,11 @@ describe('addItem function', () => {
26
26
  };
27
27
 
28
28
  // Call the function
29
- const [updatedOrder, itemIndex, addedItem] = addItem({
29
+ const {
30
+ updatedOrder,
31
+ itemIndex,
32
+ item: addedItem,
33
+ } = addItem({
30
34
  order,
31
35
  item,
32
36
  itemIndex: -1, // No existing item in order
@@ -67,7 +71,11 @@ describe('addItem function', () => {
67
71
  };
68
72
 
69
73
  // Call the function
70
- const [updatedOrder, itemIndex, addedItem] = addItem({
74
+ const {
75
+ updatedOrder,
76
+ itemIndex,
77
+ item: addedItem,
78
+ } = addItem({
71
79
  order,
72
80
  item,
73
81
  itemIndex: -1, // Assuming no explicit index
@@ -99,7 +107,7 @@ describe('addItem function', () => {
99
107
  };
100
108
 
101
109
  // Call the function with an overridden quantity
102
- const [updatedOrder, , addedItem] = addItem({
110
+ const { updatedOrder, item: addedItem } = addItem({
103
111
  order,
104
112
  item,
105
113
  itemIndex: -1, // Assuming no explicit index
@@ -179,7 +187,7 @@ describe('addItem function', () => {
179
187
  };
180
188
 
181
189
  // Call the function
182
- const [updatedOrder] = addItem({
190
+ const { updatedOrder } = addItem({
183
191
  order,
184
192
  item,
185
193
  itemIndex: -1, // Assuming no explicit index
@@ -187,6 +187,7 @@ module.exports = ({ actions, itemActions, modifierActions, settings, _ }) => {
187
187
  !_.isEmpty(orderItem.modifiers)
188
188
  )
189
189
  requiredModifiers = getUnselectedModifiers(orderItem, requiredModifiers);
190
+
190
191
  if (!_.isEmpty(requiredModifiers)) {
191
192
  modifiersToAdd.push(
192
193
  ...requiredModifiers.filter(
@@ -213,17 +214,23 @@ module.exports = ({ actions, itemActions, modifierActions, settings, _ }) => {
213
214
  let [nextOrder, nextItemIndex] = params;
214
215
  const [, , nextItem] = params;
215
216
 
217
+ const overrideModifiers = modifiersToAdd.filter(modToAdd =>
218
+ modifierActions.isOverride(modToAdd)
219
+ );
220
+
216
221
  if (modifiersToAdd.length) {
217
- nextOrder = modifiersToAdd.reduce(
218
- (acc, modifier) =>
219
- actions.addItemModifier({
220
- itemIndex: nextItemIndex,
221
- order: acc,
222
- modifier,
223
- cache,
224
- }),
225
- nextOrder
226
- );
222
+ nextOrder = modifiersToAdd
223
+ .filter(modToAdd => !modifierActions.isOverride(modToAdd))
224
+ .reduce(
225
+ (acc, modifier) =>
226
+ actions.addItemModifier({
227
+ itemIndex: nextItemIndex,
228
+ order: acc,
229
+ modifier,
230
+ cache,
231
+ }),
232
+ nextOrder
233
+ );
227
234
  }
228
235
 
229
236
  const { reArrangedOrder, newIndex } = reArrangeNewItem({
@@ -243,6 +250,11 @@ module.exports = ({ actions, itemActions, modifierActions, settings, _ }) => {
243
250
  nextOrder.items.splice(idxToRemove, 1);
244
251
  }
245
252
 
246
- return [nextOrder, nextItemIndex, nextItem];
253
+ return {
254
+ updatedOrder: nextOrder,
255
+ itemIndex: nextItemIndex,
256
+ item: nextItem,
257
+ overrideModifiers,
258
+ };
247
259
  };
248
260
  };
@@ -244,7 +244,7 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
244
244
 
245
245
  if (modifierActions.hasRelatedItems(modifier)) {
246
246
  order = modifier.properties.group.items.reduce((acc, each) => {
247
- const [nextOrder] = actions.addItem({
247
+ const { updatedOrder: nextOrder } = actions.addItem({
248
248
  item: {
249
249
  ...each,
250
250
  itemId: each._id,
@@ -14,7 +14,7 @@ module.exports = ({ actions, settings, _ }) => {
14
14
  const updatedQuantity = reset
15
15
  ? quantity
16
16
  : parseInt(`${item.quantity}${quantity}`, 10);
17
- return actions.updateItem({
17
+ const { updatedOrder } = actions.updateItem({
18
18
  order,
19
19
  itemIndex,
20
20
  item: {
@@ -22,6 +22,7 @@ module.exports = ({ actions, settings, _ }) => {
22
22
  quantity: updatedQuantity,
23
23
  },
24
24
  });
25
+ return updatedOrder;
25
26
  }
26
27
  if (isBefore) {
27
28
  return actions.addItem({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -39,5 +39,5 @@
39
39
  "supertest": "^6.2.3",
40
40
  "supervisor": "^0.12.0"
41
41
  },
42
- "gitHead": "e048578555dc3d2147bbc4e5b4e0d55809261dcc"
42
+ "gitHead": "98185abdf0b1e4c22098c17b8eb1fde30c673093"
43
43
  }