@darkpos/pricing 1.0.70 → 1.0.71

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.
@@ -356,12 +356,11 @@ describe('getModifierTags Function', () => {
356
356
 
357
357
  const result = pricingServiceGroupModifiers.item.getModifierTags({ item });
358
358
 
359
- expect(result).toHaveLength(3);
360
- expect(result[0].label.replace(/\s/g, '')).toEqual('1White');
361
- expect(result[1].label.replace(/\s/g, '')).toEqual(
359
+ expect(result).toHaveLength(2);
360
+ expect(result[0].label.replace(/\s/g, '')).toEqual(
362
361
  '1CRC5.10discount(-CRC5.10)'
363
362
  );
364
- expect(result[2].label.replace(/\s/g, '')).toEqual(
363
+ expect(result[1].label.replace(/\s/g, '')).toEqual(
365
364
  '1CRC37.50discount(-CRC37.50)'
366
365
  );
367
366
  });
@@ -3849,6 +3849,8 @@ test('getInvalidRequiredModifiers having related items', () => {
3849
3849
  delModifiers: [],
3850
3850
  },
3851
3851
  ],
3852
+ _id: '67dc63610c106ab7d481d7dd',
3853
+ itemId: '62cdbfd01ee1b4001932821a',
3852
3854
  };
3853
3855
  const otherItems = [
3854
3856
  {
@@ -3860,13 +3862,14 @@ test('getInvalidRequiredModifiers having related items', () => {
3860
3862
  parentId: '67dc63610c106ab7d481d7dd',
3861
3863
  includeParent: true,
3862
3864
  basePrice: 3,
3865
+ relatedItemId: '62cdbfd01ee1b4001932820e',
3863
3866
  },
3864
3867
  },
3865
3868
  ];
3866
3869
 
3867
3870
  const response = pricingService.item.getInvalidRequiredModifiers({
3868
3871
  item,
3869
- otherItems,
3872
+ relatedItems: otherItems,
3870
3873
  });
3871
3874
 
3872
3875
  expect(response.length).toBe(1);
@@ -1,5 +1,5 @@
1
1
  module.exports = ({ modifierActions, actions }) =>
2
- function getInvalidRequiredModifiers({ item, otherItems }) {
2
+ function getInvalidRequiredModifiers({ item, relatedItems }) {
3
3
  if (!item || !Array.isArray(item.modifiers)) return [];
4
4
  const invalidModifiers = [];
5
5
 
@@ -7,23 +7,7 @@ module.exports = ({ modifierActions, actions }) =>
7
7
  if (
8
8
  modifierActions.isRequired(modifier) &&
9
9
  modifierActions.isGroupOfModifiers(modifier) &&
10
- !item.modifiers
11
- .filter(mod => mod._id !== modifier._id)
12
- .some(itemModifier =>
13
- modifierActions.isRelatedModifier({
14
- _id: itemModifier.modifierId || itemModifier._id,
15
- modifier,
16
- })
17
- ) &&
18
- Array.isArray(otherItems) &&
19
- modifierActions.isGroupOfItems(modifier) &&
20
- !modifier.properties.group.items.some(relatedItem =>
21
- otherItems.some(
22
- otherItem =>
23
- actions.isRelatedItem(otherItem) &&
24
- otherItem.itemId === relatedItem._id
25
- )
26
- )
10
+ !actions.hasModifier({ item, modifier, relatedItems })
27
11
  ) {
28
12
  invalidModifiers.push(modifier);
29
13
  }
@@ -6,7 +6,11 @@ module.exports = ({ modifierActions, settings }) =>
6
6
  if (!item || !Array.isArray(item.modifiers)) return [];
7
7
 
8
8
  let modifierTags = item.modifiers
9
- .filter(each => modifierActions.isValid(each))
9
+ .filter(
10
+ each =>
11
+ modifierActions.isValid(each) &&
12
+ (!modifierActions.isGroup(each) || modifierActions.isDepartment(each))
13
+ )
10
14
  .map(modifier => {
11
15
  const { name, _id } = modifier;
12
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -49,5 +49,5 @@
49
49
  "supertest": "^6.2.3",
50
50
  "supervisor": "^0.12.0"
51
51
  },
52
- "gitHead": "10feaa2937e3a57ac591a3174c3fd936f061d524"
52
+ "gitHead": "95b6471cd80c91a665a81a66fe95e12cdf45ca27"
53
53
  }