@darkpos/pricing 1.0.117 → 1.0.119

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.
package/lib/item/index.js CHANGED
@@ -70,6 +70,7 @@ const adjustNegativeTotal = require('./adjustNegativeTotal');
70
70
  const applyNotesOverridesToItem = require('./applyNotesOverridesToItem');
71
71
  const getModifiersToNotCompute = require('./getModifiersToNotCompute');
72
72
  const getSplitDepartment = require('./getSplitDepartment');
73
+ const isPriceChanged = require('./isPriceChanged');
73
74
 
74
75
  const itemActions = (deps = {}) => {
75
76
  const actions = {};
@@ -153,6 +154,7 @@ const itemActions = (deps = {}) => {
153
154
  applyNotesOverridesToItem: applyNotesOverridesToItem(innerDeps),
154
155
  getModifiersToNotCompute: getModifiersToNotCompute(innerDeps),
155
156
  getSplitDepartment: getSplitDepartment(innerDeps),
157
+ isPriceChanged: isPriceChanged(innerDeps),
156
158
  });
157
159
 
158
160
  Object.keys(freezedActions).forEach(actionName => {
@@ -0,0 +1,5 @@
1
+ module.exports = () =>
2
+ function isPriceChanged(item) {
3
+ if (!item || !item.properties) return false;
4
+ return !!item.properties.priceChanged;
5
+ };
@@ -47,6 +47,9 @@ module.exports = ({ actions, utils }) => {
47
47
  }
48
48
 
49
49
  if (actions.isAdd(paymentModifier)) {
50
+ if (amountToPay > itemBalance) {
51
+ amountToPay = itemBalance;
52
+ }
50
53
  return actions.calculatePaymentFeeModifier({
51
54
  amountToPay,
52
55
  paymentModifier,
@@ -39,6 +39,8 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
39
39
  ...(item.properties || {}),
40
40
  };
41
41
 
42
+ if (itemActions.isPriceChanged(item)) return item;
43
+
42
44
  item.price = itemActions.getItemPrice({
43
45
  item,
44
46
  itemPriceLevels: originalItem ? originalItem.priceLevels : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.117",
3
+ "version": "1.0.119",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -55,5 +55,5 @@
55
55
  "supertest": "^6.2.3",
56
56
  "supervisor": "^0.12.0"
57
57
  },
58
- "gitHead": "3519ea921f066379601e455e8d838bdad9378dd0"
58
+ "gitHead": "0d7daa7d6a45a479f443acde46d0244040a96b66"
59
59
  }