homeflowjs 0.9.28 → 0.9.30

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/README.md CHANGED
@@ -66,3 +66,8 @@ success Using linked package for "react".
66
66
  You may need to repeat this for `react-dom`.
67
67
 
68
68
  This is a known issue with peer dependencies, see this comment and containing thread for more info: https://github.com/facebook/react/issues/14257#issuecomment-439967377
69
+
70
+ ## Deploy
71
+
72
+ To create a new version of HomeflowJS when merging to master, keep an eye on the Jenkins build, it pauses and waits for publish confirmation where you can enter the new version number and publish:
73
+
@@ -56,7 +56,7 @@ const Modal = ({ withUserModal, children }) => {
56
56
  )}
57
57
  />
58
58
  );
59
- });
59
+ }) || [];
60
60
 
61
61
  if (withUserModal) {
62
62
  modals.push(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.9.28",
3
+ "version": "0.9.30",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,3 +1,8 @@
1
+ const calculateRange = (price, lower, upper, rate) => {
2
+ if (price <= lower) return 0;
3
+ return (Math.min(upper, price) - lower) * rate;
4
+ }
5
+
1
6
  const englishRates = (price, firstTimeBuyer, additionalProperty) => {
2
7
  let effectiveRate = 0;
3
8
  let totalRate = 0;
@@ -7,119 +12,27 @@ const englishRates = (price, firstTimeBuyer, additionalProperty) => {
7
12
  let rate4 = 0;
8
13
  let rate5 = 0;
9
14
 
10
- // First time buyer
11
- if (firstTimeBuyer) {
12
- // Rate 2
13
- if (price - 300000 > 0) {
14
- if ((price - 300000) > (500000 - 300000)) {
15
- rate2 = (500000 - 300000) * 0.05;
16
- } else {
17
- rate2 = (price - 300000) * 0.05;
18
- }
19
- }
20
-
21
- // Rate 3 ( + supplemental rate 1)
22
- if (price - 500000 > 0) {
23
- rate1 = 5000; // 2% on 125k-250lk + 5% on 250-300k
24
- if ((price - 500000) > (925000 - 500000)) {
25
- rate3 = (925000 - 500000) * 0.05;
26
- } else {
27
- rate3 = (price - 500000) * 0.05;
28
- }
29
- }
30
-
31
- // Rate 4
32
- if (price - 925000 > 0) {
33
- if ((price - 925000) > (1500000 - 925000)) {
34
- rate4 = (1500000 - 925000) * 0.10;
35
- } else {
36
- rate4 = (price - 925000) * 0.10;
37
- }
38
- }
39
-
40
- // Rate 5
41
- if (price - 1500000 > 0) {
42
- rate5 = (price - 1500000);
43
- rate5 *= 0.12;
44
- }
45
-
15
+ // First time buyer less than or equal to 625,000 GBP
16
+ if (firstTimeBuyer && price <= 625000) {
17
+ rate2 = calculateRange(price, 425000, Number.POSITIVE_INFINITY, 0.05);
46
18
  }
47
19
 
48
20
  // Additional property
49
- if (additionalProperty) {
50
- // Rate 1
51
- if (price > 125000) rate1 = 125000 * 0.03;
52
- if (price <= 125000) {
53
- rate1 = price * 0.03;
54
- }
55
-
56
- // Rate 2
57
- if (price - 125000 > 0) {
58
- if ((price - 125000) > (250000 - 125000)) {
59
- rate2 = (250000 - 125000) * 0.05;
60
- } else {
61
- rate2 = (price - 125000) * 0.05;
62
- }
63
- }
64
-
65
- // Rate 3
66
- if (price - 250000 > 0) {
67
- if ((price - 250000) > (925000 - 250000)) {
68
- rate3 = (925000 - 250000) * 0.08;
69
- } else {
70
- rate3 = (price - 250000) * 0.08;
71
- }
72
- }
73
-
74
- // Rate 4
75
- if (price - 925000 > 0) {
76
- if ((price - 925000) > (1500000 - 925000)) {
77
- rate4 = (1500000 - 925000) * 0.13;
78
- } else {
79
- rate4 = (price - 925000) * 0.13;
80
- }
81
- }
82
-
83
- // Rate 5
84
- if (price - 1500000 > 0) {
85
- rate5 = (price - 1500000);
86
- rate5 *= 0.15;
87
- }
21
+ if (additionalProperty && price >=40000) {
22
+ rate1 = calculateRange(price, 0, 250000, 0.03);
23
+ rate2 = calculateRange(price, 250000, 925000, 0.08);
24
+ rate3 = calculateRange(price, 925000, 1500000, 0.13);
25
+ rate4 = calculateRange(price, 1500000, Number.POSITIVE_INFINITY, 0.15);
88
26
  }
89
27
 
90
- if (!firstTimeBuyer && !additionalProperty) {
91
- // Rate 2
92
- if (price - 125000 > 0) {
93
- if ((price - 125000) > (250000 - 125000)) {
94
- rate2 = (250000 - 125000) * 0.02;
95
- } else {
96
- rate2 = (price - 125000) * 0.02;
97
- }
98
- }
99
-
100
- // Rate 3
101
- if (price - 250000 > 0) {
102
- if ((price - 250000) > (925000 - 250000)) {
103
- rate3 = (925000 - 250000) * 0.05;
104
- } else {
105
- rate3 = (price - 250000) * 0.05;
106
- }
107
- }
108
-
109
- // Rate 4
110
- if (price - 925000 > 0) {
111
- if ((price - 925000) > (1500000 - 925000)) {
112
- rate4 = (1500000 - 925000) * 0.10;
113
- } else {
114
- rate4 = (price - 925000) * 0.10;
115
- }
116
- }
117
-
118
- // Rate 5
119
- if (price - 1500000 > 0) {
120
- rate5 = (price - 1500000);
121
- rate5 *= 0.12;
122
- }
28
+ // Moving OR first time buyer > 625,000 GBP
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);
123
36
  }
124
37
 
125
38
  totalRate = rate1 + rate2 + rate3 + rate4 + rate5;