@darkpos/pricing 1.0.169 → 1.0.171

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.
@@ -373,4 +373,45 @@ describe('addItem function', () => {
373
373
  ],
374
374
  });
375
375
  });
376
+
377
+ test('should keep addModifiers of a required modifier (not toggle them off)', () => {
378
+ const { addItem } = pricingService.order;
379
+
380
+ const departmentModifier = {
381
+ _id: 'dept-dt',
382
+ name: 'D+T',
383
+ attributes: ['department'],
384
+ tags: ['default'],
385
+ };
386
+
387
+ const requiredGroupModifier = {
388
+ _id: 'repair-group',
389
+ name: 'Repair Blouse',
390
+ attributes: ['group'],
391
+ required: true,
392
+ tags: ['default'],
393
+ addModifiers: [departmentModifier],
394
+ delModifiers: [],
395
+ properties: { group: { modifiers: ['child-mod'], items: [] } },
396
+ };
397
+
398
+ const { updatedOrder } = addItem({
399
+ order: { items: [] },
400
+ item: {
401
+ _id: null,
402
+ itemId: 'blouse',
403
+ quantity: 1,
404
+ price: 4.5,
405
+ modifiers: [],
406
+ itemModifiers: [requiredGroupModifier],
407
+ },
408
+ itemIndex: -1,
409
+ });
410
+
411
+ const modifierIds = updatedOrder.items[0].modifiers.map(
412
+ mod => mod.modifierId
413
+ );
414
+
415
+ expect(modifierIds).toEqual(['repair-group', 'dept-dt']);
416
+ });
376
417
  });
@@ -240,16 +240,17 @@ module.exports = ({ actions, itemActions, modifierActions, settings, _ }) => {
240
240
  const [, , nextItem] = params;
241
241
 
242
242
  if (modifiersToAdd.length) {
243
- nextOrder = modifiersToAdd.reduce(
244
- (acc, modifier) =>
245
- actions.addItemModifier({
246
- itemIndex: nextItemIndex,
247
- order: acc,
248
- modifier,
249
- originalItem: item,
250
- }),
251
- nextOrder
252
- );
243
+ nextOrder = modifiersToAdd.reduce((acc, modifier) => {
244
+ const { modifiers } = acc.items[nextItemIndex];
245
+ if (modifierActions.contains(modifiers, modifier)) return acc;
246
+
247
+ return actions.addItemModifier({
248
+ itemIndex: nextItemIndex,
249
+ order: acc,
250
+ modifier,
251
+ originalItem: item,
252
+ });
253
+ }, nextOrder);
253
254
  }
254
255
 
255
256
  const { reArrangedOrder, newIndex } = reArrangeNewItem({
@@ -7,7 +7,7 @@ module.exports = ({ utils }) =>
7
7
  const isoString = utils.date.toISOString(date);
8
8
  nextOrder.end = {
9
9
  ...nextOrder.end,
10
- actualDate: utils.date.isToday(date) ? isoString : '',
10
+ // actualDate: utils.date.isToday(date) ? isoString : '',
11
11
  requestDate: isoString,
12
12
  __typename: 'OrderEnd',
13
13
  };
@@ -7,7 +7,7 @@ module.exports = ({ utils }) =>
7
7
  const isoString = utils.date.toISOString(date);
8
8
  nextOrder.start = {
9
9
  ...nextOrder.start,
10
- actualDate: utils.date.isToday(date) ? isoString : '',
10
+ // actualDate: utils.date.isToday(date) ? isoString : '',
11
11
  requestDate: isoString,
12
12
  };
13
13
  return nextOrder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.169",
3
+ "version": "1.0.171",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -54,5 +54,5 @@
54
54
  "supertest": "^6.2.3",
55
55
  "supervisor": "^0.12.0"
56
56
  },
57
- "gitHead": "39bcdea9fdfcd1f04ffed395217362bbc80a3669"
57
+ "gitHead": "26d6fc8f73778e3c85c0269a38ff0b2a0890ed2d"
58
58
  }