homeflowjs 1.0.66 → 1.0.68

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -70,11 +70,47 @@
70
70
  margin: 0 auto;
71
71
  }
72
72
 
73
+ &__checkbox-group {
74
+ font-size: 12px;
75
+ width: 100%;
76
+
77
+ @media (min-width: 700px) {
78
+ width: 30rem;
79
+ }
80
+
81
+ .input-group {
82
+ display: flex;
83
+ align-items: flex-start;
84
+ margin-bottom: 1rem;
85
+
86
+ // Overriding the input and label components here for checkbox input and labels.
87
+ .checkbox-input {
88
+ height: 10px;
89
+ width: 10px;
90
+ }
91
+
92
+ .checkbox-label {
93
+ text-align: left;
94
+ margin-left: .5rem;
95
+ &:before {
96
+ display: none;
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ .register-button {
103
+ @media (min-width: 700px) {
104
+ margin-right: 100%;
105
+ margin-bottom: 1rem;
106
+ }
107
+ }
108
+
73
109
  &__submit {
74
110
  padding: 8px 20px;
75
111
  margin-top: 10px;
76
112
  border-radius: 0;
77
- border: solid 1px gray
113
+ border: solid 1px gray;
78
114
  }
79
115
 
80
116
  &__forgot-link {
@@ -40,9 +40,54 @@ const RegisterForm = ({ localUser, registering }) => (
40
40
  <UserInput name="password_confirmation" required />
41
41
  <label htmlFor="user-input-password_confirmation" className={localUser.password_confirmation ? 'shrink' : ''}>Confirm password</label>
42
42
  </div>
43
-
43
+ <div className='profile-register-form__checkbox-group'>
44
+ <div className='input-group'>
45
+ <UserInput
46
+ name="opt_in_marketing_url"
47
+ unmappedValue={window.location.href}
48
+ type="checkbox"
49
+ className="checkbox-input"
50
+ />
51
+ <label htmlFor="opt_in_marketing_url" className='checkbox-label'>
52
+ Get emails with the latest news and information on the local property market,
53
+ our products and services. You can unsubscribe at any time.
54
+ </label>
55
+ </div>
56
+ <div className='input-group'>
57
+ <UserInput
58
+ name="create_account"
59
+ type="checkbox"
60
+ className="checkbox-input"
61
+ />
62
+ <label htmlFor="create_account" className='checkbox-label'>
63
+ Create an account to view your saved properties and searches and keep
64
+ your personal details up-to-date.
65
+ </label>
66
+ </div>
67
+ <div className='input-group'>
68
+ <UserInput
69
+ name="terms-links"
70
+ type="checkbox"
71
+ className="checkbox-input"
72
+ required
73
+ />
74
+ <label htmlFor="terms-links" className='checkbox-label'>
75
+ I have read and agree to the
76
+ {' '}
77
+ <a href="/pages/terms-of-use">Terms and Conditions</a>
78
+ ,
79
+ {' '}
80
+ <a href="/pages/privacy-policy">Privacy Policy</a>
81
+ {' '}
82
+ and
83
+ {' '}
84
+ <a href="/pages/cookies">Cookies Policy</a>
85
+ .
86
+ </label>
87
+ </div>
88
+ </div>
44
89
  <button
45
- className="profile-register-form__submit"
90
+ className="profile-register-form__submit register-button"
46
91
  role="button"
47
92
  type="submit"
48
93
  disabled={registering}
@@ -54,7 +54,7 @@
54
54
  &__side {
55
55
  float: left;
56
56
  width: 30%;
57
- height: 100%;
57
+ height: 120%;
58
58
  background-color: #eee;
59
59
  padding-top: 50px;
60
60
  border-right: solid #ccc 1px;
@@ -9,40 +9,47 @@ const englishRates = (
9
9
  ) => {
10
10
  const englandRatesList = Homeflow.get('stamp_duty_england');
11
11
 
12
- const buyerStatusAsKeyOfObject = () => {
13
- if(firstTimeBuyer) return 'first_time_buyer_rate';
14
- if(additionalProperty) return 'additional_property_rate';
15
- return 'base_sdlt_rate';
16
- };
17
-
18
- /**
19
- * ATM the BE work doesn't have % for company purchases.
20
- * Once that's done we can initiate the base object totalRate for:
21
- * totalRate: (!ukResident && bracketForPrice) ? +((price * (bracketForPrice / 100)).toFixed(2)) : 0,
22
- * But for now we need to have the 3 options + the hardcoded 17%
23
- */
24
- const initalTotalRate = () => {
25
- if(isCompany && price > 500_000) return price * 0.17;
26
- return 0;
12
+ const ratesToCalculateBasedOnTaxType = () => {
13
+ const baseRates = englandRatesList['base'];
14
+ const firstTimeBuyerRates = englandRatesList['first_time_buyer'];
15
+
16
+ if (firstTimeBuyer) {
17
+ const priceLimit = firstTimeBuyerRates[firstTimeBuyerRates?.length - 1]
18
+ ?.['maximum_property_price'];
19
+
20
+ if (priceLimit && price > priceLimit) {
21
+ return baseRates;
22
+ } else {
23
+ return firstTimeBuyerRates;
24
+ }
25
+ }
26
+
27
+ return baseRates;
27
28
  }
28
29
 
29
- const stampDutyRatesCalculation = englandRatesList.reduce((accumulator, _, index) => {
30
+ const ratesList = ratesToCalculateBasedOnTaxType();
31
+
32
+ const stampDutyRatesCalculation = ratesList.reduce((accumulator, _, index) => {
30
33
  // Minumun price from the 1st braket should be always 0
31
34
  const minimunFallback = index === 0 ? 0 : Number.POSITIVE_INFINITY;
32
- const minimumPropertyPrice = englandRatesList[index]['minimum_property_price'] || minimunFallback;
33
- const maxisumPropertyPrice = englandRatesList[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
35
+ const minimumPropertyPrice = ratesList[index]['minimum_property_price'] || minimunFallback;
36
+ const maximumPropertyPrice = ratesList[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
34
37
  const rateIndex = `rate${index + 1}`;
35
- let percentageFromList = +(englandRatesList[index][buyerStatusAsKeyOfObject()]) / 100;
38
+ let percentageFromList = +(ratesList[index]['base_sdlt_rate']) / 100;
39
+
40
+ if (!ukResident && ratesList[index]?.['non_uk_resident_surcharge']) {
41
+ percentageFromList += (+(ratesList[index]?.['non_uk_resident_surcharge']) / 100);
42
+ }
36
43
 
37
- if (!ukResident && englandRatesList[index]?.['non_uk_resident_rate']) {
38
- percentageFromList += (+(englandRatesList[index]?.['non_uk_resident_rate']) / 100);
44
+ if ((additionalProperty || isCompany) && ratesList[index]?.['additional_property_surcharge']) {
45
+ percentageFromList += (+(ratesList[index]?.['additional_property_surcharge']) / 100);
39
46
  }
40
47
 
41
48
  percentageFromList = parseFloat(percentageFromList.toFixed(3));
42
49
 
43
- const rateForTheBracket = isCompany
44
- ? 0
45
- : calculateRange(price, minimumPropertyPrice, maxisumPropertyPrice, percentageFromList);
50
+ const rateForTheBracket = calculateRange(
51
+ price, minimumPropertyPrice, maximumPropertyPrice, percentageFromList,
52
+ );
46
53
 
47
54
  accumulator[rateIndex] = rateForTheBracket;
48
55
  accumulator.totalRate += rateForTheBracket;
@@ -51,7 +58,7 @@ const englishRates = (
51
58
 
52
59
  return accumulator;
53
60
  }, {
54
- totalRate: initalTotalRate(),
61
+ totalRate: 0,
55
62
  effectiveRate: 0,
56
63
  });
57
64
 
@@ -0,0 +1,48 @@
1
+ import { calculateRange, getPriceBracketIndex } from "./stamp-duty-utils";
2
+
3
+ const scotlandRates = (price, firstTimeBuyer, additionalProperty, isCompany) => {
4
+ const scotlandRatesList = Homeflow.get('stamp_duty_scotland');
5
+
6
+ const ratesToCalculateBasedOnTaxType = () => {
7
+ if(firstTimeBuyer) return scotlandRatesList['first_time_buyer'];
8
+ return scotlandRatesList['base'];
9
+ };
10
+
11
+ const ratesList = ratesToCalculateBasedOnTaxType();
12
+
13
+ const stampDutyRatesCalculation = ratesList.reduce((accumulator, _, index) => {
14
+ // Minumun price from the 1st braket should be always 0
15
+ const minimunFallback = index === 0 ? 0 : Number.POSITIVE_INFINITY;
16
+ const percentageFromList = +(ratesList[index]['base_lbtt_rate']) / 100;
17
+ const minimumPropertyPrice = ratesList[index]['minimum_property_price'] || minimunFallback;
18
+ const maximumPropertyPrice = ratesList[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
19
+ const rateIndex = `rate${index + 1}`;
20
+ const rateForTheBracket = calculateRange(price, minimumPropertyPrice, maximumPropertyPrice, percentageFromList);
21
+
22
+ accumulator[rateIndex] = rateForTheBracket;
23
+ accumulator.totalRate += rateForTheBracket;
24
+
25
+ accumulator.effectiveRate = (accumulator.totalRate / price) * 100;
26
+
27
+ return accumulator;
28
+ }, {
29
+ totalRate: 0,
30
+ effectiveRate: 0,
31
+ });
32
+
33
+ if (additionalProperty || isCompany) {
34
+ const additionalDwellingSurcharge = ratesList[getPriceBracketIndex(price, ratesList)]
35
+ ?.['additional_property_surcharge'];
36
+ if (additionalDwellingSurcharge) {
37
+ stampDutyRatesCalculation.totalRate += ((price * additionalDwellingSurcharge) / 100);
38
+ };
39
+ }
40
+
41
+ // Roundings
42
+ stampDutyRatesCalculation.effectiveRate = Math.round(stampDutyRatesCalculation.effectiveRate * 10) / 10;
43
+ stampDutyRatesCalculation.totalRate = Math.round(stampDutyRatesCalculation.totalRate);
44
+
45
+ return stampDutyRatesCalculation;
46
+ };
47
+
48
+ export default scotlandRates;
@@ -1,5 +1,6 @@
1
1
  import englishRates from './english-rates';
2
- import countryRates from './country-rates';
2
+ import walesRates from './wales-rates';
3
+ import scotlandRates from './scotand-rates';
3
4
 
4
5
  /**
5
6
  * We already have a DefaultStampDutyCalculator component,
@@ -17,16 +18,13 @@ const stampDutyCalculator = ({
17
18
  };
18
19
  }
19
20
 
20
- /**
21
- * For Scotland and Wales
22
- * Once the BE brings data for companies (isCompany)
23
- * countryRates will need an update and then we can have just one method.
24
- */
25
- if (
26
- country?.toLowerCase() === 'scotland'
27
- || country?.toLowerCase() === 'wales')
28
- {
29
- return countryRates(price, firstTimeBuyer, additionalProperty, ukResident, country);
21
+ if (country?.toLowerCase() === 'scotland') {
22
+ return scotlandRates(price, firstTimeBuyer, additionalProperty, isCompany);
23
+ };
24
+
25
+
26
+ if (country?.toLowerCase() === 'wales') {
27
+ return walesRates(price, additionalProperty, isCompany);
30
28
  }
31
29
 
32
30
  // If country not is not specified use English rates by default
@@ -12,10 +12,10 @@ export const getPriceBracketIndex = (price, arr) => {
12
12
 
13
13
  arr.forEach((rates, index) => {
14
14
  if (
15
- (+(rates.maximum_property_price) || Number.POSITIVE_INFINITY) > price
16
- && +(rates.minimum_property_price) < price
15
+ (+(rates.maximum_property_price) || Number.POSITIVE_INFINITY) >= price
16
+ && +(rates.minimum_property_price) <= price
17
17
  ) bracketIndex = index;
18
18
  });
19
19
 
20
- return bracketIndex || 0;
20
+ return bracketIndex;
21
21
  }
@@ -0,0 +1,41 @@
1
+ import { calculateRange } from "./stamp-duty-utils";
2
+
3
+ const walesRates = (price, additionalProperty, isCompany) => {
4
+ const walesRatesList = Homeflow.get('stamp_duty_wales');
5
+
6
+ const ratesToCalculateBasedOnTaxType = () => {
7
+ if(additionalProperty || isCompany) return walesRatesList['corporate_buyer'];
8
+ return walesRatesList['base'];
9
+ };
10
+
11
+ const ratesList = ratesToCalculateBasedOnTaxType();
12
+
13
+ const stampDutyRatesCalculation = ratesList.reduce((accumulator, _, index) => {
14
+ // Minumun price from the 1st braket should be always 0
15
+ const minimunFallback = index === 0 ? 0 : Number.POSITIVE_INFINITY;
16
+ const percentageFromList = +(ratesList[index]['base_ltt_rate']) / 100;
17
+ const minimumPropertyPrice = ratesList[index]['minimum_property_price'] || minimunFallback;
18
+ const maximumPropertyPrice = ratesList[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
19
+ const rateIndex = `rate${index + 1}`;
20
+ const rateForTheBracket = calculateRange(price, minimumPropertyPrice, maximumPropertyPrice, percentageFromList);
21
+
22
+ accumulator[rateIndex] = rateForTheBracket;
23
+ accumulator.totalRate += rateForTheBracket;
24
+
25
+ accumulator.effectiveRate = (accumulator.totalRate / price) * 100;
26
+
27
+ return accumulator;
28
+ }, {
29
+ totalRate: 0,
30
+ effectiveRate: 0,
31
+ });
32
+
33
+ // Roundings
34
+ stampDutyRatesCalculation.effectiveRate = Math.round(stampDutyRatesCalculation.effectiveRate * 10) / 10;
35
+ stampDutyRatesCalculation.totalRate = Math.round(stampDutyRatesCalculation.totalRate);
36
+
37
+
38
+ return stampDutyRatesCalculation;
39
+ };
40
+
41
+ export default walesRates;
@@ -1,49 +0,0 @@
1
- import { calculateRange } from "./stamp-duty-utils";
2
-
3
- const countryRates = (price, firstTimeBuyer, additionalProperty, ukResident, country) => {
4
- const countryConfig = {
5
- 'scotland': {
6
- cmsData: Homeflow.get('stamp_duty_scotland'),
7
- base: 'base_lbtt_rate',
8
- },
9
- 'wales': {
10
- cmsData: Homeflow.get('stamp_duty_wales'),
11
- base: 'base_ltt_rate',
12
- }
13
- }
14
- const cmsRates = countryConfig[country].cmsData;
15
-
16
- const buyerStatusAsKeyOfObject = () => {
17
- if(firstTimeBuyer) return 'first_time_buyer_rate';
18
- if(additionalProperty) return 'additional_property_rate';
19
- return countryConfig[country].base;
20
- };
21
-
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;
25
- const percentageFromList = +(cmsRates[index][buyerStatusAsKeyOfObject()]) / 100;
26
- const minimumPropertyPrice = cmsRates[index]['minimum_property_price'] || minimunFallback;
27
- const maxisumPropertyPrice = cmsRates[index]['maximum_property_price'] || Number.POSITIVE_INFINITY;
28
- const rateIndex = `rate${index + 1}`;
29
- const rateForTheBracket = calculateRange(price, minimumPropertyPrice, maxisumPropertyPrice, percentageFromList);
30
-
31
- accumulator[rateIndex] = rateForTheBracket;
32
- accumulator.totalRate += rateForTheBracket;
33
-
34
- accumulator.effectiveRate = (accumulator.totalRate / price) * 100;
35
-
36
- return accumulator;
37
- }, {
38
- totalRate: 0,
39
- effectiveRate: 0,
40
- });
41
-
42
- // Roundings
43
- stampDutyRatesCalculation.effectiveRate = Math.round(stampDutyRatesCalculation.effectiveRate * 10) / 10;
44
- stampDutyRatesCalculation.totalRate = Math.round(stampDutyRatesCalculation.totalRate);
45
-
46
- return stampDutyRatesCalculation;
47
- };
48
-
49
- export default countryRates;