homeflowjs 1.0.39 → 1.0.41
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
CHANGED
@@ -140,7 +140,7 @@ const PropertiesDisplay = ({
|
|
140
140
|
key={property.property_id}
|
141
141
|
onClick={() => visitPropertyUpdate(property.property_id)}
|
142
142
|
property={property}
|
143
|
-
data-page-marker={!
|
143
|
+
data-page-marker={!addWrapper && index === 0 ? page[0].resultPage : null}
|
144
144
|
{...other}
|
145
145
|
/>
|
146
146
|
);
|
@@ -1,9 +1,28 @@
|
|
1
1
|
const calculateRange = (price, lower, upper, rate) => {
|
2
2
|
if (price <= lower) return 0;
|
3
3
|
return (Math.min(upper, price) - lower) * rate;
|
4
|
-
}
|
4
|
+
};
|
5
|
+
|
6
|
+
const englishRates = (
|
7
|
+
price,
|
8
|
+
firstTimeBuyer,
|
9
|
+
additionalProperty,
|
10
|
+
ukResident = true, // Default to true if not explicitly specified
|
11
|
+
isCompany
|
12
|
+
) => {
|
13
|
+
// Handle cases where price is missing or invalid
|
14
|
+
if (!price || price <= 0) {
|
15
|
+
return {
|
16
|
+
rate1: 0,
|
17
|
+
rate2: 0,
|
18
|
+
rate3: 0,
|
19
|
+
rate4: 0,
|
20
|
+
rate5: 0,
|
21
|
+
totalRate: 0,
|
22
|
+
effectiveRate: 0,
|
23
|
+
};
|
24
|
+
}
|
5
25
|
|
6
|
-
const englishRates = (price, firstTimeBuyer, additionalProperty, ukResident) => {
|
7
26
|
let effectiveRate = 0;
|
8
27
|
let totalRate = 0;
|
9
28
|
let rate1 = 0;
|
@@ -12,36 +31,39 @@ const englishRates = (price, firstTimeBuyer, additionalProperty, ukResident) =>
|
|
12
31
|
let rate4 = 0;
|
13
32
|
let rate5 = 0;
|
14
33
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
34
|
+
if (isCompany) {
|
35
|
+
// Company buy: Flat rate of 17% for properties above £500,000
|
36
|
+
if (price > 500000) {
|
37
|
+
totalRate = price * 0.17;
|
38
|
+
}
|
39
|
+
} else {
|
40
|
+
// Individual buyers
|
41
|
+
if (firstTimeBuyer && price <= 625000) {
|
42
|
+
rate2 = calculateRange(price, 425000, Number.POSITIVE_INFINITY, 0.05);
|
43
|
+
}
|
19
44
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
45
|
+
if (additionalProperty) {
|
46
|
+
// Additional property rates
|
47
|
+
rate1 = calculateRange(price, 0, 250000, 0.05);
|
48
|
+
rate2 = calculateRange(price, 250000, 925000, 0.10);
|
49
|
+
rate3 = calculateRange(price, 925000, 1500000, 0.15);
|
50
|
+
rate4 = calculateRange(price, 1500000, Number.POSITIVE_INFINITY, 0.17);
|
51
|
+
} else if (!(firstTimeBuyer && price <= 625000)) {
|
52
|
+
// Moving or first-time buyer > £625,000
|
53
|
+
rate2 = calculateRange(price, 250000, 925000, 0.05);
|
54
|
+
rate3 = calculateRange(price, 925000, 1500000, 0.10);
|
55
|
+
rate4 = calculateRange(price, 1500000, Number.POSITIVE_INFINITY, 0.12);
|
56
|
+
}
|
27
57
|
|
28
|
-
|
29
|
-
if (
|
30
|
-
!(firstTimeBuyer && price <= 625000)
|
31
|
-
&& !additionalProperty
|
32
|
-
) {
|
33
|
-
rate2 = calculateRange(price, 250000, 925000, 0.05);
|
34
|
-
rate3 = calculateRange(price, 925000, 1500000, 0.10);
|
35
|
-
rate4 = calculateRange(price, 1500000, Number.POSITIVE_INFINITY, 0.12);
|
36
|
-
}
|
58
|
+
totalRate = rate1 + rate2 + rate3 + rate4 + rate5;
|
37
59
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
effectiveRate += 0.02;
|
60
|
+
// Apply additional rate for non-UK residents only if applicable
|
61
|
+
if (!ukResident && additionalProperty) {
|
62
|
+
totalRate += price * 0.02; // Non-UK resident surcharge
|
63
|
+
}
|
43
64
|
}
|
44
|
-
|
65
|
+
|
66
|
+
effectiveRate = (totalRate / price) * 100;
|
45
67
|
|
46
68
|
return {
|
47
69
|
rate1,
|
@@ -50,7 +72,7 @@ const englishRates = (price, firstTimeBuyer, additionalProperty, ukResident) =>
|
|
50
72
|
rate4,
|
51
73
|
rate5,
|
52
74
|
totalRate,
|
53
|
-
effectiveRate
|
75
|
+
effectiveRate,
|
54
76
|
};
|
55
77
|
};
|
56
78
|
|
@@ -10,7 +10,7 @@ import welshRates from './welsh-rates';
|
|
10
10
|
* different layout and/or styles to the DefaultStampDutyCalculator component.
|
11
11
|
*/
|
12
12
|
const stampDutyCalculator = ({
|
13
|
-
price, country, firstTimeBuyer, additionalProperty, ukResident = true
|
13
|
+
price, country, firstTimeBuyer, additionalProperty, ukResident = true, isCompany
|
14
14
|
}) => {
|
15
15
|
if (!price) {
|
16
16
|
return {
|
@@ -29,7 +29,7 @@ const stampDutyCalculator = ({
|
|
29
29
|
}
|
30
30
|
|
31
31
|
// If country not is not specified use English rates by default
|
32
|
-
return englishRates(price, firstTimeBuyer, additionalProperty, ukResident);
|
32
|
+
return englishRates(price, firstTimeBuyer, additionalProperty, ukResident, isCompany);
|
33
33
|
};
|
34
34
|
|
35
35
|
export default stampDutyCalculator;
|