@darkpos/pricing 1.0.95 → 1.0.96
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/__TEST__/item.test.js +1 -12
- package/__TEST__/manualTest.test.js +1 -3
- package/__TEST__/modifier/getInvalidRequiredModifiers.test.js +0 -1
- package/__TEST__/modifier.test.js +1 -4
- package/__TEST__/order/order.test.js +0 -15
- package/lib/item/getBasePrice.js +1 -3
- package/lib/modifier/createDescription.js +5 -2
- package/lib/order/addItemModifier.js +0 -8
- package/lib/order/removeItemModifier.js +1 -7
- package/package.json +2 -2
package/__TEST__/item.test.js
CHANGED
|
@@ -597,7 +597,6 @@ describe('Item actions', () => {
|
|
|
597
597
|
},
|
|
598
598
|
],
|
|
599
599
|
_id: '675354e939a47228afd1f199',
|
|
600
|
-
properties: { basePrice: 13.5 },
|
|
601
600
|
|
|
602
601
|
itemId: '62cdbfd01ee1b400193281ee',
|
|
603
602
|
};
|
|
@@ -651,7 +650,6 @@ describe('Item actions', () => {
|
|
|
651
650
|
},
|
|
652
651
|
],
|
|
653
652
|
_id: '675354e939a47228afd1f199',
|
|
654
|
-
properties: { basePrice: 13.5 },
|
|
655
653
|
|
|
656
654
|
itemId: '62cdbfd01ee1b400193281ee',
|
|
657
655
|
};
|
|
@@ -704,7 +702,6 @@ describe('Item actions', () => {
|
|
|
704
702
|
quantity: 3,
|
|
705
703
|
modifiers: [quantityOverrideMod],
|
|
706
704
|
_id: '67535f34b4c5ea63d2d79640',
|
|
707
|
-
properties: { basePrice: 13.5 },
|
|
708
705
|
itemId: '62cdbfd01ee1b400193281ee',
|
|
709
706
|
menuRuleId: '65660855dfffaf2da26fb870',
|
|
710
707
|
__typename: 'OrderItem',
|
|
@@ -780,7 +777,6 @@ describe('Item actions', () => {
|
|
|
780
777
|
},
|
|
781
778
|
],
|
|
782
779
|
_id: '675354e939a47228afd1f199',
|
|
783
|
-
properties: { basePrice: 13.5 },
|
|
784
780
|
|
|
785
781
|
itemId: '62cdbfd01ee1b400193281ee',
|
|
786
782
|
};
|
|
@@ -810,7 +806,7 @@ describe('Item actions', () => {
|
|
|
810
806
|
name: "Men's 3pc Tuxedo",
|
|
811
807
|
pieces: 3,
|
|
812
808
|
total: 141.75,
|
|
813
|
-
price:
|
|
809
|
+
price: 13.5,
|
|
814
810
|
quantity: 1,
|
|
815
811
|
modifiers: [
|
|
816
812
|
{
|
|
@@ -837,7 +833,6 @@ describe('Item actions', () => {
|
|
|
837
833
|
},
|
|
838
834
|
],
|
|
839
835
|
_id: '675360d5bc57ccecf751a5b5',
|
|
840
|
-
properties: { basePrice: 13.5 },
|
|
841
836
|
itemId: '62cdbfd01ee1b400193281ee',
|
|
842
837
|
};
|
|
843
838
|
const newItem = pricingService.item.calculate(item);
|
|
@@ -1161,9 +1156,6 @@ describe('Item actions', () => {
|
|
|
1161
1156
|
modifiers: [groupMod],
|
|
1162
1157
|
_id: '67e2cadd8dcf08ebcc5ef887',
|
|
1163
1158
|
__typename: 'OrderItem',
|
|
1164
|
-
properties: {
|
|
1165
|
-
basePrice: 100,
|
|
1166
|
-
},
|
|
1167
1159
|
};
|
|
1168
1160
|
|
|
1169
1161
|
const relatedItem1 = {
|
|
@@ -1259,9 +1251,6 @@ describe('Item actions', () => {
|
|
|
1259
1251
|
modifiers: [groupMod, rawRelatedMod1],
|
|
1260
1252
|
_id: '67e2cadd8dcf08ebcc5ef887',
|
|
1261
1253
|
__typename: 'OrderItem',
|
|
1262
|
-
properties: {
|
|
1263
|
-
basePrice: 100,
|
|
1264
|
-
},
|
|
1265
1254
|
};
|
|
1266
1255
|
|
|
1267
1256
|
const relatedItem1 = {
|
|
@@ -162,9 +162,7 @@ describe('Modifier actions', () => {
|
|
|
162
162
|
itemId: '123',
|
|
163
163
|
price: 100,
|
|
164
164
|
modifiers: [],
|
|
165
|
-
properties: {
|
|
166
|
-
basePrice: 100,
|
|
167
|
-
},
|
|
165
|
+
properties: {},
|
|
168
166
|
});
|
|
169
167
|
|
|
170
168
|
const conditionsBag = [];
|
|
@@ -467,7 +465,6 @@ describe('Modifier actions', () => {
|
|
|
467
465
|
url: null,
|
|
468
466
|
color: 'rgba(254,86,33,1)',
|
|
469
467
|
iconName: 'ActivitySquare',
|
|
470
|
-
basePrice: 213,
|
|
471
468
|
},
|
|
472
469
|
hasInventory: true,
|
|
473
470
|
inventoryType: 'push',
|
|
@@ -3300,9 +3300,6 @@ describe('Order actions', () => {
|
|
|
3300
3300
|
totalPaid: 0,
|
|
3301
3301
|
notes: [],
|
|
3302
3302
|
subTotals: {},
|
|
3303
|
-
properties: {
|
|
3304
|
-
basePrice: 0,
|
|
3305
|
-
},
|
|
3306
3303
|
};
|
|
3307
3304
|
|
|
3308
3305
|
const item2 = {
|
|
@@ -3322,9 +3319,6 @@ describe('Order actions', () => {
|
|
|
3322
3319
|
total: 12,
|
|
3323
3320
|
totalPaid: 0,
|
|
3324
3321
|
subTotals: {},
|
|
3325
|
-
properties: {
|
|
3326
|
-
basePrice: 12,
|
|
3327
|
-
},
|
|
3328
3322
|
};
|
|
3329
3323
|
|
|
3330
3324
|
const order = {
|
|
@@ -3474,9 +3468,6 @@ describe('Order actions', () => {
|
|
|
3474
3468
|
totalPaid: 0,
|
|
3475
3469
|
notes: [],
|
|
3476
3470
|
subTotals: {},
|
|
3477
|
-
properties: {
|
|
3478
|
-
basePrice: 0,
|
|
3479
|
-
},
|
|
3480
3471
|
};
|
|
3481
3472
|
|
|
3482
3473
|
const item2 = {
|
|
@@ -3496,9 +3487,6 @@ describe('Order actions', () => {
|
|
|
3496
3487
|
total: 12,
|
|
3497
3488
|
totalPaid: 0,
|
|
3498
3489
|
subTotals: {},
|
|
3499
|
-
properties: {
|
|
3500
|
-
basePrice: 12,
|
|
3501
|
-
},
|
|
3502
3490
|
};
|
|
3503
3491
|
|
|
3504
3492
|
const order = {
|
|
@@ -3648,9 +3636,6 @@ describe('Order actions', () => {
|
|
|
3648
3636
|
totalPaid: 0,
|
|
3649
3637
|
notes: [],
|
|
3650
3638
|
subTotals: {},
|
|
3651
|
-
properties: {
|
|
3652
|
-
basePrice: 0,
|
|
3653
|
-
},
|
|
3654
3639
|
_id: 1,
|
|
3655
3640
|
};
|
|
3656
3641
|
|
package/lib/item/getBasePrice.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = ({ actions, localization, _ }) =>
|
|
1
|
+
module.exports = ({ actions, localization, _, utils }) =>
|
|
2
2
|
function createDescription({ modifier, price }) {
|
|
3
3
|
const { _computed, compute, name } = modifier;
|
|
4
4
|
|
|
@@ -15,8 +15,11 @@ module.exports = ({ actions, localization, _ }) =>
|
|
|
15
15
|
description = `${name}${localAmount ? ` (${localAmount})` : ''}`;
|
|
16
16
|
|
|
17
17
|
if (actions.isPriceOverride(modifier)) {
|
|
18
|
+
const dividedPrice = localization.formatAmount(
|
|
19
|
+
price && compute.amount ? utils.math.div(price, compute.amount) : 0
|
|
20
|
+
);
|
|
18
21
|
description = isMultiplier
|
|
19
|
-
? `${name} (${compute.amount} Unit @ ${
|
|
22
|
+
? `${name} (${compute.amount} Unit @ ${dividedPrice}/Unit)`
|
|
20
23
|
: `${name} (${localization.formatAmount(compute.amount)}/Unit)`;
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -80,8 +80,6 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
|
|
|
80
80
|
order,
|
|
81
81
|
modifier: _modifier,
|
|
82
82
|
item: itemProp,
|
|
83
|
-
customer,
|
|
84
|
-
originalItem,
|
|
85
83
|
onConditionsNotMet,
|
|
86
84
|
onError,
|
|
87
85
|
}) => {
|
|
@@ -115,13 +113,7 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
|
|
|
115
113
|
|
|
116
114
|
item.properties = {
|
|
117
115
|
...(item.properties || {}),
|
|
118
|
-
basePrice: item.price,
|
|
119
116
|
};
|
|
120
|
-
item.price = itemActions.getItemPrice({
|
|
121
|
-
item,
|
|
122
|
-
itemPriceLevels: originalItem ? originalItem.priceLevels : undefined,
|
|
123
|
-
customer,
|
|
124
|
-
});
|
|
125
117
|
|
|
126
118
|
return item;
|
|
127
119
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = ({ actions, modifierActions,
|
|
1
|
+
module.exports = ({ actions, modifierActions, _ }) => {
|
|
2
2
|
const removeModifier = ({ item, modifier }) => {
|
|
3
3
|
const nextItem = { ...item, modifiers: [] };
|
|
4
4
|
|
|
@@ -29,7 +29,6 @@ module.exports = ({ actions, modifierActions, itemActions, _ }) => {
|
|
|
29
29
|
return order;
|
|
30
30
|
|
|
31
31
|
let item = actions.getSelectedItem({ order, itemIndex });
|
|
32
|
-
const customer = actions.getCustomer(order);
|
|
33
32
|
|
|
34
33
|
const contains = modifierActions.contains(item.modifiers, modifier);
|
|
35
34
|
|
|
@@ -42,11 +41,6 @@ module.exports = ({ actions, modifierActions, itemActions, _ }) => {
|
|
|
42
41
|
originalItem,
|
|
43
42
|
});
|
|
44
43
|
|
|
45
|
-
item.price = itemActions.getItemPrice({
|
|
46
|
-
item,
|
|
47
|
-
itemPriceLevels: originalItem ? originalItem.priceLevels : undefined,
|
|
48
|
-
customer,
|
|
49
|
-
});
|
|
50
44
|
order.items[itemIndex] = item;
|
|
51
45
|
|
|
52
46
|
return order;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.96",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"supertest": "^6.2.3",
|
|
55
55
|
"supervisor": "^0.12.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "aed710f165a1442c14bba31c5936682faa6b9364"
|
|
58
58
|
}
|