@darkpos/pricing 1.0.132 → 1.0.134
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__/mocks/partially-paid/order-partially-paid.json +2 -2
- package/__TEST__/order/addItem.test.js +10 -2
- package/__TEST__/order/order-payment-modifier.test.js +25 -25
- package/__TEST__/order/order.test.js +37 -4
- package/__TEST__/order/pickEndDate.test.js +1 -1
- package/__TEST__/order/unpick.order.test.js +9 -9
- package/lib/constants/Status/index.js +2 -2
- package/lib/item/adjustCreditModifiersDifference.js +1 -1
- package/lib/item/adjustFixedModifiersDifference.js +1 -1
- package/lib/item/getAddModifiers.js +11 -0
- package/lib/item/getUpdatedStatus.js +2 -5
- package/lib/item/hasAddModifiers.js +9 -0
- package/lib/item/index.js +6 -2
- package/lib/item/{isFullyPaid.js → isPaid.js} +1 -1
- package/lib/order/addItem.js +5 -0
- package/lib/order/addModifiersToParentItem.js +41 -0
- package/lib/order/calculate.js +1 -1
- package/lib/order/createSubOrder.js +2 -2
- package/lib/order/getUpdatedStatus.js +4 -10
- package/lib/order/index.js +6 -2
- package/lib/order/isPaid.js +6 -0
- package/lib/order/removeEmptyNotes.js +11 -0
- package/lib/order/unpick.js +4 -4
- package/lib/store/pickEndDate.js +3 -3
- package/package.json +2 -2
- package/lib/order/isFullyPaid.js +0 -6
|
@@ -253,7 +253,11 @@ describe('addItem function', () => {
|
|
|
253
253
|
});
|
|
254
254
|
expect(updatedOrder2.items[1]).toMatchObject({
|
|
255
255
|
name: 'the parent item',
|
|
256
|
-
modifiers: [
|
|
256
|
+
modifiers: [
|
|
257
|
+
{
|
|
258
|
+
name: 'General Repair Department',
|
|
259
|
+
},
|
|
260
|
+
],
|
|
257
261
|
});
|
|
258
262
|
|
|
259
263
|
const relatedItem2 = {
|
|
@@ -291,7 +295,11 @@ describe('addItem function', () => {
|
|
|
291
295
|
});
|
|
292
296
|
expect(updatedOrder3.items[2]).toMatchObject({
|
|
293
297
|
name: 'the parent item',
|
|
294
|
-
modifiers: [
|
|
298
|
+
modifiers: [
|
|
299
|
+
{
|
|
300
|
+
name: 'General Repair Department',
|
|
301
|
+
},
|
|
302
|
+
],
|
|
295
303
|
});
|
|
296
304
|
});
|
|
297
305
|
});
|
|
@@ -559,45 +559,45 @@ describe('Order actions', () => {
|
|
|
559
559
|
expect(itemBalance).toEqual(1.25);
|
|
560
560
|
|
|
561
561
|
// paying with a paymenttype that doesn match the payment modifiers
|
|
562
|
-
const
|
|
562
|
+
const paidOrderWithCredit = pricingService.order.calculate(testOrder, {
|
|
563
563
|
paymentType: 'credit',
|
|
564
564
|
amountToPay: 1.25,
|
|
565
565
|
lockPaymentModifiers: true,
|
|
566
566
|
});
|
|
567
|
-
|
|
568
|
-
|
|
567
|
+
paidOrderWithCredit.items[0].totalPaid += 1.25;
|
|
568
|
+
paidOrderWithCredit.totalPaid += 1.25;
|
|
569
569
|
|
|
570
570
|
const orderBalanceWithCredit = pricingService.order.getOrdersBalance({
|
|
571
|
-
orders: [
|
|
571
|
+
orders: [paidOrderWithCredit],
|
|
572
572
|
});
|
|
573
573
|
const itemBalanceWithCredit = pricingService.item.getItemsBalance({
|
|
574
|
-
items:
|
|
574
|
+
items: paidOrderWithCredit.items,
|
|
575
575
|
});
|
|
576
576
|
|
|
577
|
-
expect(
|
|
578
|
-
expect(
|
|
579
|
-
expect(
|
|
577
|
+
expect(paidOrderWithCredit).toHaveProperty('total', 11.59);
|
|
578
|
+
expect(paidOrderWithCredit).toHaveProperty('subTotal', 13.5);
|
|
579
|
+
expect(paidOrderWithCredit).toHaveProperty('subTotals', {
|
|
580
580
|
discount: -2.585,
|
|
581
581
|
fee: 0.675,
|
|
582
582
|
});
|
|
583
583
|
|
|
584
|
-
expect(
|
|
584
|
+
expect(paidOrderWithCredit.items[0].modifiers).toHaveLength(3);
|
|
585
585
|
|
|
586
|
-
expect(
|
|
586
|
+
expect(paidOrderWithCredit.items[0].modifiers[0]._computed).toEqual(
|
|
587
587
|
expect.objectContaining({
|
|
588
588
|
amount: 0,
|
|
589
589
|
description: 'CASH 20% DISCOUNT',
|
|
590
590
|
})
|
|
591
591
|
);
|
|
592
592
|
|
|
593
|
-
expect(
|
|
593
|
+
expect(paidOrderWithCredit.items[0].modifiers[1]._computed).toEqual(
|
|
594
594
|
expect.objectContaining({
|
|
595
595
|
amount: 0.675,
|
|
596
596
|
description: '5% FEE ($0.68)',
|
|
597
597
|
})
|
|
598
598
|
);
|
|
599
599
|
|
|
600
|
-
expect(
|
|
600
|
+
expect(paidOrderWithCredit.items[0].modifiers[2]._computed).toEqual(
|
|
601
601
|
expect.objectContaining({
|
|
602
602
|
amount: -2.585,
|
|
603
603
|
description: '$2.59 discount (-$2.59)',
|
|
@@ -608,52 +608,52 @@ describe('Order actions', () => {
|
|
|
608
608
|
expect(itemBalanceWithCredit).toEqual(0);
|
|
609
609
|
|
|
610
610
|
// paying with a paymenttype that doesn match the payment modifiers
|
|
611
|
-
const
|
|
611
|
+
const paidOrderWithCash = pricingService.order.calculate(testOrder, {
|
|
612
612
|
paymentType: 'cash',
|
|
613
613
|
amountToPay: 1,
|
|
614
614
|
lockPaymentModifiers: true,
|
|
615
615
|
});
|
|
616
|
-
|
|
617
|
-
|
|
616
|
+
paidOrderWithCash.items[0].totalPaid += 1;
|
|
617
|
+
paidOrderWithCash.totalPaid += 1;
|
|
618
618
|
|
|
619
619
|
const orderBalanceWithCash = pricingService.order.getOrdersBalance({
|
|
620
|
-
orders: [
|
|
620
|
+
orders: [paidOrderWithCash],
|
|
621
621
|
});
|
|
622
622
|
const itemBalanceWithCash = pricingService.item.getItemsBalance({
|
|
623
|
-
items:
|
|
623
|
+
items: paidOrderWithCash.items,
|
|
624
624
|
});
|
|
625
625
|
|
|
626
|
-
expect(
|
|
627
|
-
expect(
|
|
628
|
-
expect(
|
|
626
|
+
expect(paidOrderWithCash).toHaveProperty('total', 11.34);
|
|
627
|
+
expect(paidOrderWithCash).toHaveProperty('subTotal', 13.5);
|
|
628
|
+
expect(paidOrderWithCash).toHaveProperty('subTotals', {
|
|
629
629
|
discount: -2.835,
|
|
630
630
|
fee: 0.675,
|
|
631
631
|
});
|
|
632
632
|
|
|
633
|
-
expect(
|
|
633
|
+
expect(paidOrderWithCash.items[0].modifiers).toHaveLength(4);
|
|
634
634
|
|
|
635
|
-
expect(
|
|
635
|
+
expect(paidOrderWithCash.items[0].modifiers[0]._computed).toEqual(
|
|
636
636
|
expect.objectContaining({
|
|
637
637
|
amount: 0,
|
|
638
638
|
description: 'CASH 20% DISCOUNT',
|
|
639
639
|
})
|
|
640
640
|
);
|
|
641
641
|
|
|
642
|
-
expect(
|
|
642
|
+
expect(paidOrderWithCash.items[0].modifiers[1]._computed).toEqual(
|
|
643
643
|
expect.objectContaining({
|
|
644
644
|
amount: 0.675,
|
|
645
645
|
description: '5% FEE ($0.68)',
|
|
646
646
|
})
|
|
647
647
|
);
|
|
648
648
|
|
|
649
|
-
expect(
|
|
649
|
+
expect(paidOrderWithCash.items[0].modifiers[2]._computed).toEqual(
|
|
650
650
|
expect.objectContaining({
|
|
651
651
|
amount: -0.25,
|
|
652
652
|
description: '$0.25 discount (-$0.25)',
|
|
653
653
|
})
|
|
654
654
|
);
|
|
655
655
|
|
|
656
|
-
expect(
|
|
656
|
+
expect(paidOrderWithCash.items[0].modifiers[3]._computed).toEqual(
|
|
657
657
|
expect.objectContaining({
|
|
658
658
|
amount: -2.585,
|
|
659
659
|
description: '$2.59 discount (-$2.59)',
|
|
@@ -3743,7 +3743,7 @@ describe('Order actions', () => {
|
|
|
3743
3743
|
const newOrder = pricing.order.calculate(order);
|
|
3744
3744
|
|
|
3745
3745
|
expect(newOrder).toHaveProperty('total', 0);
|
|
3746
|
-
expect(newOrder.status).toMatchObject({
|
|
3746
|
+
expect(newOrder.status).toMatchObject({ paid: true });
|
|
3747
3747
|
expect(newOrder.items[0].total).toBe(0);
|
|
3748
3748
|
expect(newOrder.items[0].status).toMatchObject({
|
|
3749
3749
|
paid: {
|
|
@@ -3770,11 +3770,11 @@ describe('Order actions', () => {
|
|
|
3770
3770
|
const pricing = usePricing({
|
|
3771
3771
|
store: { _settings: { order: { autoMarkAsPaid: true } } },
|
|
3772
3772
|
});
|
|
3773
|
-
const order = { items: [orderItem], status: {
|
|
3773
|
+
const order = { items: [orderItem], status: { paid: true } };
|
|
3774
3774
|
const newOrder = pricing.order.calculate(order);
|
|
3775
3775
|
|
|
3776
3776
|
expect(newOrder).toHaveProperty('total', 25);
|
|
3777
|
-
expect(newOrder.status).toMatchObject({
|
|
3777
|
+
expect(newOrder.status).toMatchObject({ paid: false });
|
|
3778
3778
|
expect(newOrder.items[0].total).toBe(25);
|
|
3779
3779
|
expect(newOrder.items[0].status).toMatchObject({
|
|
3780
3780
|
paid: undefined,
|
|
@@ -3783,7 +3783,7 @@ describe('Order actions', () => {
|
|
|
3783
3783
|
const newOrder2 = pricingService.order.calculate(order);
|
|
3784
3784
|
|
|
3785
3785
|
expect(newOrder2).toHaveProperty('total', 25);
|
|
3786
|
-
expect(newOrder2.status).toMatchObject({
|
|
3786
|
+
expect(newOrder2.status).toMatchObject({ paid: true });
|
|
3787
3787
|
expect(newOrder2.items[0].total).toBe(25);
|
|
3788
3788
|
expect(newOrder2.items[0].status).toMatchObject({ paid: { value: true } });
|
|
3789
3789
|
});
|
|
@@ -3933,4 +3933,37 @@ describe('Order actions', () => {
|
|
|
3933
3933
|
expect(parentCount).toBe(1);
|
|
3934
3934
|
expect(result).toEqual(items);
|
|
3935
3935
|
});
|
|
3936
|
+
|
|
3937
|
+
test('Should remove notes with no message, file, or url', () => {
|
|
3938
|
+
const order = {
|
|
3939
|
+
notes: [
|
|
3940
|
+
{ message: '', file: '', url: '' }, // empty
|
|
3941
|
+
{ message: 'Hello', file: '', url: '' }, // valid
|
|
3942
|
+
{ message: '', file: 'a.pdf', url: '' }, // valid
|
|
3943
|
+
{ message: '', file: '', url: 'http://x.com' }, // valid
|
|
3944
|
+
],
|
|
3945
|
+
};
|
|
3946
|
+
|
|
3947
|
+
const { removeEmptyNotes } = pricingService.order;
|
|
3948
|
+
const result = removeEmptyNotes(order);
|
|
3949
|
+
|
|
3950
|
+
expect(result.notes.length).toBe(3);
|
|
3951
|
+
expect(result.notes).toEqual([
|
|
3952
|
+
{ message: 'Hello', file: '', url: '' },
|
|
3953
|
+
{ message: '', file: 'a.pdf', url: '' },
|
|
3954
|
+
{ message: '', file: '', url: 'http://x.com' },
|
|
3955
|
+
]);
|
|
3956
|
+
});
|
|
3957
|
+
|
|
3958
|
+
test('Should return order unchanged if notes is missing or not an array', () => {
|
|
3959
|
+
const { removeEmptyNotes } = pricingService.order;
|
|
3960
|
+
|
|
3961
|
+
const order1 = {};
|
|
3962
|
+
const order2 = { notes: null };
|
|
3963
|
+
const order3 = { notes: 'invalid' };
|
|
3964
|
+
|
|
3965
|
+
expect(removeEmptyNotes(order1)).toEqual(order1);
|
|
3966
|
+
expect(removeEmptyNotes(order2)).toEqual(order2);
|
|
3967
|
+
expect(removeEmptyNotes(order3)).toEqual(order3);
|
|
3968
|
+
});
|
|
3936
3969
|
});
|
|
@@ -14,9 +14,9 @@ describe('Order actions - unpick order', () => {
|
|
|
14
14
|
quantity: 2,
|
|
15
15
|
status: { picked: { value: true, date: new Date() } },
|
|
16
16
|
};
|
|
17
|
-
const order = { items: [orderItem], status: {
|
|
17
|
+
const order = { items: [orderItem], status: { picked: true } };
|
|
18
18
|
const newOrder = pricingService.order.unpickOrder(order);
|
|
19
|
-
expect(newOrder.status.
|
|
19
|
+
expect(newOrder.status.picked).toBe(false);
|
|
20
20
|
newOrder.items.map(item =>
|
|
21
21
|
expect(item.status.picked).toStrictEqual({ value: false, date: '' })
|
|
22
22
|
);
|
|
@@ -28,7 +28,7 @@ describe('Order actions - unpick order', () => {
|
|
|
28
28
|
status: { picked: { value: true, date: new Date() } },
|
|
29
29
|
};
|
|
30
30
|
const order = {
|
|
31
|
-
status: {
|
|
31
|
+
status: { picked: true },
|
|
32
32
|
items: [
|
|
33
33
|
orderItem,
|
|
34
34
|
orderItem,
|
|
@@ -43,7 +43,7 @@ describe('Order actions - unpick order', () => {
|
|
|
43
43
|
],
|
|
44
44
|
};
|
|
45
45
|
const newOrder = pricingService.order.unpickOrder(order);
|
|
46
|
-
expect(newOrder.status.
|
|
46
|
+
expect(newOrder.status.picked).toBe(false);
|
|
47
47
|
newOrder.items.map(item =>
|
|
48
48
|
expect(item.status.picked).toStrictEqual({ value: false, date: '' })
|
|
49
49
|
);
|
|
@@ -61,10 +61,10 @@ describe('Order actions - unpick order', () => {
|
|
|
61
61
|
};
|
|
62
62
|
const order = {
|
|
63
63
|
items: [orderItem, orderItemNotPicked],
|
|
64
|
-
status: {
|
|
64
|
+
status: { picked: true },
|
|
65
65
|
};
|
|
66
66
|
const newOrder = pricingService.order.unpickOrder(order);
|
|
67
|
-
expect(newOrder.status.
|
|
67
|
+
expect(newOrder.status.picked).toBe(false);
|
|
68
68
|
newOrder.items.map(item =>
|
|
69
69
|
expect(item.status.picked).toStrictEqual({ value: false, date: '' })
|
|
70
70
|
);
|
|
@@ -77,18 +77,18 @@ describe('Order actions - unpick order', () => {
|
|
|
77
77
|
status: { picked: { value: true, date: new Date() } },
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const subOrder = { items: [orderItem], status: {
|
|
80
|
+
const subOrder = { items: [orderItem], status: { picked: true } };
|
|
81
81
|
const order = {
|
|
82
82
|
items: [orderItem],
|
|
83
83
|
orders: [subOrder],
|
|
84
|
-
status: {
|
|
84
|
+
status: { picked: true },
|
|
85
85
|
};
|
|
86
86
|
const newOrder = pricingService.order.unpickOrder(order);
|
|
87
87
|
newOrder.items.map(item =>
|
|
88
88
|
expect(item.status.picked).toStrictEqual({ value: false, date: '' })
|
|
89
89
|
);
|
|
90
90
|
newOrder.orders.map(_order => {
|
|
91
|
-
expect(_order.status.
|
|
91
|
+
expect(_order.status.picked).toBe(false);
|
|
92
92
|
return _order.items.map(item =>
|
|
93
93
|
expect(item.status.picked).toStrictEqual({ value: false, date: '' })
|
|
94
94
|
);
|
|
@@ -2,13 +2,13 @@ const Order = Object.freeze({
|
|
|
2
2
|
OPEN: 'open',
|
|
3
3
|
HOLD: 'hold',
|
|
4
4
|
VOID: 'void',
|
|
5
|
-
CLOSED: '
|
|
5
|
+
CLOSED: 'closed',
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
const Invoice = Object.freeze({
|
|
9
9
|
PARTIAL: 'partial',
|
|
10
10
|
PENDING: 'pending',
|
|
11
|
-
CLOSED: '
|
|
11
|
+
CLOSED: 'closed',
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
const Kitchen = Object.freeze({
|
|
@@ -5,7 +5,7 @@ module.exports = ({ utils, actions, modifierActions }) => {
|
|
|
5
5
|
const selectedSubItemIndex = subItems.findIndex(
|
|
6
6
|
subItem =>
|
|
7
7
|
modifierActions.hasCreditModifier(subItem.modifiers) &&
|
|
8
|
-
!actions.
|
|
8
|
+
!actions.isPaid(subItem) &&
|
|
9
9
|
subItem.total > difference
|
|
10
10
|
);
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ module.exports = ({ utils, actions, modifierActions, _ }) => {
|
|
|
5
5
|
const selectedSubItemIndex = subItems.findIndex(
|
|
6
6
|
subItem =>
|
|
7
7
|
modifierActions.hasFixedModifier(subItem.modifiers) &&
|
|
8
|
-
!actions.
|
|
8
|
+
!actions.isPaid(subItem) &&
|
|
9
9
|
subItem.total > difference
|
|
10
10
|
);
|
|
11
11
|
|
|
@@ -5,14 +5,11 @@ module.exports = ({ actions, settings }) =>
|
|
|
5
5
|
|
|
6
6
|
const localStatus = status || {};
|
|
7
7
|
|
|
8
|
-
if (actions.
|
|
8
|
+
if (actions.isPaid({ item: { status: localStatus } }) && total !== 0) {
|
|
9
9
|
return { ...localStatus, paid: undefined };
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
if (
|
|
13
|
-
!actions.isFullyPaid({ item: { status: localStatus } }) &&
|
|
14
|
-
total === 0
|
|
15
|
-
) {
|
|
12
|
+
if (!actions.isPaid({ item: { status: localStatus } }) && total === 0) {
|
|
16
13
|
return { ...localStatus, paid: { value: true, date: new Date() } };
|
|
17
14
|
}
|
|
18
15
|
|
package/lib/item/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const isRepairOnly = require('./isRepairOnly');
|
|
|
29
29
|
const hasCreateSubscription = require('./hasCreateSubscription');
|
|
30
30
|
const getItemModifiers = require('./getItemModifiers');
|
|
31
31
|
const getItemsBalance = require('./getItemsBalance');
|
|
32
|
-
const
|
|
32
|
+
const isPaid = require('./isPaid');
|
|
33
33
|
const getTotalPrice = require('./getTotalPrice');
|
|
34
34
|
const getItems = require('./getItems');
|
|
35
35
|
const getAmounts = require('./getAmounts');
|
|
@@ -75,6 +75,8 @@ const getSerialStatus = require('./getSerialStatus');
|
|
|
75
75
|
const removeDepartmentModifiers = require('./removeDepartmentModifiers');
|
|
76
76
|
const isRemoveParentItem = require('./isRemoveParentItem');
|
|
77
77
|
const hasRelatedItems = require('./hasRelatedItems');
|
|
78
|
+
const getAddModifiers = require('./getAddModifiers');
|
|
79
|
+
const hasAddModifiers = require('./hasAddModifiers');
|
|
78
80
|
|
|
79
81
|
const itemActions = (deps = {}) => {
|
|
80
82
|
const actions = {};
|
|
@@ -116,7 +118,7 @@ const itemActions = (deps = {}) => {
|
|
|
116
118
|
hasCreateSubscription: hasCreateSubscription(innerDeps),
|
|
117
119
|
getItemModifiers: getItemModifiers(innerDeps),
|
|
118
120
|
getItemsBalance: getItemsBalance(innerDeps),
|
|
119
|
-
|
|
121
|
+
isPaid: isPaid(innerDeps),
|
|
120
122
|
getTotalPrice: getTotalPrice(innerDeps),
|
|
121
123
|
getItems: getItems(innerDeps),
|
|
122
124
|
getAmounts: getAmounts(innerDeps),
|
|
@@ -163,6 +165,8 @@ const itemActions = (deps = {}) => {
|
|
|
163
165
|
removeDepartmentModifiers: removeDepartmentModifiers(innerDeps),
|
|
164
166
|
isRemoveParentItem: isRemoveParentItem(innerDeps),
|
|
165
167
|
hasRelatedItems: hasRelatedItems(innerDeps),
|
|
168
|
+
getAddModifiers: getAddModifiers(innerDeps),
|
|
169
|
+
hasAddModifiers: hasAddModifiers(innerDeps),
|
|
166
170
|
});
|
|
167
171
|
|
|
168
172
|
Object.keys(freezedActions).forEach(actionName => {
|
package/lib/order/addItem.js
CHANGED
|
@@ -265,6 +265,11 @@ module.exports = ({ actions, itemActions, modifierActions, settings, _ }) => {
|
|
|
265
265
|
nextOrder.items.splice(idxToRemove, 1);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
nextOrder = actions.addModifiersToParentItem({
|
|
269
|
+
order: nextOrder,
|
|
270
|
+
relatedItem: orderItem,
|
|
271
|
+
});
|
|
272
|
+
|
|
268
273
|
return {
|
|
269
274
|
updatedOrder: nextOrder,
|
|
270
275
|
itemIndex: nextItemIndex,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module.exports = ({ actions, itemActions }) =>
|
|
2
|
+
function addModifiersToParentItem({ order, relatedItem }) {
|
|
3
|
+
if (
|
|
4
|
+
!order ||
|
|
5
|
+
!itemActions.isRelatedItem(relatedItem) ||
|
|
6
|
+
!itemActions.hasAddModifiers(relatedItem) ||
|
|
7
|
+
itemActions.isRepairOnly(relatedItem)
|
|
8
|
+
) {
|
|
9
|
+
return order;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let nextOrder = { ...order };
|
|
13
|
+
|
|
14
|
+
const parentItem = itemActions.getParentItem(nextOrder.items, relatedItem);
|
|
15
|
+
const parentIndex = actions.getItemIndex({
|
|
16
|
+
order: nextOrder,
|
|
17
|
+
item: parentItem,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (parentIndex < 0) return nextOrder;
|
|
21
|
+
|
|
22
|
+
const relatedModifiersToAdd = itemActions
|
|
23
|
+
.getAddModifiers(relatedItem)
|
|
24
|
+
.filter(
|
|
25
|
+
mod =>
|
|
26
|
+
!parentItem.modifiers.some(itemMod => itemMod.modifierId === mod._id)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
nextOrder = relatedModifiersToAdd.reduce(
|
|
30
|
+
(acc, modifier) =>
|
|
31
|
+
actions.addItemModifier({
|
|
32
|
+
itemIndex: parentIndex,
|
|
33
|
+
order: acc,
|
|
34
|
+
modifier,
|
|
35
|
+
originalItem: parentItem,
|
|
36
|
+
}),
|
|
37
|
+
nextOrder
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return nextOrder;
|
|
41
|
+
};
|
package/lib/order/calculate.js
CHANGED
|
@@ -5,18 +5,12 @@ module.exports = ({ actions, settings }) =>
|
|
|
5
5
|
|
|
6
6
|
const localStatus = status || {};
|
|
7
7
|
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
total !== 0
|
|
11
|
-
) {
|
|
12
|
-
return { ...localStatus, fullyPaid: false };
|
|
8
|
+
if (actions.isPaid({ order: { status: localStatus } }) && total !== 0) {
|
|
9
|
+
return { ...localStatus, paid: false };
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
total === 0
|
|
18
|
-
) {
|
|
19
|
-
return { ...localStatus, fullyPaid: true };
|
|
12
|
+
if (!actions.isPaid({ order: { status: localStatus } }) && total === 0) {
|
|
13
|
+
return { ...localStatus, paid: true };
|
|
20
14
|
}
|
|
21
15
|
|
|
22
16
|
return localStatus;
|
package/lib/order/index.js
CHANGED
|
@@ -89,11 +89,13 @@ const resetItem = require('./resetItem');
|
|
|
89
89
|
const splitItems = require('./splitItems');
|
|
90
90
|
const getNewItems = require('./getNewItems');
|
|
91
91
|
const mapSubOrders = require('./mapSubOrders');
|
|
92
|
-
const
|
|
92
|
+
const isPaid = require('./isPaid');
|
|
93
93
|
const getUpdatedStatus = require('./getUpdatedStatus');
|
|
94
94
|
const setPieces = require('./setPieces');
|
|
95
95
|
const copyItemToParents = require('./copyItemToParents');
|
|
96
96
|
const getItemsWithParents = require('./getItemsWithParents');
|
|
97
|
+
const addModifiersToParentItem = require('./addModifiersToParentItem');
|
|
98
|
+
const removeEmptyNotes = require('./removeEmptyNotes');
|
|
97
99
|
|
|
98
100
|
const orderActions = (deps = {}) => {
|
|
99
101
|
const actions = {};
|
|
@@ -194,11 +196,13 @@ const orderActions = (deps = {}) => {
|
|
|
194
196
|
splitItems: splitItems(innerDeps),
|
|
195
197
|
getNewItems: getNewItems(innerDeps),
|
|
196
198
|
mapSubOrders: mapSubOrders(innerDeps),
|
|
197
|
-
|
|
199
|
+
isPaid: isPaid(innerDeps),
|
|
198
200
|
getUpdatedStatus: getUpdatedStatus(innerDeps),
|
|
199
201
|
setPieces: setPieces(innerDeps),
|
|
200
202
|
copyItemToParents: copyItemToParents(innerDeps),
|
|
201
203
|
getItemsWithParents: getItemsWithParents(innerDeps),
|
|
204
|
+
addModifiersToParentItem: addModifiersToParentItem(innerDeps),
|
|
205
|
+
removeEmptyNotes: removeEmptyNotes(innerDeps),
|
|
202
206
|
});
|
|
203
207
|
|
|
204
208
|
Object.keys(freezedActions).forEach(actionName => {
|
package/lib/order/unpick.js
CHANGED
|
@@ -6,8 +6,8 @@ module.exports = ({ itemActions }) =>
|
|
|
6
6
|
const orderItems = [...(order.items || [])].map(item =>
|
|
7
7
|
itemActions.unpickItem(item)
|
|
8
8
|
);
|
|
9
|
-
if (nextOrder.status && nextOrder.status.
|
|
10
|
-
nextOrder.status.
|
|
9
|
+
if (nextOrder.status && nextOrder.status.picked) {
|
|
10
|
+
nextOrder.status.picked = false;
|
|
11
11
|
}
|
|
12
12
|
nextOrder.items = orderItems;
|
|
13
13
|
}
|
|
@@ -17,8 +17,8 @@ module.exports = ({ itemActions }) =>
|
|
|
17
17
|
..._order,
|
|
18
18
|
items: _order.items.map(item => itemActions.unpickItem(item)),
|
|
19
19
|
};
|
|
20
|
-
if (nextsubOrder.status && nextsubOrder.status.
|
|
21
|
-
nextsubOrder.status.
|
|
20
|
+
if (nextsubOrder.status && nextsubOrder.status.picked) {
|
|
21
|
+
nextsubOrder.status.picked = false;
|
|
22
22
|
}
|
|
23
23
|
return nextsubOrder;
|
|
24
24
|
});
|
package/lib/store/pickEndDate.js
CHANGED
|
@@ -35,9 +35,9 @@ module.exports = ({ settings, _, moment }) => {
|
|
|
35
35
|
|
|
36
36
|
const getClosedDays = () => {
|
|
37
37
|
const schedule = _.get(settings, 'schedule', {});
|
|
38
|
-
const {
|
|
39
|
-
if (!Array.isArray(
|
|
40
|
-
return
|
|
38
|
+
const { closed = [] } = schedule;
|
|
39
|
+
if (!Array.isArray(closed)) return [];
|
|
40
|
+
return closed;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const MAX_ADD_DAYS = 365;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.134",
|
|
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": "cfe52c49a64c3418b808a7c5ce7f76324b8340a5"
|
|
56
56
|
}
|