@darkpos/pricing 1.0.25 → 1.0.27

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.
@@ -10,6 +10,7 @@ const orderModifiersPartiallyPaid = require('../mocks/partially-paid/order-modif
10
10
  const inputItemsPartiallyPaidOrder = require('../mocks/partially-paid/input-items.json');
11
11
 
12
12
  const orderCredit = require('../mocks/order-credit.json');
13
+ const { Types } = require('../../lib/constants/Modifier/Compute');
13
14
 
14
15
  const session = {
15
16
  store: mockStores[0],
@@ -1917,208 +1918,326 @@ describe('Order actions', () => {
1917
1918
 
1918
1919
  expect(balanceToPay).toBe(102.79);
1919
1920
  });
1920
- });
1921
1921
 
1922
- test('CU-8678p4ky3. Get Calculated order. Multiple Items. 2 Modifiers. 1 Item tax. 1 Orde discount', () => {
1923
- const taxMod = {
1924
- _id: 2,
1925
- name: `7.75% tax`,
1926
- type: 'tax',
1927
- compute: {
1928
- amount: 7.75,
1929
- type: 'percentage',
1930
- action: 'add',
1931
- },
1932
- properties: {
1933
- sort: 2,
1934
- },
1935
- };
1936
-
1937
- const discountMod = {
1938
- _id: 1,
1939
- compute: {
1940
- amount: 15,
1922
+ test('CU-8678p4ky3. Get Calculated order. Multiple Items. 2 Modifiers. 1 Item tax. 1 Orde discount', () => {
1923
+ const taxMod = {
1924
+ _id: 2,
1925
+ name: `7.75% tax`,
1926
+ type: 'tax',
1927
+ compute: {
1928
+ amount: 7.75,
1929
+ type: 'percentage',
1930
+ action: 'add',
1931
+ },
1932
+ properties: {
1933
+ sort: 2,
1934
+ },
1935
+ };
1936
+
1937
+ const discountMod = {
1938
+ _id: 1,
1939
+ compute: {
1940
+ amount: 15,
1941
+ type: 'percentage',
1942
+ action: 'subtract',
1943
+ },
1944
+ name: `15%`,
1941
1945
  type: 'percentage',
1942
- action: 'subtract',
1943
- },
1944
- name: `15%`,
1945
- type: 'percentage',
1946
- properties: {
1947
- sort: 1,
1948
- },
1949
- };
1950
-
1951
- const item1 = {
1952
- _id: 1,
1953
- price: 35.95,
1954
- quantity: 2,
1955
- modifiers: [taxMod],
1956
- };
1957
- const item2 = {
1958
- _id: 2,
1959
- price: 28.95,
1960
- quantity: 2,
1961
- modifiers: [taxMod],
1962
- };
1963
- const item3 = {
1964
- _id: 3,
1965
- price: 17.95,
1966
- quantity: 4,
1967
- modifiers: [taxMod],
1968
- };
1969
- const item4 = {
1970
- _id: 4,
1971
- price: 158,
1972
- quantity: 1,
1973
- modifiers: [taxMod],
1974
- };
1975
- const item5 = {
1976
- _id: 5,
1977
- price: 148,
1978
- quantity: 2,
1979
- modifiers: [taxMod],
1980
- };
1981
- const item6 = {
1982
- _id: 6,
1983
- price: 120,
1984
- quantity: 1,
1985
- modifiers: [taxMod],
1986
- };
1987
-
1988
- const order = {
1989
- items: [item1, item2, item3, item4, item5, item6],
1990
- modifiers: [discountMod],
1991
- };
1992
-
1993
- const newOrder = pricingService.order.calculate(order);
1994
-
1995
- expect(newOrder).toHaveProperty('total', 710.35);
1996
- expect(newOrder).toHaveProperty('subTotal', 775.6);
1997
- expect(newOrder).toHaveProperty('subTotals', {
1998
- percentage: -116.34,
1999
- tax: 51.09,
1946
+ properties: {
1947
+ sort: 1,
1948
+ },
1949
+ };
1950
+
1951
+ const item1 = {
1952
+ _id: 1,
1953
+ price: 35.95,
1954
+ quantity: 2,
1955
+ modifiers: [taxMod],
1956
+ };
1957
+ const item2 = {
1958
+ _id: 2,
1959
+ price: 28.95,
1960
+ quantity: 2,
1961
+ modifiers: [taxMod],
1962
+ };
1963
+ const item3 = {
1964
+ _id: 3,
1965
+ price: 17.95,
1966
+ quantity: 4,
1967
+ modifiers: [taxMod],
1968
+ };
1969
+ const item4 = {
1970
+ _id: 4,
1971
+ price: 158,
1972
+ quantity: 1,
1973
+ modifiers: [taxMod],
1974
+ };
1975
+ const item5 = {
1976
+ _id: 5,
1977
+ price: 148,
1978
+ quantity: 2,
1979
+ modifiers: [taxMod],
1980
+ };
1981
+ const item6 = {
1982
+ _id: 6,
1983
+ price: 120,
1984
+ quantity: 1,
1985
+ modifiers: [taxMod],
1986
+ };
1987
+
1988
+ const order = {
1989
+ items: [item1, item2, item3, item4, item5, item6],
1990
+ modifiers: [discountMod],
1991
+ };
1992
+
1993
+ const newOrder = pricingService.order.calculate(order);
1994
+
1995
+ expect(newOrder).toHaveProperty('total', 710.35);
1996
+ expect(newOrder).toHaveProperty('subTotal', 775.6);
1997
+ expect(newOrder).toHaveProperty('subTotals', {
1998
+ percentage: -116.34,
1999
+ tax: 51.09,
2000
+ });
2001
+ expect(newOrder.items[0]).toHaveProperty('total', 65.8514125);
2002
+ expect(newOrder.items[1]).toHaveProperty('total', 53.0291625);
2003
+ expect(newOrder.items[2]).toHaveProperty('total', 65.759825);
2004
+ expect(newOrder.items[3]).toHaveProperty('total', 144.70825);
2005
+ expect(newOrder.items[4]).toHaveProperty('total', 271.099);
2006
+ expect(newOrder.items[5]).toHaveProperty('total', 109.905);
2007
+ expect(newOrder.items[0].modifiers[0]._computed).toHaveProperty(
2008
+ 'amount',
2009
+ -10.785
2010
+ );
2011
+ expect(newOrder.items[0].modifiers[1]._computed).toHaveProperty(
2012
+ 'amount',
2013
+ 4.7364125
2014
+ );
2015
+
2016
+ expect(newOrder.items[1].modifiers[0]._computed).toHaveProperty(
2017
+ 'amount',
2018
+ -8.685
2019
+ );
2020
+ expect(newOrder.items[1].modifiers[1]._computed).toHaveProperty(
2021
+ 'amount',
2022
+ 3.8141625
2023
+ );
2024
+
2025
+ expect(newOrder.items[2].modifiers[0]._computed).toHaveProperty(
2026
+ 'amount',
2027
+ -10.77
2028
+ );
2029
+ expect(newOrder.items[2].modifiers[1]._computed).toHaveProperty(
2030
+ 'amount',
2031
+ 4.729825
2032
+ );
2033
+
2034
+ expect(newOrder.items[3].modifiers[0]._computed).toHaveProperty(
2035
+ 'amount',
2036
+ -23.7
2037
+ );
2038
+ expect(newOrder.items[3].modifiers[1]._computed).toHaveProperty(
2039
+ 'amount',
2040
+ 10.40825
2041
+ );
2042
+
2043
+ expect(newOrder.items[4].modifiers[0]._computed).toHaveProperty(
2044
+ 'amount',
2045
+ -44.4
2046
+ );
2047
+ expect(newOrder.items[4].modifiers[1]._computed).toHaveProperty(
2048
+ 'amount',
2049
+ 19.499
2050
+ );
2051
+
2052
+ expect(newOrder.items[5].modifiers[0]._computed).toHaveProperty(
2053
+ 'amount',
2054
+ -18
2055
+ );
2056
+ expect(newOrder.items[5].modifiers[1]._computed).toHaveProperty(
2057
+ 'amount',
2058
+ 7.905
2059
+ );
2000
2060
  });
2001
- expect(newOrder.items[0]).toHaveProperty('total', 65.8514125);
2002
- expect(newOrder.items[1]).toHaveProperty('total', 53.0291625);
2003
- expect(newOrder.items[2]).toHaveProperty('total', 65.759825);
2004
- expect(newOrder.items[3]).toHaveProperty('total', 144.70825);
2005
- expect(newOrder.items[4]).toHaveProperty('total', 271.099);
2006
- expect(newOrder.items[5]).toHaveProperty('total', 109.905);
2007
- expect(newOrder.items[0].modifiers[0]._computed).toHaveProperty(
2008
- 'amount',
2009
- -10.785
2010
- );
2011
- expect(newOrder.items[0].modifiers[1]._computed).toHaveProperty(
2012
- 'amount',
2013
- 4.7364125
2014
- );
2015
-
2016
- expect(newOrder.items[1].modifiers[0]._computed).toHaveProperty(
2017
- 'amount',
2018
- -8.685
2019
- );
2020
- expect(newOrder.items[1].modifiers[1]._computed).toHaveProperty(
2021
- 'amount',
2022
- 3.8141625
2023
- );
2024
-
2025
- expect(newOrder.items[2].modifiers[0]._computed).toHaveProperty(
2026
- 'amount',
2027
- -10.77
2028
- );
2029
- expect(newOrder.items[2].modifiers[1]._computed).toHaveProperty(
2030
- 'amount',
2031
- 4.729825
2032
- );
2033
-
2034
- expect(newOrder.items[3].modifiers[0]._computed).toHaveProperty(
2035
- 'amount',
2036
- -23.7
2037
- );
2038
- expect(newOrder.items[3].modifiers[1]._computed).toHaveProperty(
2039
- 'amount',
2040
- 10.40825
2041
- );
2042
-
2043
- expect(newOrder.items[4].modifiers[0]._computed).toHaveProperty(
2044
- 'amount',
2045
- -44.4
2046
- );
2047
- expect(newOrder.items[4].modifiers[1]._computed).toHaveProperty(
2048
- 'amount',
2049
- 19.499
2050
- );
2051
-
2052
- expect(newOrder.items[5].modifiers[0]._computed).toHaveProperty(
2053
- 'amount',
2054
- -18
2055
- );
2056
- expect(newOrder.items[5].modifiers[1]._computed).toHaveProperty(
2057
- 'amount',
2058
- 7.905
2059
- );
2060
- });
2061
2061
 
2062
- test('CU-8678tdrvq. Get Calculated order. Multiple Items. 1 Order tax', () => {
2063
- const taxMod = {
2064
- _id: 2,
2065
- name: `7.75% tax`,
2066
- type: 'tax',
2067
- compute: {
2068
- amount: 7.75,
2069
- type: 'percentage',
2070
- action: 'add',
2071
- },
2072
- properties: {
2073
- sort: 2,
2074
- },
2075
- };
2076
-
2077
- const item1 = {
2078
- _id: 1,
2079
- price: 38,
2080
- quantity: 1,
2081
- modifiers: [],
2082
- };
2083
- const item2 = {
2084
- _id: 2,
2085
- price: 42,
2086
- quantity: 1,
2087
- modifiers: [],
2088
- };
2089
- const item3 = {
2090
- _id: 3,
2091
- price: 48,
2092
- quantity: 1,
2093
- modifiers: [],
2094
- };
2095
-
2096
- const order = {
2097
- items: [item1, item2, item3],
2098
- modifiers: [taxMod],
2099
- };
2100
-
2101
- const newOrder = pricingService.order.calculate(order);
2102
-
2103
- expect(newOrder).toHaveProperty('total', 137.92);
2104
- expect(newOrder).toHaveProperty('subTotal', 128);
2105
- expect(newOrder).toHaveProperty('subTotals', {
2106
- tax: 9.92,
2062
+ test('CU-8678tdrvq. Get Calculated order. Multiple Items. 1 Order tax', () => {
2063
+ const taxMod = {
2064
+ _id: 2,
2065
+ name: `7.75% tax`,
2066
+ type: 'tax',
2067
+ compute: {
2068
+ amount: 7.75,
2069
+ type: 'percentage',
2070
+ action: 'add',
2071
+ },
2072
+ properties: {
2073
+ sort: 2,
2074
+ },
2075
+ };
2076
+
2077
+ const item1 = {
2078
+ _id: 1,
2079
+ price: 38,
2080
+ quantity: 1,
2081
+ modifiers: [],
2082
+ };
2083
+ const item2 = {
2084
+ _id: 2,
2085
+ price: 42,
2086
+ quantity: 1,
2087
+ modifiers: [],
2088
+ };
2089
+ const item3 = {
2090
+ _id: 3,
2091
+ price: 48,
2092
+ quantity: 1,
2093
+ modifiers: [],
2094
+ };
2095
+
2096
+ const order = {
2097
+ items: [item1, item2, item3],
2098
+ modifiers: [taxMod],
2099
+ };
2100
+
2101
+ const newOrder = pricingService.order.calculate(order);
2102
+
2103
+ expect(newOrder).toHaveProperty('total', 137.92);
2104
+ expect(newOrder).toHaveProperty('subTotal', 128);
2105
+ expect(newOrder).toHaveProperty('subTotals', {
2106
+ tax: 9.92,
2107
+ });
2108
+ expect(newOrder.items[0]).toHaveProperty('total', 40.945);
2109
+ expect(newOrder.items[1]).toHaveProperty('total', 45.255);
2110
+ expect(newOrder.items[2]).toHaveProperty('total', 51.72);
2111
+ expect(newOrder.items[0].modifiers[0]._computed).toHaveProperty(
2112
+ 'amount',
2113
+ 2.945
2114
+ );
2115
+
2116
+ expect(newOrder.items[1].modifiers[0]._computed).toHaveProperty(
2117
+ 'amount',
2118
+ 3.255
2119
+ );
2120
+ expect(newOrder.items[2].modifiers[0]._computed).toHaveProperty(
2121
+ 'amount',
2122
+ 3.72
2123
+ );
2124
+ });
2125
+
2126
+ test('CU-86dtxh2y5: #1- Get calculated Order, One item and fixed Fee Modifier', () => {
2127
+ const newOrderFixedModifier = pricingService.order.calculate({
2128
+ items: [
2129
+ {
2130
+ _id: 1,
2131
+ price: 5,
2132
+ quantity: 2,
2133
+ },
2134
+ ],
2135
+ modifiers: [
2136
+ {
2137
+ compute: {
2138
+ amount: 10,
2139
+ type: 'fixed',
2140
+ action: 'add',
2141
+ },
2142
+ name: 'fee 10 USD',
2143
+ type: 'fee',
2144
+ },
2145
+ ],
2146
+ });
2147
+ expect(newOrderFixedModifier).toHaveProperty('total', 20);
2148
+ });
2149
+
2150
+ test('CU-86dtxh2y5: #2.A- Get calculated Order, One item and fixed Fee Modifier (ignoreQuantity: false)', () => {
2151
+ const newOrderFixedModifier = pricingService.order.calculate({
2152
+ items: [
2153
+ {
2154
+ _id: 1,
2155
+ price: 5,
2156
+ quantity: 2,
2157
+ modifiers: [
2158
+ {
2159
+ compute: {
2160
+ amount: 20,
2161
+ type: 'fixed',
2162
+ action: 'add',
2163
+ },
2164
+ name: 'fee 20 USD',
2165
+ type: 'fee',
2166
+ },
2167
+ ],
2168
+ },
2169
+ ],
2170
+ });
2171
+ expect(newOrderFixedModifier).toHaveProperty('total', 50);
2172
+ });
2173
+
2174
+ test('CU-86dtxh2y5: #2.B- Get calculated Order, One item and fixed Fee Modifier (ignoreQuantity: true)', () => {
2175
+ const newOrderFixedModifier = pricingService.order.calculate({
2176
+ items: [
2177
+ {
2178
+ _id: 1,
2179
+ price: 5,
2180
+ quantity: 2,
2181
+ modifiers: [
2182
+ {
2183
+ compute: {
2184
+ amount: 20,
2185
+ type: 'fixed',
2186
+ action: 'add',
2187
+ },
2188
+ name: 'fee 20 USD',
2189
+ type: 'fee',
2190
+ properties: {
2191
+ ignoreQuantity: true,
2192
+ },
2193
+ },
2194
+ ],
2195
+ },
2196
+ ],
2197
+ });
2198
+ expect(newOrderFixedModifier).toHaveProperty('total', 30);
2199
+ });
2200
+
2201
+ test('CU-86dtxh2y5: #3- Get calculated Order, One item and fixed Fee Modifier, using createFeeModifier', () => {
2202
+ const newOrderFixedModifier = pricingService.order.calculate({
2203
+ items: [
2204
+ {
2205
+ _id: 1,
2206
+ price: 10,
2207
+ quantity: 2,
2208
+ },
2209
+ ],
2210
+ modifiers: [
2211
+ pricingService.modifier.createFeeModifier({
2212
+ amount: 100,
2213
+ type: Types.FIXED,
2214
+ }),
2215
+ ],
2216
+ });
2217
+
2218
+ expect(newOrderFixedModifier).toHaveProperty('total', 120);
2219
+ });
2220
+
2221
+ test('CU-86dtxh2y5: #4- Get calculated Order, One item and fixed Fee Modifier, using createFeeModifier (ignoreQuantity: true)', () => {
2222
+ const newOrderFixedModifier = pricingService.order.calculate({
2223
+ items: [
2224
+ {
2225
+ _id: 1,
2226
+ price: 10,
2227
+ quantity: 2,
2228
+ },
2229
+ ],
2230
+ modifiers: [
2231
+ pricingService.modifier.createFeeModifier({
2232
+ amount: 100,
2233
+ type: Types.FIXED,
2234
+ properties: {
2235
+ ignoreQuantity: true,
2236
+ },
2237
+ }),
2238
+ ],
2239
+ });
2240
+
2241
+ expect(newOrderFixedModifier).toHaveProperty('total', 120);
2107
2242
  });
2108
- expect(newOrder.items[0]).toHaveProperty('total', 40.945);
2109
- expect(newOrder.items[1]).toHaveProperty('total', 45.255);
2110
- expect(newOrder.items[2]).toHaveProperty('total', 51.72);
2111
- expect(newOrder.items[0].modifiers[0]._computed).toHaveProperty(
2112
- 'amount',
2113
- 2.945
2114
- );
2115
-
2116
- expect(newOrder.items[1].modifiers[0]._computed).toHaveProperty(
2117
- 'amount',
2118
- 3.255
2119
- );
2120
- expect(newOrder.items[2].modifiers[0]._computed).toHaveProperty(
2121
- 'amount',
2122
- 3.72
2123
- );
2124
2243
  });
@@ -2,6 +2,7 @@
2
2
  module.exports = {
3
3
  DISCOUNT: 'discount',
4
4
  TAX: 'tax',
5
+ FEE: 'fee',
5
6
  GRATUITY: 'gratuity',
6
7
  CREDIT: 'credit',
7
8
  };
package/lib/index.js CHANGED
@@ -34,5 +34,6 @@ module.exports = session => {
34
34
  item: itemActions,
35
35
  order: orderActions,
36
36
  modifier: modifierActions,
37
+ constants,
37
38
  };
38
39
  };
@@ -73,7 +73,8 @@ module.exports = ({ _, utils, actions, modifierActions }) => {
73
73
  let computedAmount =
74
74
  _modifier.compute.type === 'percentage' ||
75
75
  modifierActions.isIgnoreQuantity(_modifier) ||
76
- math.gt(math.abs(computedAmountCalc), computedPriceCalc)
76
+ (!modifierActions.isFixedAdd(_modifier) &&
77
+ math.gt(math.abs(computedAmountCalc), computedPriceCalc))
77
78
  ? _computed.amount
78
79
  : computedAmountCalc;
79
80
 
@@ -19,7 +19,9 @@ module.exports = ({ _, constants, utils, localization, actions }) => {
19
19
  const maxAmountProp = actions.getProperty(modifier, 'maxAmount');
20
20
 
21
21
  if (!options.skip) {
22
- const maxAmountCalc = math.mul(options.price, options.quantity);
22
+ const maxAmountCalc = actions.isFixedAdd(modifier)
23
+ ? amount
24
+ : math.mul(options.price, options.quantity);
23
25
 
24
26
  const maxAmount = maxAmountProp
25
27
  ? math.min(maxAmountProp, maxAmountCalc)
@@ -2,7 +2,7 @@ module.exports = ({ constants, actions, localization }) => {
2
2
  const { Modifier } = constants;
3
3
 
4
4
  return function createDiscountModifier(params) {
5
- const { amount, type } = params;
5
+ const { amount, type, properties } = params;
6
6
  const { formatAmount } = localization;
7
7
 
8
8
  const name =
@@ -18,6 +18,9 @@ module.exports = ({ constants, actions, localization }) => {
18
18
  },
19
19
  type: Modifier.Types.DISCOUNT,
20
20
  name: `${name} ${Modifier.Types.DISCOUNT}`,
21
+ properties: {
22
+ ...properties,
23
+ },
21
24
  });
22
25
  };
23
26
  };
@@ -0,0 +1,27 @@
1
+ module.exports = ({ constants, actions, localization }) => {
2
+ const { Modifier } = constants;
3
+
4
+ return function createFeeModifier(params) {
5
+ const { amount, type, properties } = params;
6
+ const { formatAmount } = localization;
7
+
8
+ const name =
9
+ type === Modifier.Compute.Types.PERCENTAGE
10
+ ? `${amount}%`
11
+ : `${formatAmount(amount)}`;
12
+
13
+ return actions.create({
14
+ compute: {
15
+ action: Modifier.Compute.Actions.ADD,
16
+ amount,
17
+ type,
18
+ },
19
+ type: Modifier.Types.FEE,
20
+ name: `${name} ${Modifier.Types.FEE}`,
21
+ properties: {
22
+ ignoreQuantity: true,
23
+ ...properties,
24
+ },
25
+ });
26
+ };
27
+ };
@@ -35,10 +35,15 @@ module.exports = ({ _, utils, constants, actions }) => {
35
35
  !math.isZero(options.orderTotal) &&
36
36
  (type !== Modifier.Compute.Types.PERCENTAGE || modifier.type === 'credit')
37
37
  ) {
38
+ const modififierQuantity =
39
+ modifier.properties && modifier.properties.ignoreQuantity
40
+ ? 1
41
+ : options.itemQuantity;
42
+
38
43
  amountToApply = math.div(
39
44
  math.mul(modifierAmount, options.itemTotal),
40
45
  options.orderTotal,
41
- options.itemQuantity
46
+ modififierQuantity
42
47
  );
43
48
  }
44
49
 
@@ -8,6 +8,7 @@ const create = require('./create');
8
8
  const createAmountOverrideModifier = require('./createAmountOverrideModifier');
9
9
  const createCreditModifier = require('./createCreditModifier');
10
10
  const createDiscountModifier = require('./createDiscountModifier');
11
+ const createFeeModifier = require('./createFeeModifier');
11
12
  const createGroupValuesModifier = require('./createGroupValuesModifier');
12
13
  const createIndirectModifier = require('./createIndirectModifier');
13
14
  const createSubscriptionModifier = require('./createSubscriptionModifier');
@@ -120,6 +121,10 @@ const isPaymentModifier = require('./isPaymentModifier');
120
121
  const createPaymentModifier = require('./createPaymentModifier');
121
122
  const isSubtract = require('./isSubtract');
122
123
  const isFixed = require('./isFixed');
124
+ const isFixedAdd = require('./isFixedAdd');
125
+ const isFee = require('./isFee');
126
+ const isAdd = require('./isAdd');
127
+
123
128
  const isFixedDiscount = require('./isFixedDiscount');
124
129
  const removeLocked = require('./removeLocked');
125
130
  const hasItems = require('./hasItems');
@@ -143,6 +148,7 @@ const modifierActions = (deps = {}) => {
143
148
  createAmountOverrideModifier: createAmountOverrideModifier(innerDeps),
144
149
  createCreditModifier: createCreditModifier(innerDeps),
145
150
  createDiscountModifier: createDiscountModifier(innerDeps),
151
+ createFeeModifier: createFeeModifier(innerDeps),
146
152
  createGroupValuesModifier: createGroupValuesModifier(innerDeps),
147
153
  createIndirectModifier: createIndirectModifier(innerDeps),
148
154
  createSubscriptionModifier: createSubscriptionModifier(innerDeps),
@@ -260,6 +266,9 @@ const modifierActions = (deps = {}) => {
260
266
  removeLocked: removeLocked(innerDeps),
261
267
  hasItems: hasItems(innerDeps),
262
268
  getLockedModifiers: getLockedModifiers(innerDeps),
269
+ isFixedAdd: isFixedAdd(innerDeps),
270
+ isFee: isFee(innerDeps),
271
+ isAdd: isAdd(innerDeps),
263
272
  });
264
273
 
265
274
  Object.keys(freezedActions).forEach(actionName => {
@@ -0,0 +1,10 @@
1
+ module.exports = ({ constants }) => {
2
+ const { Modifier } = constants;
3
+ return function isAdd(modifier) {
4
+ return !!(
5
+ modifier &&
6
+ modifier.compute &&
7
+ modifier.compute.action === Modifier.Compute.Actions.ADD
8
+ );
9
+ };
10
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = ({ constants }) => {
2
+ const { Modifier } = constants;
3
+ return function isFee(modifier) {
4
+ return !!(modifier && modifier.type === Modifier.Types.FEE);
5
+ };
6
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = ({ actions }) =>
2
+ function isFixedAdd(modifier) {
3
+ return actions.isAdd(modifier) && actions.isFixed(modifier);
4
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = ({ actions }) =>
2
+ function isFixedFee(modifier) {
3
+ return actions.isFee(modifier) && actions.isFixed(modifier);
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -36,5 +36,5 @@
36
36
  "supertest": "^6.2.3",
37
37
  "supervisor": "^0.12.0"
38
38
  },
39
- "gitHead": "e8af4c6528df412d450ff6382f930723b32e6a1d"
39
+ "gitHead": "575378174e6efda3e4bffa65d1226e55eb09725e"
40
40
  }