@unchainedshop/core-products 2.7.0 → 2.7.1
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.
|
@@ -23,9 +23,11 @@ export const ProductPricingSheet = (params) => {
|
|
|
23
23
|
meta,
|
|
24
24
|
});
|
|
25
25
|
},
|
|
26
|
-
addTax({ amount, rate, meta }) {
|
|
26
|
+
addTax({ amount, baseCategory, rate, meta, discountId }) {
|
|
27
27
|
basePricingSheet.calculation.push({
|
|
28
28
|
category: ProductPricingRowCategory.Tax,
|
|
29
|
+
baseCategory,
|
|
30
|
+
discountId,
|
|
29
31
|
amount,
|
|
30
32
|
isTaxable: false,
|
|
31
33
|
isNetPrice: false,
|
|
@@ -53,7 +55,10 @@ export const ProductPricingSheet = (params) => {
|
|
|
53
55
|
},
|
|
54
56
|
discountPrices(explicitDiscountId) {
|
|
55
57
|
const discountIds = pricingSheet
|
|
56
|
-
.
|
|
58
|
+
.filterBy({
|
|
59
|
+
category: ProductPricingRowCategory.Discount,
|
|
60
|
+
discountId: explicitDiscountId,
|
|
61
|
+
})
|
|
57
62
|
.map(({ discountId }) => discountId);
|
|
58
63
|
return [...new Set(discountIds)]
|
|
59
64
|
.map((discountId) => {
|
|
@@ -72,12 +77,6 @@ export const ProductPricingSheet = (params) => {
|
|
|
72
77
|
})
|
|
73
78
|
.filter(Boolean);
|
|
74
79
|
},
|
|
75
|
-
getDiscountRows(discountId) {
|
|
76
|
-
return basePricingSheet.filterBy({
|
|
77
|
-
category: ProductPricingRowCategory.Discount,
|
|
78
|
-
discountId,
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
80
|
};
|
|
82
81
|
return pricingSheet;
|
|
83
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductPricingSheet.js","sourceRoot":"","sources":["../../src/director/ProductPricingSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC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QAAQ,CAAC;gBAC1C,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC;QACJ,CAAC;QAED,cAAc,CAAC,kBAAkB;YAC/B,MAAM,WAAW,GAAG,YAAY;iBAC7B,QAAQ,CAAC;gBACR,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;gBAC5C,UAAU,EAAE,kBAAkB;aAC/B,CAAC;iBACD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;YAEvC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;iBAC7B,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;gBAClB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC;oBAClC,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;oBAC5C,UAAU;iBACX,CAAC,CAAC;gBACH,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO;oBACL,UAAU;oBACV,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;oBAC1B,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;iBACpC,CAAC;YACJ,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-products",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"main": "lib/products-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/products-index.js",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/events": "^2.7.
|
|
35
|
-
"@unchainedshop/file-upload": "^2.7.
|
|
36
|
-
"@unchainedshop/utils": "^2.7.
|
|
34
|
+
"@unchainedshop/events": "^2.7.1",
|
|
35
|
+
"@unchainedshop/file-upload": "^2.7.1",
|
|
36
|
+
"@unchainedshop/utils": "^2.7.1",
|
|
37
37
|
"locale": "^0.1.0",
|
|
38
38
|
"simpl-schema": "=3.2.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/locale": "^0.1.4",
|
|
42
42
|
"@types/node": "^20.11.17",
|
|
43
|
-
"@unchainedshop/types": "^2.7.
|
|
43
|
+
"@unchainedshop/types": "^2.7.1",
|
|
44
44
|
"jest": "^29.7.0",
|
|
45
45
|
"ts-jest": "^29.1.2",
|
|
46
46
|
"typescript": "^5.3.3"
|
|
@@ -33,7 +33,6 @@ describe('ProductPricingSheet', () => {
|
|
|
33
33
|
expect(typeof pricingSheet.discountSum).toBe('function');
|
|
34
34
|
expect(typeof pricingSheet.unitPrice).toBe('function');
|
|
35
35
|
expect(typeof pricingSheet.discountPrices).toBe('function');
|
|
36
|
-
expect(typeof pricingSheet.getDiscountRows).toBe('function');
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
it('gross() should return the GROSS sum of all ProductPricingCalculation', () => {
|
|
@@ -82,13 +81,6 @@ describe('ProductPricingSheet', () => {
|
|
|
82
81
|
})
|
|
83
82
|
|
|
84
83
|
|
|
85
|
-
describe('getDiscountRows', () => {
|
|
86
|
-
it('should return all the DISCOUNTS registered on the ProductPricingSheet', () => {
|
|
87
|
-
expect(pricingSheet.getDiscountRows('for-all')).toEqual([DISCOUNT, DISCOUNT2])
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
})
|
|
91
|
-
|
|
92
84
|
describe('taxSum', () => {
|
|
93
85
|
it('should return the sum of TAX calculation registered on the adapter', () => {
|
|
94
86
|
expect(pricingSheet.taxSum()).toEqual(75)
|
|
@@ -124,14 +116,6 @@ describe('ProductPricingSheet', () => {
|
|
|
124
116
|
})
|
|
125
117
|
|
|
126
118
|
})
|
|
127
|
-
|
|
128
|
-
describe('addDiscount', () => {
|
|
129
|
-
it('should add ProductPricingCalculation DISCOUNT category successfully', () => {
|
|
130
|
-
expect(pricingSheet.getDiscountRows('new')).toEqual([])
|
|
131
|
-
pricingSheet.addDiscount({amount: 300, isNetPrice: true, isTaxable: true, discountId: 'new'})
|
|
132
|
-
expect(pricingSheet.getDiscountRows('new')).toEqual([{amount: 300, isNetPrice: true, isTaxable: true, category: 'DISCOUNT', meta: undefined, discountId: 'new'}])
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
119
|
})
|
|
136
120
|
|
|
137
121
|
|
|
@@ -35,9 +35,11 @@ export const ProductPricingSheet = (
|
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
37
|
|
|
38
|
-
addTax({ amount, rate, meta }) {
|
|
38
|
+
addTax({ amount, baseCategory, rate, meta, discountId }) {
|
|
39
39
|
basePricingSheet.calculation.push({
|
|
40
40
|
category: ProductPricingRowCategory.Tax,
|
|
41
|
+
baseCategory,
|
|
42
|
+
discountId,
|
|
41
43
|
amount,
|
|
42
44
|
isTaxable: false,
|
|
43
45
|
isNetPrice: false,
|
|
@@ -69,7 +71,10 @@ export const ProductPricingSheet = (
|
|
|
69
71
|
|
|
70
72
|
discountPrices(explicitDiscountId) {
|
|
71
73
|
const discountIds = pricingSheet
|
|
72
|
-
.
|
|
74
|
+
.filterBy({
|
|
75
|
+
category: ProductPricingRowCategory.Discount,
|
|
76
|
+
discountId: explicitDiscountId,
|
|
77
|
+
})
|
|
73
78
|
.map(({ discountId }) => discountId);
|
|
74
79
|
|
|
75
80
|
return [...new Set(discountIds)]
|
|
@@ -89,13 +94,6 @@ export const ProductPricingSheet = (
|
|
|
89
94
|
})
|
|
90
95
|
.filter(Boolean);
|
|
91
96
|
},
|
|
92
|
-
|
|
93
|
-
getDiscountRows(discountId: string) {
|
|
94
|
-
return basePricingSheet.filterBy({
|
|
95
|
-
category: ProductPricingRowCategory.Discount,
|
|
96
|
-
discountId,
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
97
|
};
|
|
100
98
|
|
|
101
99
|
return pricingSheet;
|