@darkpos/pricing 1.0.49 → 1.0.50
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const usePricing = require('../index');
|
|
2
|
+
|
|
3
|
+
const pricingService = usePricing();
|
|
4
|
+
|
|
5
|
+
describe('Modifier actions', () => {
|
|
6
|
+
test('CU-86dv8hzxg modifier.isGroup fn', () => {
|
|
7
|
+
expect(
|
|
8
|
+
pricingService.modifier.isGroup({
|
|
9
|
+
attributes: ['group'],
|
|
10
|
+
})
|
|
11
|
+
).toBe(true);
|
|
12
|
+
|
|
13
|
+
expect(
|
|
14
|
+
pricingService.modifier.isGroup({
|
|
15
|
+
properties: {
|
|
16
|
+
group: {},
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
).toBe(false);
|
|
20
|
+
expect(
|
|
21
|
+
pricingService.modifier.isGroup({
|
|
22
|
+
atrributes: [],
|
|
23
|
+
properties: {},
|
|
24
|
+
})
|
|
25
|
+
).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -11,7 +11,7 @@ module.exports = ({ modifierActions, _, settings }) =>
|
|
|
11
11
|
!modifierActions.isAmountOverride(each) &&
|
|
12
12
|
!modifierActions.isDepartment(each) &&
|
|
13
13
|
modifierActions.isDirect(each) &&
|
|
14
|
-
!modifierActions.
|
|
14
|
+
!modifierActions.isGroup(each)
|
|
15
15
|
)
|
|
16
16
|
.map(modifier => {
|
|
17
17
|
const { name, _id, compute = {} } = modifier;
|
package/lib/modifier/index.js
CHANGED
|
@@ -148,6 +148,7 @@ const isCalculatedPaymentModifier = require('./isCalculatedPaymentModifier');
|
|
|
148
148
|
const isChild = require('./isChild');
|
|
149
149
|
const isExtractCalculatedValue = require('./isExtractCalculatedValue');
|
|
150
150
|
const getPriceWithoutModifier = require('./getPriceWithoutModifier');
|
|
151
|
+
const isGroup = require('./isGroup');
|
|
151
152
|
|
|
152
153
|
const modifierActions = (deps = {}) => {
|
|
153
154
|
const actions = {};
|
|
@@ -309,6 +310,7 @@ const modifierActions = (deps = {}) => {
|
|
|
309
310
|
isChild: isChild(innerDeps),
|
|
310
311
|
isExtractCalculatedValue: isExtractCalculatedValue(innerDeps),
|
|
311
312
|
getPriceWithoutModifier: getPriceWithoutModifier(innerDeps),
|
|
313
|
+
isGroup: isGroup(innerDeps),
|
|
312
314
|
});
|
|
313
315
|
|
|
314
316
|
Object.keys(freezedActions).forEach(actionName => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports = ({ actions }) =>
|
|
2
|
+
function isGroup(modifier) {
|
|
3
|
+
if (!modifier) return false;
|
|
4
|
+
return !!(
|
|
5
|
+
actions.hasAttribute(modifier, 'group') ||
|
|
6
|
+
(modifier.properties &&
|
|
7
|
+
modifier.properties.group &&
|
|
8
|
+
Object.keys(modifier.properties.group) > 0)
|
|
9
|
+
);
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"supertest": "^6.2.3",
|
|
41
41
|
"supervisor": "^0.12.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "fc073d4d5ff5b5473b177e9462584caed71f3867"
|
|
44
44
|
}
|