homeflowjs 1.0.63 → 1.0.65
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/package.json +1 -1
- package/properties/load-more-button/load-more-button.component.jsx +2 -1
- package/utils/stamp-duty-calculator/country-rates.js +5 -9
- package/utils/stamp-duty-calculator/english-rates.js +12 -6
- package/utils/stamp-duty-calculator/stamp-duty-calculator.js +4 -1
- package/utils/stamp-duty-calculator/stamp-duty-utils.js +2 -2
package/package.json
CHANGED
@@ -135,7 +135,7 @@ const LoadMoreButton = (props) => {
|
|
135
135
|
};
|
136
136
|
|
137
137
|
LoadMoreButton.propTypes = {
|
138
|
-
children: PropTypes.node
|
138
|
+
children: PropTypes.node,
|
139
139
|
Loader: PropTypes.elementType,
|
140
140
|
isHidden: PropTypes.bool,
|
141
141
|
isRouterLink: PropTypes.bool,
|
@@ -145,6 +145,7 @@ LoadMoreButton.defaultProps = {
|
|
145
145
|
Loader: DefaultLoader,
|
146
146
|
isHidden: false,
|
147
147
|
isRouterLink: false,
|
148
|
+
children: null,
|
148
149
|
};
|
149
150
|
|
150
151
|
export default LoadMoreButton;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { calculateRange
|
1
|
+
import { calculateRange } from "./stamp-duty-utils";
|
2
2
|
|
3
3
|
const countryRates = (price, firstTimeBuyer, additionalProperty, ukResident, country) => {
|
4
4
|
const countryConfig = {
|
@@ -18,16 +18,12 @@ const countryRates = (price, firstTimeBuyer, additionalProperty, ukResident, cou
|
|
18
18
|
if(additionalProperty) return 'additional_property_rate';
|
19
19
|
return countryConfig[country].base;
|
20
20
|
};
|
21
|
-
const bracketForPrice = +(cmsRates[getPriceBracketIndex(price, cmsRates)]['non_uk_resident_rate']);
|
22
|
-
|
23
|
-
const initalTotalRate = () => {
|
24
|
-
if (!ukResident && bracketForPrice) return +((price * (bracketForPrice / 100)).toFixed(2));
|
25
|
-
return 0;
|
26
|
-
}
|
27
21
|
|
28
22
|
const stampDutyRatesCalculation = cmsRates.reduce((accumulator, _, index) => {
|
23
|
+
// Minumun price from the 1st braket should be always 0
|
24
|
+
const minimunFallback = index === 0 ? 0 : Number.POSITIVE_INFINITY;
|
29
25
|
const percentageFromList = +(cmsRates[index][buyerStatusAsKeyOfObject()]) / 100;
|
30
|
-
const minimumPropertyPrice = cmsRates[index]['minimum_property_price'] ||
|
26
|
+
const minimumPropertyPrice = cmsRates[index]['minimum_property_price'] || minimunFallback;
|
31
27
|
const maxisumPropertyPrice = cmsRates[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
|
32
28
|
const rateIndex = `rate${index + 1}`;
|
33
29
|
const rateForTheBracket = calculateRange(price, minimumPropertyPrice, maxisumPropertyPrice, percentageFromList);
|
@@ -39,7 +35,7 @@ const countryRates = (price, firstTimeBuyer, additionalProperty, ukResident, cou
|
|
39
35
|
|
40
36
|
return accumulator;
|
41
37
|
}, {
|
42
|
-
totalRate:
|
38
|
+
totalRate: 0,
|
43
39
|
effectiveRate: 0,
|
44
40
|
});
|
45
41
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { calculateRange
|
1
|
+
import { calculateRange } from "./stamp-duty-utils";
|
2
2
|
|
3
3
|
const englishRates = (
|
4
4
|
price = 0,
|
@@ -8,7 +8,6 @@ const englishRates = (
|
|
8
8
|
isCompany
|
9
9
|
) => {
|
10
10
|
const englandRatesList = Homeflow.get('stamp_duty_england');
|
11
|
-
const bracketForPrice = +(englandRatesList[getPriceBracketIndex(price, englandRatesList)]['non_uk_resident_rate']);
|
12
11
|
|
13
12
|
const buyerStatusAsKeyOfObject = () => {
|
14
13
|
if(firstTimeBuyer) return 'first_time_buyer_rate';
|
@@ -24,15 +23,23 @@ const englishRates = (
|
|
24
23
|
*/
|
25
24
|
const initalTotalRate = () => {
|
26
25
|
if(isCompany && price > 500_000) return price * 0.17;
|
27
|
-
if (!ukResident && bracketForPrice && !isCompany) return +((price * (bracketForPrice / 100)).toFixed(2));
|
28
26
|
return 0;
|
29
27
|
}
|
30
28
|
|
31
29
|
const stampDutyRatesCalculation = englandRatesList.reduce((accumulator, _, index) => {
|
32
|
-
|
33
|
-
const
|
30
|
+
// Minumun price from the 1st braket should be always 0
|
31
|
+
const minimunFallback = index === 0 ? 0 : Number.POSITIVE_INFINITY;
|
32
|
+
const minimumPropertyPrice = englandRatesList[index]['minimum_property_price'] || minimunFallback;
|
34
33
|
const maxisumPropertyPrice = englandRatesList[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
|
35
34
|
const rateIndex = `rate${index + 1}`;
|
35
|
+
let percentageFromList = +(englandRatesList[index][buyerStatusAsKeyOfObject()]) / 100;
|
36
|
+
|
37
|
+
if (!ukResident && englandRatesList[index]?.['non_uk_resident_rate']) {
|
38
|
+
percentageFromList += (+(englandRatesList[index]?.['non_uk_resident_rate']) / 100);
|
39
|
+
}
|
40
|
+
|
41
|
+
percentageFromList = parseFloat(percentageFromList.toFixed(3));
|
42
|
+
|
36
43
|
const rateForTheBracket = isCompany
|
37
44
|
? 0
|
38
45
|
: calculateRange(price, minimumPropertyPrice, maxisumPropertyPrice, percentageFromList);
|
@@ -44,7 +51,6 @@ const englishRates = (
|
|
44
51
|
|
45
52
|
return accumulator;
|
46
53
|
}, {
|
47
|
-
// totalRate: (!ukResident && bracketForPrice) ? +((price * (bracketForPrice / 100)).toFixed(2)) : 0,
|
48
54
|
totalRate: initalTotalRate(),
|
49
55
|
effectiveRate: 0,
|
50
56
|
});
|
@@ -22,7 +22,10 @@ const stampDutyCalculator = ({
|
|
22
22
|
* Once the BE brings data for companies (isCompany)
|
23
23
|
* countryRates will need an update and then we can have just one method.
|
24
24
|
*/
|
25
|
-
if (
|
25
|
+
if (
|
26
|
+
country?.toLowerCase() === 'scotland'
|
27
|
+
|| country?.toLowerCase() === 'wales')
|
28
|
+
{
|
26
29
|
return countryRates(price, firstTimeBuyer, additionalProperty, ukResident, country);
|
27
30
|
}
|
28
31
|
|
@@ -12,8 +12,8 @@ export const getPriceBracketIndex = (price, arr) => {
|
|
12
12
|
|
13
13
|
arr.forEach((rates, index) => {
|
14
14
|
if (
|
15
|
-
(rates.
|
16
|
-
&& (rates.minimum_property_price
|
15
|
+
(+(rates.maximum_property_price) || Number.POSITIVE_INFINITY) > price
|
16
|
+
&& +(rates.minimum_property_price) < price
|
17
17
|
) bracketIndex = index;
|
18
18
|
});
|
19
19
|
|