@darkpos/pricing 1.0.11 → 1.0.12

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.
@@ -41,10 +41,14 @@ module.exports = ({ utils, modifierActions }) => {
41
41
  compute: {
42
42
  ...inheritedModifier.compute,
43
43
  amount: math.add(
44
- inheritedModifier.compute.amount,
45
- math.div(difference, selectedItem.quantity)
44
+ math.mul(inheritedModifier.compute.amount, selectedItem.quantity),
45
+ difference
46
46
  ),
47
47
  },
48
+ properties: {
49
+ ...inheritedModifier.properties,
50
+ ignoreQuantity: true,
51
+ },
48
52
  };
49
53
  }
50
54
  return itemsModifiers;
@@ -67,7 +67,9 @@ module.exports = ({ _, utils, modifierActions }) => {
67
67
  modifiers.push(_modifier);
68
68
  const { type, _computed } = _modifier;
69
69
  // console.log('computedPrice => ', _computed);
70
- let computedAmount = math.mul(_computed.amount, quantity);
70
+ let computedAmount = modifierActions.isIgnoreQuantity(_modifier)
71
+ ? _computed.amount
72
+ : math.mul(_computed.amount, quantity);
71
73
  // subscription modifiers have fixed amount and can't be multiplied by quantity
72
74
  if (modifierActions.isSubscription(_modifier))
73
75
  computedAmount = _computed.amount;
@@ -99,6 +99,7 @@ const isCustomerTagsExtend = require('./isCustomerTagsExtend');
99
99
  const isAmountOverride = require('./isAmountOverride');
100
100
  const isDiscount = require('./isDiscount');
101
101
  const isHidden = require('./isHidden');
102
+ const isIgnoreQuantity = require('./isIgnoreQuantity');
102
103
  const isGratuity = require('./isGratuity');
103
104
  const isPaymentMethods = require('./isPaymentMethods');
104
105
  const isPaymentTypes = require('./isPaymentTypes');
@@ -221,6 +222,7 @@ const modifierActions = (deps = {}) => {
221
222
  isAmountOverride: isAmountOverride(innerDeps),
222
223
  isDiscount: isDiscount(innerDeps),
223
224
  isHidden: isHidden(innerDeps),
225
+ isIgnoreQuantity: isIgnoreQuantity(innerDeps),
224
226
  isGratuity: isGratuity(innerDeps),
225
227
  isPaymentMethods: isPaymentMethods(innerDeps),
226
228
  isPaymentTypes: isPaymentTypes(innerDeps),
@@ -0,0 +1,5 @@
1
+ module.exports = () =>
2
+ function isIgnoreQuantity(modifier) {
3
+ if (!modifier || !modifier.properties) return false;
4
+ return modifier.properties.ignoreQuantity;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -35,5 +35,5 @@
35
35
  "supertest": "^6.2.3",
36
36
  "supervisor": "^0.12.0"
37
37
  },
38
- "gitHead": "d839ed87a99ef0c4297ba95cd647e358cba38639"
38
+ "gitHead": "c4950f95d5e9b9a8d9af97699a9f7f2acd1d35ca"
39
39
  }