@darkpos/pricing 1.0.175 → 1.0.176
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,34 @@
|
|
|
1
|
+
const usePricing = require('../../index');
|
|
2
|
+
const mockStores = require('../mocks/stores');
|
|
3
|
+
const mockStoreSettings = require('../mocks/storeSettings');
|
|
4
|
+
|
|
5
|
+
const pricingService = usePricing({
|
|
6
|
+
store: mockStores[0],
|
|
7
|
+
settings: mockStoreSettings,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('getItemsTotals', () => {
|
|
11
|
+
test('skips the subTotals of an item stored without them', () => {
|
|
12
|
+
const totals = pricingService.item.getItemsTotals([
|
|
13
|
+
{ _id: 'a', total: 0 },
|
|
14
|
+
{ _id: 'b', total: 5, subTotals: { discount: -1 } },
|
|
15
|
+
]);
|
|
16
|
+
expect(totals.total).toBe(5);
|
|
17
|
+
expect(totals.subTotals).toEqual({ discount: -1 });
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('getOverPaidOrders does not throw on such an item', () => {
|
|
21
|
+
const result = pricingService.payment.getOverPaidOrders({
|
|
22
|
+
orders: [
|
|
23
|
+
{
|
|
24
|
+
_id: 'parent',
|
|
25
|
+
isParent: true,
|
|
26
|
+
orders: [
|
|
27
|
+
{ _id: 'child', totalPaid: 0, items: [{ _id: 'a', total: 0 }] },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
expect(result.overPaidAmount).toBe(0);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -14,7 +14,7 @@ module.exports = ({ utils, actions }) => {
|
|
|
14
14
|
actions.getSubtotalIncluded(item)
|
|
15
15
|
);
|
|
16
16
|
subTotal = math.add(subTotal, actions.getSubtotal(item));
|
|
17
|
-
const keys = Object.keys(item.subTotals).filter(
|
|
17
|
+
const keys = Object.keys(item.subTotals || {}).filter(
|
|
18
18
|
key => !key.includes('_')
|
|
19
19
|
);
|
|
20
20
|
for (const key of keys) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.176",
|
|
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": "f81d174d40b1fb5314afb5430b387ceaf50bdcc1"
|
|
58
58
|
}
|