homeflowjs 1.0.64 → 1.0.66
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/properties-map/draggable-map.js +35 -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
@@ -93,7 +93,33 @@ export default class DraggableMap {
|
|
93
93
|
// is a design feature
|
94
94
|
this.initControlsMobile();
|
95
95
|
}
|
96
|
-
|
96
|
+
|
97
|
+
if (this.noLocationfound) {
|
98
|
+
/**
|
99
|
+
* If no location is found but if properties
|
100
|
+
* are found (i.e search without a location)
|
101
|
+
* run the setToMarkeredBounds
|
102
|
+
*/
|
103
|
+
const properties = this.getProperties();
|
104
|
+
if(properties) this.setToMarkeredBounds();
|
105
|
+
|
106
|
+
/**
|
107
|
+
* If no location and properties are found, the setToMarkeredBounds
|
108
|
+
* will return null as it can't find any bounds. In turn
|
109
|
+
* this causes the map to error because it can't set a center point.
|
110
|
+
* If this is case, we need to grab the last center point and zoom
|
111
|
+
* from the last drag event and use that to set the map view.
|
112
|
+
*
|
113
|
+
* (properties are not found if the map
|
114
|
+
* re-renders because of a parent component and
|
115
|
+
* the user has dragged out of site of any properties)
|
116
|
+
*/
|
117
|
+
const lastDragEvent = Homeflow.get('last_map_drag_event');
|
118
|
+
if(!properties) {
|
119
|
+
this.map.setView(lastDragEvent.center, lastDragEvent.zoom);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
97
123
|
if (Homeflow.get('custom_map_zoom')) {
|
98
124
|
this.map.setZoom(Homeflow.get('custom_map_zoom'));
|
99
125
|
}
|
@@ -508,6 +534,14 @@ export default class DraggableMap {
|
|
508
534
|
// no drag allowed.
|
509
535
|
if (Homeflow.get('disable_draggable_map') || this.drawableMapInitialized) return;
|
510
536
|
|
537
|
+
// Acts as a fallback in the init if the map is re-rendered without any properties
|
538
|
+
const center = this.map.getCenter();
|
539
|
+
const zoom = this.map.getZoom();
|
540
|
+
Homeflow.set('last_map_drag_event', {
|
541
|
+
center,
|
542
|
+
zoom
|
543
|
+
})
|
544
|
+
|
511
545
|
// drag map but no fetching properties within the new boundaries.
|
512
546
|
if(this.dragWithoutUpdate) return null;
|
513
547
|
|
@@ -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
|
|