@darkpos/pricing 1.0.56 → 1.0.58
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.
|
@@ -74,6 +74,64 @@ describe('Modifier actions', () => {
|
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
expect(conditionsBag).toEqual([]);
|
|
78
|
+
expect(error).toEqual('');
|
|
79
|
+
|
|
80
|
+
expect(updatedOrder2.items[0].modifiers.length).toEqual(2);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('CU-86dve27tq Should not allow adding a modifier more than once to an item if isQuantityMultiplier={true} QTY={2}', () => {
|
|
84
|
+
const order = {
|
|
85
|
+
id: 'ord-123',
|
|
86
|
+
items: [],
|
|
87
|
+
modifiers: [],
|
|
88
|
+
};
|
|
89
|
+
const modifier = {
|
|
90
|
+
_id: 1,
|
|
91
|
+
compute: {
|
|
92
|
+
amount: 10,
|
|
93
|
+
action: 'subtract',
|
|
94
|
+
type: 'fixed',
|
|
95
|
+
},
|
|
96
|
+
properties: {
|
|
97
|
+
isQuantityMultiplier: true,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
order.items.push({
|
|
101
|
+
quantity: 2,
|
|
102
|
+
itemId: '123',
|
|
103
|
+
price: 100,
|
|
104
|
+
modifiers: [],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const conditionsBag = [];
|
|
108
|
+
|
|
109
|
+
const updatedOrder = pricingService.order.addItemModifier({
|
|
110
|
+
order,
|
|
111
|
+
modifier,
|
|
112
|
+
itemIndex: 0,
|
|
113
|
+
onConditionsNotMet: bag => {
|
|
114
|
+
bag.forEach(condition => {
|
|
115
|
+
conditionsBag.push(condition);
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
let error = '';
|
|
121
|
+
const updatedOrder2 = pricingService.order.addItemModifier({
|
|
122
|
+
order: { ...updatedOrder },
|
|
123
|
+
modifier,
|
|
124
|
+
itemIndex: 0,
|
|
125
|
+
onConditionsNotMet: bag => {
|
|
126
|
+
bag.forEach(condition => {
|
|
127
|
+
conditionsBag.push(condition);
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
onError: errorMessage => {
|
|
131
|
+
error = errorMessage;
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
77
135
|
expect(conditionsBag).toEqual([]);
|
|
78
136
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
79
137
|
expect(updatedOrder2).toEqual(updatedOrder);
|
package/lib/modifier/index.js
CHANGED
|
@@ -150,6 +150,7 @@ const isOptionsSelectedOverride = require('./isOptionsSelectedOverride');
|
|
|
150
150
|
const isFixedSubtract = require('./isFixedSubtract');
|
|
151
151
|
const isQuantityMultiplier = require('./isQuantityMultiplier');
|
|
152
152
|
const isCompute = require('./isCompute');
|
|
153
|
+
const isFixedOverride = require('./isFixedOverride');
|
|
153
154
|
|
|
154
155
|
const modifierActions = (deps = {}) => {
|
|
155
156
|
const actions = {};
|
|
@@ -313,6 +314,7 @@ const modifierActions = (deps = {}) => {
|
|
|
313
314
|
isFixedSubtract: isFixedSubtract(innerDeps),
|
|
314
315
|
isQuantityMultiplier: isQuantityMultiplier(innerDeps),
|
|
315
316
|
isCompute: isCompute(innerDeps),
|
|
317
|
+
isFixedOverride: isFixedOverride(innerDeps),
|
|
316
318
|
});
|
|
317
319
|
|
|
318
320
|
Object.keys(freezedActions).forEach(actionName => {
|
|
@@ -227,7 +227,7 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
|
|
|
227
227
|
if (
|
|
228
228
|
contains &&
|
|
229
229
|
modifierActions.isCompute(modifier) &&
|
|
230
|
-
|
|
230
|
+
modifierActions.isQuantityMultiplier(modifier)
|
|
231
231
|
) {
|
|
232
232
|
if (onError)
|
|
233
233
|
onError('modifier.has.reached.the.maximum.amount.of.applies');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"supertest": "^6.2.3",
|
|
46
46
|
"supervisor": "^0.12.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "44545d8746f8adb06ebe4d8b87edc6ae0f0f4406"
|
|
49
49
|
}
|