@darkpos/pricing 1.0.135 → 1.0.137
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.
|
@@ -58,7 +58,7 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
58
58
|
modifiers,
|
|
59
59
|
entity: customer,
|
|
60
60
|
})
|
|
61
|
-
).toHaveLength(
|
|
61
|
+
).toHaveLength(1);
|
|
62
62
|
modifiers = [{ tags: ['test'] }];
|
|
63
63
|
expect(
|
|
64
64
|
pricingService.modifier.getMatchTagsModifiers({
|
|
@@ -79,7 +79,7 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
79
79
|
modifiers,
|
|
80
80
|
entity: customer,
|
|
81
81
|
})
|
|
82
|
-
).toHaveLength(
|
|
82
|
+
).toHaveLength(2);
|
|
83
83
|
modifiers = [
|
|
84
84
|
{ tags: ['all'] },
|
|
85
85
|
{ tags: ['test'] },
|
|
@@ -91,7 +91,7 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
91
91
|
modifiers,
|
|
92
92
|
entity: customer,
|
|
93
93
|
})
|
|
94
|
-
).toHaveLength(
|
|
94
|
+
).toHaveLength(2);
|
|
95
95
|
modifiers = [
|
|
96
96
|
{ tags: ['all'] },
|
|
97
97
|
{ tags: ['test'] },
|
|
@@ -104,7 +104,7 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
104
104
|
modifiers,
|
|
105
105
|
entity: customer,
|
|
106
106
|
})
|
|
107
|
-
).toHaveLength(
|
|
107
|
+
).toHaveLength(3);
|
|
108
108
|
modifiers = [{ tags: ['all'] }];
|
|
109
109
|
expect(
|
|
110
110
|
pricingService.modifier.getMatchTagsModifiers({
|
|
@@ -130,7 +130,7 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
130
130
|
modifiers,
|
|
131
131
|
entity: customer,
|
|
132
132
|
})
|
|
133
|
-
).toHaveLength(
|
|
133
|
+
).toHaveLength(3);
|
|
134
134
|
customer.tags = ['all'];
|
|
135
135
|
expect(
|
|
136
136
|
pricingService.modifier.getMatchTagsModifiers({
|
|
@@ -158,6 +158,6 @@ describe('GetMatchTagsModifiers Function', () => {
|
|
|
158
158
|
modifiers,
|
|
159
159
|
entity: customer,
|
|
160
160
|
})
|
|
161
|
-
).toHaveLength(
|
|
161
|
+
).toHaveLength(6);
|
|
162
162
|
});
|
|
163
163
|
});
|
|
@@ -31,9 +31,9 @@ describe('Has Match Tags Function', () => {
|
|
|
31
31
|
);
|
|
32
32
|
customer.tags = ['test'];
|
|
33
33
|
modifier.tags = ['test'];
|
|
34
|
-
expect(pricingService.modifier.hasMatchTags(customer)).toBe(
|
|
34
|
+
expect(pricingService.modifier.hasMatchTags(customer)).toBe(true);
|
|
35
35
|
expect(pricingService.modifier.hasMatchTags(undefined, modifier)).toBe(
|
|
36
|
-
|
|
36
|
+
true
|
|
37
37
|
);
|
|
38
38
|
customer.tags = ['test'];
|
|
39
39
|
modifier.tags = ['all'];
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
module.exports = ({ actions }) =>
|
|
2
|
-
/* checks if the customer can be matched with the entity or not,
|
|
3
|
-
* This function will return true in these conditions:
|
|
4
|
-
* Neither customer nor the entity has any tags
|
|
5
|
-
* Customer has no tags and entity has the 'all' tag
|
|
6
|
-
* customer has the 'all' tag and entity has no tags
|
|
7
|
-
* customer and entity have at least one exact tag (case-sensitive)
|
|
8
|
-
* In any other case the function should return false
|
|
9
|
-
* */
|
|
10
2
|
function hasMatchTags(modifier, entity) {
|
|
11
3
|
const entityNoTags = actions.hasNoTags(entity);
|
|
12
4
|
const modifierNoTags = actions.hasNoTags(modifier);
|
|
13
|
-
if (
|
|
14
|
-
(modifierNoTags && entityNoTags) ||
|
|
15
|
-
(entityNoTags && actions.hasAllTag(modifier)) || // customer has no tags but modifier has the all tag
|
|
16
|
-
(modifierNoTags && actions.hasAllTag(entity)) // modifier has no tags but customer has the all tag
|
|
17
|
-
) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!entity || !entity.tags) return false;
|
|
22
|
-
if (!modifier || !modifier.tags) return false;
|
|
5
|
+
if (modifierNoTags || entityNoTags) return true;
|
|
23
6
|
|
|
24
7
|
const sameTag = modifier.tags.find(tag => entity.tags.includes(tag));
|
|
25
8
|
|
|
@@ -23,7 +23,7 @@ module.exports = ({ actions, settings, _ }) => {
|
|
|
23
23
|
...rest,
|
|
24
24
|
parentId: orderSettings.allowSuborder ? _id : null,
|
|
25
25
|
status: {
|
|
26
|
-
order: 'open',
|
|
26
|
+
order: status.order || 'open',
|
|
27
27
|
delivery: status.delivery || false,
|
|
28
28
|
detailed: status.detailed || false,
|
|
29
29
|
paid: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.137",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"supertest": "^6.2.3",
|
|
53
53
|
"supervisor": "^0.12.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3682dadc4e1f7231918dc3e3a4581a46c41cd8b2"
|
|
56
56
|
}
|