@darkpos/pricing 1.0.43 → 1.0.44

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.
Files changed (42) hide show
  1. package/__TEST__/item/getItemsModifierDescription.test.js +10 -3
  2. package/__TEST__/mocks/addItemMock.js +18729 -19357
  3. package/__TEST__/mocks/partially-paid/order-modifiers.json +48 -51
  4. package/__TEST__/mocks/partially-paid/order-partially-paid.json +893 -860
  5. package/__TEST__/mocks/unpaid/order-modifiers.json +48 -52
  6. package/__TEST__/modifier/calculate.test.js +1 -0
  7. package/__TEST__/modifier/getMatchTagsModifiers.test.js +72 -18
  8. package/__TEST__/modifier/getModifierIndex.test.js +10 -7
  9. package/__TEST__/modifier/getRecommendedModifiers.test.js +6 -4
  10. package/__TEST__/modifier/hasAttribute.test.js +11 -5
  11. package/__TEST__/modifier/hasMatchTags.test.js +33 -11
  12. package/__TEST__/modifier/sort.test.js +1 -1
  13. package/__TEST__/order/conditionsNotMet.test.js +133 -0
  14. package/__TEST__/order/order.test.js +7 -5
  15. package/__TEST__/order/pickEndDate.test.js +1 -1
  16. package/__TEST__/order/validateConditionsCalculate.test.js +397 -0
  17. package/lib/constants/index.js +1 -1
  18. package/lib/index.js +11 -2
  19. package/lib/item/calculate.js +27 -10
  20. package/lib/item/getItemModifiersDescription.js +1 -0
  21. package/lib/item/markModifiersAsLocked.js +3 -1
  22. package/lib/modifier/areConditionsMet.js +71 -0
  23. package/lib/modifier/index.js +14 -5
  24. package/lib/modifier/isPaymentMethodModifier.js +1 -1
  25. package/lib/modifier/isPaymentTypeModifier.js +1 -1
  26. package/lib/modifier/isValid.js +12 -0
  27. package/lib/modifier/validate.js +14 -0
  28. package/lib/modifier/validateDateDaysDiff.js +30 -0
  29. package/lib/modifier/validateInArr.js +12 -0
  30. package/lib/modifier/validateNumberCondition.js +20 -0
  31. package/lib/modifier/validateRequiredModifiers.js +16 -0
  32. package/lib/order/addItemModifier.js +72 -28
  33. package/lib/order/calculate.js +12 -7
  34. package/lib/order/index.js +0 -2
  35. package/lib/order/removeModifiersWithPaymentMethods.js +1 -2
  36. package/lib/order/removeModifiersWithPaymentTypes.js +1 -2
  37. package/lib/store/getRecommendedEndDate.js +13 -0
  38. package/lib/store/index.js +25 -0
  39. package/package.json +3 -3
  40. package/lib/modifier/findByPaymentMethod.js +0 -10
  41. package/lib/modifier/findByPaymentType.js +0 -10
  42. /package/lib/{order → store}/pickEndDate.js +0 -0
@@ -1,53 +1,50 @@
1
1
  [
2
- {
3
- "__typename": "Modifier",
4
- "addModifiers": [],
5
- "delModifiers": [],
6
- "conditions": {
7
- "__typename": "Conditions",
8
- "paymentTypes": [
9
- "cash"
10
- ],
11
- "paymentMethods": [],
12
- "modifiers": [],
13
- "minItemQuantity": 0,
14
- "minItemPieces": 0
2
+ {
3
+ "__typename": "Modifier",
4
+ "addModifiers": [],
5
+ "delModifiers": [],
6
+ "conditions": {
7
+ "rules":[
8
+ {
9
+ "key": "paymentTypes",
10
+ "operand": "$in",
11
+ "value": ["cash"]
12
+ }
13
+ ]
15
14
  },
16
- "compute": {
17
- "__typename": "Compute",
18
- "type": "fixed",
19
- "action": "add",
20
- "amount": 2
21
- },
22
- "_createdAt": "2022-11-08T16:09:49.227Z",
23
- "_updatedAt": "2022-11-28T18:44:16.821Z",
24
- "_id": "636a7f3ec19c040636f3da9a",
25
- "modifierId": null,
26
- "_parentId": null,
27
- "locked": false,
28
- "name": "Cash fee",
29
- "sku": "",
30
- "description": "",
31
- "group": "",
32
- "type": "fee",
33
- "attributes": [],
34
- "color": "",
35
- "backgroundColor": "",
36
- "icon": "",
37
- "url": "",
38
- "tags": [
39
- "default"
40
- ],
41
- "order": 0,
42
- "included": false,
43
- "direct": true,
44
- "hidden": false,
45
- "print": true,
46
- "required": false,
47
- "recommended": false,
48
- "default": false,
49
- "code": "",
50
- "properties": null,
51
- "_computed": null
52
- }
53
- ]
15
+ "compute": {
16
+ "__typename": "Compute",
17
+ "type": "fixed",
18
+ "action": "add",
19
+ "amount": 2
20
+ },
21
+ "_createdAt": "2022-11-08T16:09:49.227Z",
22
+ "_updatedAt": "2022-11-28T18:44:16.821Z",
23
+ "_id": "636a7f3ec19c040636f3da9a",
24
+ "modifierId": null,
25
+ "_parentId": null,
26
+ "locked": false,
27
+ "name": "Cash fee",
28
+ "sku": "",
29
+ "description": "",
30
+ "group": "",
31
+ "type": "fee",
32
+ "attributes": [],
33
+ "color": "",
34
+ "backgroundColor": "",
35
+ "icon": "",
36
+ "url": "",
37
+ "tags": ["default"],
38
+ "order": 0,
39
+ "included": false,
40
+ "direct": true,
41
+ "hidden": false,
42
+ "print": true,
43
+ "required": false,
44
+ "recommended": false,
45
+ "default": false,
46
+ "code": "",
47
+ "properties": null,
48
+ "_computed": null
49
+ }
50
+ ]