@darkpos/pricing 1.0.51 → 1.0.53
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/{getItemsModifierDescription.test.js → getModifierTags.test.js} +35 -24
- package/__TEST__/item/getNoteTags.test.js +52 -0
- package/__TEST__/item.test.js +293 -0
- package/__TEST__/mocks/addItemMock.js +1 -1
- package/__TEST__/modifier/hasModifier.test.js +1 -1
- package/__TEST__/order/order-payment-modifier.test.js +12 -12
- package/__TEST__/order/order.test.js +44 -3
- package/lib/item/calculate.js +24 -5
- package/lib/item/getBasePrice.js +7 -0
- package/lib/item/getModifierTags.js +45 -0
- package/lib/{modifier/getNotesToModifierTags.js → item/getNoteTags.js} +2 -2
- package/lib/item/index.js +6 -2
- package/lib/item/removeModifier.js +3 -8
- package/lib/modifier/calculate.js +38 -5
- package/lib/modifier/index.js +2 -4
- package/lib/modifier/isGroup.js +1 -6
- package/lib/modifier/isOptionsSelectedOverride.js +7 -0
- package/lib/order/addItemModifier.js +15 -3
- package/lib/order/calculate.js +62 -59
- package/package.json +3 -2
- package/__TEST__/modifier/getNotesToModifierTags.test.js +0 -78
- package/__TEST__/modifier/isComputedOverride.test.js +0 -38
- package/lib/item/getItemModifiersDescription.js +0 -56
- package/lib/modifier/isComputedOverride.js +0 -8
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const usePricing = require('../../lib/index');
|
|
2
2
|
|
|
3
3
|
const pricingService = usePricing();
|
|
4
|
+
const pricingServiceGroupModifiers = usePricing({
|
|
5
|
+
store: { _settings: { order: { groupModifiers: true } } },
|
|
6
|
+
});
|
|
4
7
|
|
|
5
|
-
const { getItemModifiersDescription } = pricingService.item;
|
|
6
8
|
const mockModifier = {
|
|
7
9
|
_id: '67106323db3c71afb52b07b7',
|
|
8
10
|
attributes: ['override'],
|
|
@@ -37,7 +39,7 @@ const mockModifier = {
|
|
|
37
39
|
},
|
|
38
40
|
_computed: {
|
|
39
41
|
amount: 0,
|
|
40
|
-
description: 'ItemsPriceManual
|
|
42
|
+
description: 'ItemsPriceManual',
|
|
41
43
|
},
|
|
42
44
|
addModifiers: [],
|
|
43
45
|
delModifiers: [],
|
|
@@ -46,13 +48,13 @@ const mockModifier = {
|
|
|
46
48
|
_createdAt: '2024-10-17T01:12:34.370Z',
|
|
47
49
|
_updatedAt: '2024-10-17T01:12:34.370Z',
|
|
48
50
|
};
|
|
49
|
-
describe('
|
|
51
|
+
describe('getModifierTags Function', () => {
|
|
50
52
|
beforeEach(() => {
|
|
51
53
|
jest.clearAllMocks();
|
|
52
54
|
});
|
|
53
55
|
|
|
54
56
|
test('should return an empty array if item or modifiers are not provided', () => {
|
|
55
|
-
const result =
|
|
57
|
+
const result = pricingService.item.getModifierTags({});
|
|
56
58
|
expect(result).toEqual([]);
|
|
57
59
|
});
|
|
58
60
|
|
|
@@ -69,50 +71,59 @@ describe('getItemModifiersDescription Function', () => {
|
|
|
69
71
|
],
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
const result =
|
|
74
|
+
const result = pricingService.item.getModifierTags({
|
|
75
|
+
item,
|
|
76
|
+
});
|
|
73
77
|
|
|
74
|
-
expect(result).
|
|
78
|
+
expect(result).toMatchObject([
|
|
75
79
|
{
|
|
76
80
|
label: 'Desc 1',
|
|
77
81
|
value: 'mod1',
|
|
78
82
|
data: item.modifiers[0],
|
|
79
83
|
quantity: 1,
|
|
80
84
|
},
|
|
85
|
+
{
|
|
86
|
+
label: 'ItemsPriceManual',
|
|
87
|
+
value: 'mod2',
|
|
88
|
+
data: item.modifiers[1],
|
|
89
|
+
quantity: 1,
|
|
90
|
+
},
|
|
81
91
|
]);
|
|
82
92
|
});
|
|
83
93
|
|
|
84
94
|
test('should handle selected override options in the modifier', () => {
|
|
85
95
|
const item = {
|
|
86
96
|
modifiers: [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
pricingService.modifier.calculate(
|
|
98
|
+
{
|
|
99
|
+
...mockModifier,
|
|
100
|
+
_id: 'mod1',
|
|
101
|
+
name: 'Modifier 1',
|
|
102
|
+
compute: { amount: 200 },
|
|
103
|
+
properties: {
|
|
104
|
+
override: { selected: { selectedUnit: 'kg', value: 200 } },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{ price: 10, quantity: 1 }
|
|
108
|
+
),
|
|
94
109
|
],
|
|
95
110
|
};
|
|
96
111
|
|
|
97
|
-
const result =
|
|
112
|
+
const result = pricingService.item.getModifierTags({
|
|
113
|
+
item,
|
|
114
|
+
});
|
|
98
115
|
|
|
99
116
|
expect(result).toEqual([
|
|
100
117
|
{
|
|
101
|
-
label: 'Modifier 1
|
|
118
|
+
label: 'Modifier 1 ($200.00/kg)',
|
|
102
119
|
value: 'mod1',
|
|
103
120
|
data: item.modifiers[0],
|
|
104
|
-
quantity:
|
|
121
|
+
quantity: 1,
|
|
105
122
|
},
|
|
106
123
|
]);
|
|
107
124
|
});
|
|
108
125
|
|
|
109
126
|
test('should group modifiers when groupModifiers setting is true', () => {
|
|
110
|
-
const pricingService2 = usePricing({
|
|
111
|
-
store: { _settings: { order: { groupModifiers: true } } },
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const { getItemModifiersDescription: getItemModifiersDescription2 } =
|
|
115
|
-
pricingService2.item;
|
|
116
127
|
const item = {
|
|
117
128
|
modifiers: [
|
|
118
129
|
{
|
|
@@ -124,9 +135,9 @@ describe('getItemModifiersDescription Function', () => {
|
|
|
124
135
|
],
|
|
125
136
|
};
|
|
126
137
|
|
|
127
|
-
const result =
|
|
138
|
+
const result = pricingServiceGroupModifiers.item.getModifierTags({ item });
|
|
128
139
|
|
|
129
|
-
expect(result).
|
|
140
|
+
expect(result).toMatchObject([
|
|
130
141
|
{
|
|
131
142
|
label: '1 Desc 1',
|
|
132
143
|
value: 'mod1',
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const usePricing = require('../../index');
|
|
2
|
+
|
|
3
|
+
const pricingService = usePricing();
|
|
4
|
+
|
|
5
|
+
describe('pricingService.item.getNoteTags Function', () => {
|
|
6
|
+
test('should return empty array if no notes are provided', () => {
|
|
7
|
+
const result = pricingService.item.getNoteTags({
|
|
8
|
+
notes: null,
|
|
9
|
+
});
|
|
10
|
+
expect(result).toEqual([]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('should filter out notes that are null or have a url', () => {
|
|
14
|
+
const notes = [
|
|
15
|
+
{ message: 'Note 1' },
|
|
16
|
+
{ message: 'Note 2', url: 'http://example.com' }, // Should be filtered out
|
|
17
|
+
null, // Should be filtered out
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const result = pricingService.item.getNoteTags({ notes });
|
|
21
|
+
|
|
22
|
+
expect(result).toEqual([
|
|
23
|
+
{ label: 'Note 1', value: '0', data: { message: 'Note 1' }, quantity: 1 },
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('should map notes to noteTags', () => {
|
|
28
|
+
const notes = [{ message: 'Note 1' }, { message: 'Note 2' }];
|
|
29
|
+
|
|
30
|
+
const result = pricingService.item.getNoteTags({ notes });
|
|
31
|
+
|
|
32
|
+
expect(result).toEqual([
|
|
33
|
+
{ label: 'Note 1', value: '0', data: { message: 'Note 1' }, quantity: 1 },
|
|
34
|
+
{ label: 'Note 2', value: '1', data: { message: 'Note 2' }, quantity: 1 },
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('should handle case where notes contain falsy values', () => {
|
|
39
|
+
const notes = [null, undefined, { message: 'Valid Note' }];
|
|
40
|
+
|
|
41
|
+
const result = pricingService.item.getNoteTags({ notes });
|
|
42
|
+
|
|
43
|
+
expect(result).toEqual([
|
|
44
|
+
{
|
|
45
|
+
label: 'Valid Note',
|
|
46
|
+
value: '0',
|
|
47
|
+
data: { message: 'Valid Note' },
|
|
48
|
+
quantity: 1,
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
});
|
package/__TEST__/item.test.js
CHANGED
|
@@ -536,4 +536,297 @@ describe('Item actions', () => {
|
|
|
536
536
|
_actual: 100,
|
|
537
537
|
});
|
|
538
538
|
});
|
|
539
|
+
test('CU-86dvbn63z: Calculate item with quantity > 1 and modifierAmountFixed10', () => {
|
|
540
|
+
const itemWithModifierAmountFixed10 = {
|
|
541
|
+
name: "Men's 3pc Tuxedo",
|
|
542
|
+
pieces: 3,
|
|
543
|
+
total: 53.03,
|
|
544
|
+
price: 13.5,
|
|
545
|
+
quantity: 3,
|
|
546
|
+
modifiers: [
|
|
547
|
+
{
|
|
548
|
+
_id: '675354ee39a47228afd1f1a4',
|
|
549
|
+
attributes: ['override'],
|
|
550
|
+
modifierId: '6751f7eeb60c71cefee138ee',
|
|
551
|
+
name: 'Override modamount fixed 10',
|
|
552
|
+
group: 'Upcharge',
|
|
553
|
+
type: 'fee',
|
|
554
|
+
tags: ['default', 'all'],
|
|
555
|
+
direct: true,
|
|
556
|
+
properties: {
|
|
557
|
+
override: {
|
|
558
|
+
type: 'fixed',
|
|
559
|
+
field: 'amount',
|
|
560
|
+
fixedValue: 10,
|
|
561
|
+
multiplier: false,
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
compute: { type: 'fixed', amount: 10, action: 'add' },
|
|
565
|
+
},
|
|
566
|
+
],
|
|
567
|
+
_id: '675354e939a47228afd1f199',
|
|
568
|
+
properties: { basePrice: 13.5 },
|
|
569
|
+
|
|
570
|
+
itemId: '62cdbfd01ee1b400193281ee',
|
|
571
|
+
};
|
|
572
|
+
const newItem = pricingService.item.calculate(
|
|
573
|
+
itemWithModifierAmountFixed10
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
expect(newItem).toHaveProperty('total', 50.5);
|
|
577
|
+
expect(newItem).toHaveProperty('price', 13.5);
|
|
578
|
+
expect(newItem.modifiers[0]).toHaveProperty('_computed', {
|
|
579
|
+
amount: 10,
|
|
580
|
+
description: 'Override modamount fixed 10 ($10.00)',
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
expect(newItem).toHaveProperty('subTotals', {
|
|
584
|
+
fee: 10,
|
|
585
|
+
_included: 0,
|
|
586
|
+
_xincluded: 10,
|
|
587
|
+
_direct: 10,
|
|
588
|
+
_xdirect: 0,
|
|
589
|
+
_simple: 40.5,
|
|
590
|
+
_actual: 40.5,
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
test('CU-86dvbn63z: Calculate item with quantity > 1 and modifierAmountFixed10 Multiplier', () => {
|
|
595
|
+
const itemWithModifierAmountFixed10Multiplier = {
|
|
596
|
+
name: "Men's 3pc Tuxedo",
|
|
597
|
+
pieces: 3,
|
|
598
|
+
total: 53.03,
|
|
599
|
+
price: 13.5,
|
|
600
|
+
quantity: 3,
|
|
601
|
+
modifiers: [
|
|
602
|
+
{
|
|
603
|
+
_id: '675354ee39a47228afd1f1a4',
|
|
604
|
+
attributes: ['override'],
|
|
605
|
+
modifierId: '6751f7eeb60c71cefee138ee',
|
|
606
|
+
name: 'Override modamount fixed 10',
|
|
607
|
+
group: 'Upcharge',
|
|
608
|
+
type: 'fee',
|
|
609
|
+
tags: ['default', 'all'],
|
|
610
|
+
direct: true,
|
|
611
|
+
properties: {
|
|
612
|
+
override: {
|
|
613
|
+
type: 'fixed',
|
|
614
|
+
field: 'amount',
|
|
615
|
+
fixedValue: 10,
|
|
616
|
+
multiplier: true,
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
compute: { type: 'fixed', amount: 10, action: 'add' },
|
|
620
|
+
},
|
|
621
|
+
],
|
|
622
|
+
_id: '675354e939a47228afd1f199',
|
|
623
|
+
properties: { basePrice: 13.5 },
|
|
624
|
+
|
|
625
|
+
itemId: '62cdbfd01ee1b400193281ee',
|
|
626
|
+
};
|
|
627
|
+
const newItem = pricingService.item.calculate(
|
|
628
|
+
itemWithModifierAmountFixed10Multiplier
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
expect(newItem).toHaveProperty('total', 70.5);
|
|
632
|
+
expect(newItem).toHaveProperty('price', 13.5);
|
|
633
|
+
expect(newItem.modifiers[0]).toHaveProperty('_computed', {
|
|
634
|
+
amount: 10,
|
|
635
|
+
description: 'Override modamount fixed 10 ($30.00)',
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
expect(newItem).toHaveProperty('subTotals', {
|
|
639
|
+
fee: 30,
|
|
640
|
+
_included: 0,
|
|
641
|
+
_xincluded: 30,
|
|
642
|
+
_direct: 30,
|
|
643
|
+
_xdirect: 0,
|
|
644
|
+
_simple: 40.5,
|
|
645
|
+
_actual: 40.5,
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
test('CU-86dvbn63z: Calculate item with quantity > 1 and quantity override modifier', () => {
|
|
650
|
+
const itemWithQuantityOverride5 = {
|
|
651
|
+
name: "Men's 3pc Tuxedo",
|
|
652
|
+
pieces: 3,
|
|
653
|
+
total: 70.88,
|
|
654
|
+
price: 13.5,
|
|
655
|
+
quantity: 5,
|
|
656
|
+
modifiers: [
|
|
657
|
+
{
|
|
658
|
+
_id: '67535f3ab4c5ea63d2d7964b',
|
|
659
|
+
attributes: ['override'],
|
|
660
|
+
modifierId: '675359b5d08f91f558233f85',
|
|
661
|
+
_parentId: null,
|
|
662
|
+
locked: false,
|
|
663
|
+
name: 'Override Item Quantity 5',
|
|
664
|
+
sku: '',
|
|
665
|
+
description: '',
|
|
666
|
+
group: 'Upcharge',
|
|
667
|
+
type: 'tax',
|
|
668
|
+
tags: ['default'],
|
|
669
|
+
order: 0,
|
|
670
|
+
included: false,
|
|
671
|
+
direct: true,
|
|
672
|
+
hidden: false,
|
|
673
|
+
print: true,
|
|
674
|
+
required: false,
|
|
675
|
+
recommended: false,
|
|
676
|
+
default: false,
|
|
677
|
+
code: '',
|
|
678
|
+
properties: {
|
|
679
|
+
subscription: {},
|
|
680
|
+
override: { type: 'fixed', field: 'quantity', fixedValue: 5 },
|
|
681
|
+
group: { items: [], modifiers: [] },
|
|
682
|
+
department: {},
|
|
683
|
+
sort: null,
|
|
684
|
+
},
|
|
685
|
+
_computed: { amount: 0, description: 'Override Item Quantity 5' },
|
|
686
|
+
addModifiers: [],
|
|
687
|
+
delModifiers: [],
|
|
688
|
+
conditions: { valid: true },
|
|
689
|
+
compute: null,
|
|
690
|
+
_createdAt: '2024-12-06T20:08:21.409Z',
|
|
691
|
+
_updatedAt: '2024-12-06T20:18:37.174Z',
|
|
692
|
+
},
|
|
693
|
+
],
|
|
694
|
+
_id: '67535f34b4c5ea63d2d79640',
|
|
695
|
+
properties: { basePrice: 13.5 },
|
|
696
|
+
itemId: '62cdbfd01ee1b400193281ee',
|
|
697
|
+
menuRuleId: '65660855dfffaf2da26fb870',
|
|
698
|
+
__typename: 'OrderItem',
|
|
699
|
+
};
|
|
700
|
+
const newItem = pricingService.item.calculate(itemWithQuantityOverride5);
|
|
701
|
+
|
|
702
|
+
expect(newItem).toHaveProperty('total', 67.5);
|
|
703
|
+
expect(newItem).toHaveProperty('price', 13.5);
|
|
704
|
+
expect(newItem.modifiers[0]).toHaveProperty('_computed', {
|
|
705
|
+
amount: 0,
|
|
706
|
+
description: 'Override Item Quantity 5',
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
expect(newItem).toHaveProperty('subTotals', {
|
|
710
|
+
_included: 0,
|
|
711
|
+
_xincluded: 0,
|
|
712
|
+
_direct: 0,
|
|
713
|
+
_xdirect: 0,
|
|
714
|
+
_simple: 67.5,
|
|
715
|
+
_actual: 67.5,
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
test('CU-86dvbn63z: Calculate item with quantity > 1 and modifieritemPriceFixed10', () => {
|
|
720
|
+
const itemWithModifierAmountFixed10 = {
|
|
721
|
+
name: "Men's 3pc Tuxedo",
|
|
722
|
+
pieces: 3,
|
|
723
|
+
price: 10,
|
|
724
|
+
quantity: 3,
|
|
725
|
+
modifiers: [
|
|
726
|
+
{
|
|
727
|
+
_id: '675354ee39a47228afd1f1a4',
|
|
728
|
+
attributes: ['override'],
|
|
729
|
+
modifierId: '6751f7eeb60c71cefee138ee',
|
|
730
|
+
name: 'Override item price fixed 10',
|
|
731
|
+
group: 'Upcharge',
|
|
732
|
+
type: 'fee',
|
|
733
|
+
tags: ['default', 'all'],
|
|
734
|
+
direct: true,
|
|
735
|
+
properties: {
|
|
736
|
+
override: {
|
|
737
|
+
type: 'fixed',
|
|
738
|
+
field: 'price',
|
|
739
|
+
fixedValue: 10,
|
|
740
|
+
multiplier: false,
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
compute: { type: 'fixed', amount: 10, action: 'add' },
|
|
744
|
+
},
|
|
745
|
+
],
|
|
746
|
+
_id: '675354e939a47228afd1f199',
|
|
747
|
+
properties: { basePrice: 13.5 },
|
|
748
|
+
|
|
749
|
+
itemId: '62cdbfd01ee1b400193281ee',
|
|
750
|
+
};
|
|
751
|
+
const newItem = pricingService.item.calculate(
|
|
752
|
+
itemWithModifierAmountFixed10
|
|
753
|
+
);
|
|
754
|
+
|
|
755
|
+
expect(newItem).toHaveProperty('total', 30);
|
|
756
|
+
expect(newItem).toHaveProperty('price', 10);
|
|
757
|
+
expect(newItem.modifiers[0]).toHaveProperty('_computed', {
|
|
758
|
+
amount: 0,
|
|
759
|
+
description: 'Override item price fixed 10 ($10.00/Unit)',
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
expect(newItem).toHaveProperty('subTotals', {
|
|
763
|
+
_included: 0,
|
|
764
|
+
_xincluded: 0,
|
|
765
|
+
_direct: 0,
|
|
766
|
+
_xdirect: 0,
|
|
767
|
+
_simple: 30,
|
|
768
|
+
_actual: 30,
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
test('CU-86dvbn63z: Calculate item with quantity > 1 and modifieritemPriceFixed1 multiplier', () => {
|
|
773
|
+
const item = {
|
|
774
|
+
name: "Men's 3pc Tuxedo",
|
|
775
|
+
pieces: 3,
|
|
776
|
+
total: 141.75,
|
|
777
|
+
price: 135,
|
|
778
|
+
quantity: 1,
|
|
779
|
+
modifiers: [
|
|
780
|
+
{
|
|
781
|
+
_id: '67536495bc57ccecf751a5dc',
|
|
782
|
+
attributes: ['override'],
|
|
783
|
+
modifierId: '6751e9c0b60c71cefee0c3cc',
|
|
784
|
+
_parentId: null,
|
|
785
|
+
locked: false,
|
|
786
|
+
name: 'Override Item Price 10 USD Multiplier',
|
|
787
|
+
group: 'Upcharge',
|
|
788
|
+
type: 'fee',
|
|
789
|
+
tags: ['default', 'all'],
|
|
790
|
+
|
|
791
|
+
direct: true,
|
|
792
|
+
|
|
793
|
+
properties: {
|
|
794
|
+
override: {
|
|
795
|
+
type: 'fixed',
|
|
796
|
+
field: 'price',
|
|
797
|
+
fixedValue: 10,
|
|
798
|
+
multiplier: true,
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
_computed: {
|
|
802
|
+
amount: 0,
|
|
803
|
+
description:
|
|
804
|
+
'Override Item Price 10 USD Multiplier (10 Unit @ $13.50/Unit)',
|
|
805
|
+
},
|
|
806
|
+
compute: { amount: 10 },
|
|
807
|
+
},
|
|
808
|
+
],
|
|
809
|
+
_id: '675360d5bc57ccecf751a5b5',
|
|
810
|
+
properties: { basePrice: 13.5 },
|
|
811
|
+
itemId: '62cdbfd01ee1b400193281ee',
|
|
812
|
+
};
|
|
813
|
+
const newItem = pricingService.item.calculate(item);
|
|
814
|
+
|
|
815
|
+
expect(newItem).toHaveProperty('total', 135);
|
|
816
|
+
expect(newItem).toHaveProperty('price', 135);
|
|
817
|
+
expect(newItem.modifiers[0]).toHaveProperty('_computed', {
|
|
818
|
+
amount: 0,
|
|
819
|
+
description:
|
|
820
|
+
'Override Item Price 10 USD Multiplier (10 Unit @ $13.50/Unit)',
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
expect(newItem).toHaveProperty('subTotals', {
|
|
824
|
+
_included: 0,
|
|
825
|
+
_xincluded: 0,
|
|
826
|
+
_direct: 0,
|
|
827
|
+
_xdirect: 0,
|
|
828
|
+
_simple: 135,
|
|
829
|
+
_actual: 135,
|
|
830
|
+
});
|
|
831
|
+
});
|
|
539
832
|
});
|
|
@@ -60,7 +60,7 @@ describe('Order actions', () => {
|
|
|
60
60
|
expect(cashPercentageDiscountOrder.items[0].modifiers[0]._computed).toEqual(
|
|
61
61
|
expect.objectContaining({
|
|
62
62
|
amount: 0,
|
|
63
|
-
description: 'CASH 10% DISCOUNT
|
|
63
|
+
description: 'CASH 10% DISCOUNT',
|
|
64
64
|
})
|
|
65
65
|
);
|
|
66
66
|
|
|
@@ -469,7 +469,7 @@ describe('Order actions', () => {
|
|
|
469
469
|
expect(testOrder.items[0].modifiers[0]._computed).toEqual(
|
|
470
470
|
expect.objectContaining({
|
|
471
471
|
amount: 0,
|
|
472
|
-
description: 'CASH 20% DISCOUNT
|
|
472
|
+
description: 'CASH 20% DISCOUNT',
|
|
473
473
|
})
|
|
474
474
|
);
|
|
475
475
|
|
|
@@ -500,7 +500,7 @@ describe('Order actions', () => {
|
|
|
500
500
|
expect(testOrder.items[0].modifiers[0]._computed).toEqual(
|
|
501
501
|
expect.objectContaining({
|
|
502
502
|
amount: 0,
|
|
503
|
-
description: 'CASH 20% DISCOUNT
|
|
503
|
+
description: 'CASH 20% DISCOUNT',
|
|
504
504
|
})
|
|
505
505
|
);
|
|
506
506
|
|
|
@@ -533,7 +533,7 @@ describe('Order actions', () => {
|
|
|
533
533
|
expect(testOrder.items[0].modifiers[0]._computed).toEqual(
|
|
534
534
|
expect.objectContaining({
|
|
535
535
|
amount: 0,
|
|
536
|
-
description: 'CASH 20% DISCOUNT
|
|
536
|
+
description: 'CASH 20% DISCOUNT',
|
|
537
537
|
})
|
|
538
538
|
);
|
|
539
539
|
|
|
@@ -589,7 +589,7 @@ describe('Order actions', () => {
|
|
|
589
589
|
expect(fullyPaidOrderWithCredit.items[0].modifiers[0]._computed).toEqual(
|
|
590
590
|
expect.objectContaining({
|
|
591
591
|
amount: 0,
|
|
592
|
-
description: 'CASH 20% DISCOUNT
|
|
592
|
+
description: 'CASH 20% DISCOUNT',
|
|
593
593
|
})
|
|
594
594
|
);
|
|
595
595
|
|
|
@@ -638,7 +638,7 @@ describe('Order actions', () => {
|
|
|
638
638
|
expect(fullyPaidOrderWithCash.items[0].modifiers[0]._computed).toEqual(
|
|
639
639
|
expect.objectContaining({
|
|
640
640
|
amount: 0,
|
|
641
|
-
description: 'CASH 20% DISCOUNT
|
|
641
|
+
description: 'CASH 20% DISCOUNT',
|
|
642
642
|
})
|
|
643
643
|
);
|
|
644
644
|
|
|
@@ -719,7 +719,7 @@ describe('Order actions', () => {
|
|
|
719
719
|
},
|
|
720
720
|
_computed: {
|
|
721
721
|
amount: 0,
|
|
722
|
-
description: 'Alice Blue
|
|
722
|
+
description: 'Alice Blue',
|
|
723
723
|
},
|
|
724
724
|
addModifiers: [],
|
|
725
725
|
delModifiers: [],
|
|
@@ -762,7 +762,7 @@ describe('Order actions', () => {
|
|
|
762
762
|
},
|
|
763
763
|
_computed: {
|
|
764
764
|
amount: 0,
|
|
765
|
-
description: 'CASH 20% DISCOUNT
|
|
765
|
+
description: 'CASH 20% DISCOUNT',
|
|
766
766
|
},
|
|
767
767
|
addModifiers: [],
|
|
768
768
|
delModifiers: [],
|
|
@@ -810,7 +810,7 @@ describe('Order actions', () => {
|
|
|
810
810
|
},
|
|
811
811
|
_computed: {
|
|
812
812
|
amount: 0,
|
|
813
|
-
description: 'Light
|
|
813
|
+
description: 'Light',
|
|
814
814
|
},
|
|
815
815
|
addModifiers: [],
|
|
816
816
|
delModifiers: [],
|
|
@@ -857,7 +857,7 @@ describe('Order actions', () => {
|
|
|
857
857
|
},
|
|
858
858
|
_computed: {
|
|
859
859
|
amount: 0,
|
|
860
|
-
description: 'Box
|
|
860
|
+
description: 'Box',
|
|
861
861
|
},
|
|
862
862
|
addModifiers: [],
|
|
863
863
|
delModifiers: [],
|
|
@@ -1096,14 +1096,14 @@ describe('Order actions', () => {
|
|
|
1096
1096
|
expect(resultedOrder.items[0].modifiers[0]._computed).toEqual(
|
|
1097
1097
|
expect.objectContaining({
|
|
1098
1098
|
amount: 0,
|
|
1099
|
-
description: 'Alice Blue ($
|
|
1099
|
+
description: 'Alice Blue (0 Unit @ $13.50/Unit)',
|
|
1100
1100
|
})
|
|
1101
1101
|
);
|
|
1102
1102
|
|
|
1103
1103
|
expect(resultedOrder.items[0].modifiers[1]._computed).toEqual(
|
|
1104
1104
|
expect.objectContaining({
|
|
1105
1105
|
amount: 0,
|
|
1106
|
-
description: 'CASH 20% DISCOUNT
|
|
1106
|
+
description: 'CASH 20% DISCOUNT',
|
|
1107
1107
|
})
|
|
1108
1108
|
);
|
|
1109
1109
|
|
|
@@ -1377,7 +1377,7 @@ describe('Order actions', () => {
|
|
|
1377
1377
|
},
|
|
1378
1378
|
_computed: {
|
|
1379
1379
|
amount: 0,
|
|
1380
|
-
description: 'Laundry
|
|
1380
|
+
description: 'Laundry',
|
|
1381
1381
|
},
|
|
1382
1382
|
addModifiers: [],
|
|
1383
1383
|
delModifiers: [],
|
|
@@ -1455,7 +1455,7 @@ describe('Order actions', () => {
|
|
|
1455
1455
|
},
|
|
1456
1456
|
_computed: {
|
|
1457
1457
|
amount: 0,
|
|
1458
|
-
description: 'Dry Cleaning
|
|
1458
|
+
description: 'Dry Cleaning',
|
|
1459
1459
|
},
|
|
1460
1460
|
addModifiers: [],
|
|
1461
1461
|
delModifiers: [],
|
|
@@ -1533,7 +1533,7 @@ describe('Order actions', () => {
|
|
|
1533
1533
|
},
|
|
1534
1534
|
_computed: {
|
|
1535
1535
|
amount: 0,
|
|
1536
|
-
description: 'Dry Cleaning
|
|
1536
|
+
description: 'Dry Cleaning',
|
|
1537
1537
|
},
|
|
1538
1538
|
addModifiers: [],
|
|
1539
1539
|
delModifiers: [],
|
|
@@ -2620,4 +2620,45 @@ describe('Order actions', () => {
|
|
|
2620
2620
|
_actual: 4.65,
|
|
2621
2621
|
});
|
|
2622
2622
|
});
|
|
2623
|
+
|
|
2624
|
+
test('CU-86dvd3dbp Get calculated Order, multiple items and indirect modifiers #2 toNeareastMultiple (No Order Modifiers)', () => {
|
|
2625
|
+
const pricingService2 = usePricing({
|
|
2626
|
+
store: { _settings: { localization: { nearestMultiple: '0.5' } } },
|
|
2627
|
+
});
|
|
2628
|
+
|
|
2629
|
+
const item1 = {
|
|
2630
|
+
_id: 1,
|
|
2631
|
+
price: 15.99,
|
|
2632
|
+
quantity: 1,
|
|
2633
|
+
};
|
|
2634
|
+
const item2 = {
|
|
2635
|
+
_id: 2,
|
|
2636
|
+
price: 4.65,
|
|
2637
|
+
quantity: 1,
|
|
2638
|
+
};
|
|
2639
|
+
|
|
2640
|
+
const order = { items: [item1, item2] };
|
|
2641
|
+
const newOrder = pricingService2.order.calculate(order);
|
|
2642
|
+
expect(newOrder).toHaveProperty('total', 21);
|
|
2643
|
+
expect(newOrder).toHaveProperty('subTotal', 20.64);
|
|
2644
|
+
expect(newOrder).toHaveProperty('subTotals', {});
|
|
2645
|
+
expect(newOrder.items[0]).toHaveProperty('total', 16.35);
|
|
2646
|
+
expect(newOrder.items[0]).toHaveProperty('subTotals', {
|
|
2647
|
+
_included: 0,
|
|
2648
|
+
_xincluded: 0,
|
|
2649
|
+
_direct: 0,
|
|
2650
|
+
_xdirect: 0,
|
|
2651
|
+
_simple: 15.99,
|
|
2652
|
+
_actual: 15.99,
|
|
2653
|
+
});
|
|
2654
|
+
expect(newOrder.items[1]).toHaveProperty('total', 4.65);
|
|
2655
|
+
expect(newOrder.items[1]).toHaveProperty('subTotals', {
|
|
2656
|
+
_included: 0,
|
|
2657
|
+
_xincluded: 0,
|
|
2658
|
+
_direct: 0,
|
|
2659
|
+
_xdirect: 0,
|
|
2660
|
+
_simple: 4.65,
|
|
2661
|
+
_actual: 4.65,
|
|
2662
|
+
});
|
|
2663
|
+
});
|
|
2623
2664
|
});
|