@darkpos/pricing 1.0.38 → 1.0.40

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.
@@ -1,4 +1,4 @@
1
- const Status = require('./Status');
1
+ const Status = require('./status');
2
2
  const Modifier = require('./Modifier');
3
3
 
4
4
  module.exports = {
@@ -1,5 +1,4 @@
1
1
  module.exports = () =>
2
2
  function getItemModifiers(item) {
3
-
4
3
  return item.modifiers;
5
4
  };
@@ -1,5 +1,5 @@
1
1
  module.exports = ({ actions }) =>
2
- function getItemsTotalPieces(items) {
2
+ function getItemsTotalQuantity(items) {
3
3
  return items.reduce(
4
4
  (total, item) => total + actions.getTotalQuantity(item),
5
5
  0
@@ -6,5 +6,4 @@ module.exports = ({ utils }) =>
6
6
  (totalPrice, item) => utils.math.add(totalPrice, item.price),
7
7
  0
8
8
  );
9
-
10
9
  };
package/lib/item/index.js CHANGED
@@ -11,10 +11,8 @@ const create = require('./create');
11
11
  const hasModifier = require('./hasModifier');
12
12
  const isSelected = require('./isSelected');
13
13
  const hasModifiers = require('./hasModifiers');
14
- const openRecommendationDialog = require('./openRecommendationDialog');
15
14
  const addIndirectModifier = require('./addIndirectModifier');
16
15
  const calculate = require('./calculate');
17
- const filterByDirectModifiers = require('./filterByDirectModifiers');
18
16
  const getItemPrice = require('./getItemPrice');
19
17
  const getDepartmentModifiers = require('./getDepartmentModifiers');
20
18
  const hasSubscription = require('./hasSubscription');
@@ -62,10 +60,8 @@ const itemActions = (deps = {}) => {
62
60
  hasModifier: hasModifier(innerDeps),
63
61
  isSelected: isSelected(innerDeps),
64
62
  hasModifiers: hasModifiers(innerDeps),
65
- openRecommendationDialog: openRecommendationDialog(innerDeps),
66
63
  addIndirectModifier: addIndirectModifier(innerDeps),
67
64
  calculate: calculate(innerDeps),
68
- filterByDirectModifiers: filterByDirectModifiers(innerDeps),
69
65
  getItemPrice: getItemPrice(innerDeps),
70
66
  getDepartmentModifiers: getDepartmentModifiers(innerDeps),
71
67
  hasSubscription: hasSubscription(innerDeps),
@@ -14,7 +14,6 @@ module.exports = ({ _, constants, utils, localization, actions }) => {
14
14
  const modifier = _modifier;
15
15
  const { name } = modifier;
16
16
  const compute = getComputeModField(modifier);
17
- modifier.compute = compute;
18
17
  const { type, action, amount = 0 } = compute;
19
18
  const _computed = {
20
19
  amount: 0,
@@ -24,9 +23,10 @@ module.exports = ({ _, constants, utils, localization, actions }) => {
24
23
  const maxAmountProp = actions.getProperty(modifier, 'maxAmount');
25
24
 
26
25
  if (!options.skip) {
27
- const maxAmountCalc = actions.isFixedAdd(modifier)
28
- ? amount
29
- : math.mul(options.price, options.quantity);
26
+ const maxAmountCalc =
27
+ actions.isFixedAdd(modifier) || actions.isAmountOverride(modifier)
28
+ ? amount
29
+ : math.mul(options.price, options.quantity);
30
30
 
31
31
  const maxAmount = maxAmountProp
32
32
  ? math.min(maxAmountProp, maxAmountCalc)
@@ -1,6 +1,5 @@
1
- module.exports = ({ _, actions }) => {
2
-
3
- return function createCreditModifier(modifier = {}) {
1
+ module.exports = ({ _, actions }) =>
2
+ function createCreditModifier(modifier = {}) {
4
3
  const { customerStoredCredit, ...rest } = _.cloneDeep(modifier);
5
4
  if (!customerStoredCredit) return null;
6
5
  let creditModifier;
@@ -27,4 +26,3 @@ module.exports = ({ _, actions }) => {
27
26
  };
28
27
  return creditModifier;
29
28
  };
30
- };
@@ -1,5 +1,5 @@
1
- module.exports = ({ actions }) => {
2
- return function getItemModifiers({ modifiers, customer, cache }) {
1
+ module.exports = ({ actions }) =>
2
+ function getItemModifiers({ modifiers, customer, cache }) {
3
3
  const matchedModifiers = actions.getMatchTagsModifiers({
4
4
  modifiers,
5
5
  entity: customer,
@@ -34,4 +34,3 @@ module.exports = ({ actions }) => {
34
34
  modifierId: each.modifierId || each._id,
35
35
  }));
36
36
  };
37
- };
@@ -48,8 +48,10 @@ module.exports = ({ settings, _, moment }) => {
48
48
  // day condition stays working until addDaysCounter is greater than loop
49
49
  if (
50
50
  !shouldSkip ||
51
+ // eslint-disable-next-line no-loop-func
51
52
  !closedDays.some(closedDay => closedDay.date.isSame(endDateTZ, 'day'))
52
53
  ) {
54
+ // eslint-disable-next-line no-plusplus
53
55
  addDaysCounter++;
54
56
  }
55
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
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": "6d87c96080369a419d9f2ae7fb77205be0c62d02"
39
+ "gitHead": "da5bee1f9a5c7e67c1776be8c31b093551d5df0d"
40
40
  }
@@ -1,13 +0,0 @@
1
- /**
2
- * Remove order modifiers from items
3
- */
4
- module.exports = ({ modifierActions }) =>
5
- //
6
- function filterByDirectModifiers(items = []) {
7
- return items.map(item => ({
8
- ...item,
9
- modifiers: (item.modifiers || []).filter(modifier =>
10
- modifierActions.isDirect(modifier)
11
- ),
12
- }));
13
- };
@@ -1,4 +0,0 @@
1
- module.exports = () =>
2
- function openRecommendationDialog(item) {
3
- return !!(item && item.openRecommendationDialog);
4
- };