Browse Source

BoncCalc & Navlinks

master
30117125 4 years ago
parent
commit
274b0a112a
2 changed files with 139 additions and 35 deletions
  1. 132
    0
      src/components/misc/bondCaclculator.vue
  2. 7
    35
      src/components/shared/navBar.vue

+ 132
- 0
src/components/misc/bondCaclculator.vue View File

1
+<template>
2
+  <div>
3
+    <h2 id="modal-bondcal">Bond Calculator</h2>
4
+    <p>Calculate the value of the property you could buy</p>
5
+    <input
6
+      type="text"
7
+      class="form-control mb-2"
8
+      name="income"
9
+      id="gross-income"
10
+      placeholder="Gross Monthly Household Income"
11
+      v-model="amount"
12
+      @input="displayValue()"
13
+    />
14
+    <input
15
+      type="text"
16
+      class="form-control mb-2"
17
+      name="deposit"
18
+      id="deposit"
19
+      placeholder="Deposit Amount – May be Required"
20
+      v-model="deposit"
21
+      @input="displayDeposit()"
22
+    />
23
+    <div class="slidecontainer mt-4">
24
+      <input type="range" min="5" max="30" value="10" class="slider" id="myRange" v-model="term" />
25
+    </div>
26
+    <p>{{ term }} Years</p>
27
+    <input
28
+      type="text"
29
+      class="form-control mb-2"
30
+      name="interest"
31
+      id="interest"
32
+      placeholder="Interest Rate (Percent)"
33
+      v-model="rate"
34
+    />
35
+    <!-- <button @click="calculate()" class="btn-solid-blue scrollto">CALCULATE</button> -->
36
+    <div class="container p-0 mt-5">
37
+      <div class="row">
38
+        <div class="col-md-7">
39
+          Monthly Repayment
40
+        </div>
41
+        <div class="col-md-5">
42
+          <strong>{{ totalMonthlyPayment | toCurrency }}</strong>
43
+        </div>
44
+      </div>
45
+      <hr />
46
+      <div class="row">
47
+        <div class="col-md-7">
48
+          Gross Montly Income
49
+        </div>
50
+        <div class="col-md-5">
51
+          <strong>{{ grossIncome | toCurrency }}</strong>
52
+        </div>
53
+      </div>
54
+    </div>
55
+  </div>
56
+</template>
57
+
58
+<script>
59
+/* eslint-disable */
60
+export default {
61
+  data() {
62
+    const formatter = new Intl.NumberFormat("en-US", {
63
+      minimumFractionDigits: 2
64
+    });
65
+    return {
66
+      amount: "R" + formatter.format(100000.0),
67
+      deposit: "R" + formatter.format(0),
68
+      term: 10,
69
+      rate: 7,
70
+      isInputActive: false
71
+    };
72
+  },
73
+  props: ["value"],
74
+  methods: {
75
+    calculate() {
76
+      var rate = this.calcRate();
77
+      var years = this.term * 12;
78
+      var topPart = rate * Math.pow(1 + rate, years);
79
+      var bottomPart = Math.pow(1 + rate, years) - 1;
80
+      var netAmnt = this.amount - this.deposit;
81
+      var bond = (netAmnt * topPart) / bottomPart;
82
+    },
83
+    calcRate() {
84
+      var answer = this.rate / 100 / 12;
85
+      return answer;
86
+    },
87
+    displayValue() {
88
+      const formatter = new Intl.NumberFormat("en-US", {
89
+        minimumFractionDigits: 2
90
+      });
91
+      if (this.amount.charAt(0) !== "R") {
92
+        this.amount = "R" + formatter.format(this.amount);
93
+        if (this.amount < 1) {
94
+          this.amount = "R" + 0;
95
+        }
96
+      }
97
+    },
98
+    displayDeposit() {
99
+      if (this.deposit.charAt(0) !== "R") {
100
+        if (this.deposit < 1) {
101
+          this.deposit = "R" + 0;
102
+        }
103
+      }
104
+    }
105
+  },
106
+  computed: {
107
+    totalMonthlyPayment() {
108
+      var rate = this.calcRate;
109
+      var years = this.term * 12;
110
+      var topPart = rate * Math.pow(1 + rate, years);
111
+      var bottomPart = Math.pow(1 + rate, years) - 1;
112
+
113
+      var netAmnt = parseFloat(this.amount.substring(1)) - parseFloat(this.deposit.substring(1));
114
+      var bond = (netAmnt * topPart) / bottomPart;
115
+      if (isNaN(bond)) {
116
+        return 0;
117
+      } else {
118
+        return bond;
119
+      }
120
+    },
121
+    calcRate() {
122
+      var answer = this.rate / 100 / 12;
123
+      return answer;
124
+    },
125
+    grossIncome() {
126
+      return this.totalMonthlyPayment * 3.335120643;
127
+    }
128
+  }
129
+};
130
+</script>
131
+
132
+<style lang="scss" scoped></style>

+ 7
- 35
src/components/shared/navBar.vue View File

19
             <div class="col-md-9" id="topbar">
19
             <div class="col-md-9" id="topbar">
20
               <div class="container clearFix">
20
               <div class="container clearFix">
21
                 <div class="social-links  ">
21
                 <div class="social-links  ">
22
-                  <a href="#">
22
+                  <a href="mailto:info@univateproperties.co.za">
23
                     <i class="fa fa-envelope"></i>
23
                     <i class="fa fa-envelope"></i>
24
                   </a>
24
                   </a>
25
-                  <a href="#">
25
+                  <a href="https://www.facebook.com/univateproperties/" target="_blank">
26
                     <i class="fa fa-facebook"></i>
26
                     <i class="fa fa-facebook"></i>
27
                   </a>
27
                   </a>
28
                   <a href="#">
28
                   <a href="#">
231
           </div>
231
           </div>
232
 
232
 
233
           <div class="modal-body pt-3">
233
           <div class="modal-body pt-3">
234
-            <h2 id="modal-bondcal">Bond Calculator</h2>
235
-            <p>Calculate the value of the property you could buy</p>
236
-            <input
237
-              type="text"
238
-              class="form-control mb-2"
239
-              name="income"
240
-              id="gross-income"
241
-              placeholder="Gross Monthly Household Income"
242
-            />
243
-            <input
244
-              type="text"
245
-              class="form-control mb-2"
246
-              name="deposit"
247
-              id="deposit"
248
-              placeholder="Deposit Amount – May be Required"
249
-            />
250
-            <input
251
-              data-toggle="dropdown"
252
-              name="repayment-term"
253
-              class="form-control mb-2"
254
-              id="replayment-term"
255
-              placeholder="Repayment Term (Years)"
256
-              aria-haspopup="true"
257
-              aria-expanded="false"
258
-            />
259
-            <input
260
-              type="text"
261
-              class="form-control mb-2"
262
-              name="interest"
263
-              id="interest"
264
-              placeholder="Interest Rate (Percent)"
265
-            />
266
-            <a href="#" class="btn-solid-blue scrollto">CALCULATE</a>
234
+            <bondCalculator />
267
           </div>
235
           </div>
268
         </div>
236
         </div>
269
         <!-- modal-content -->
237
         <!-- modal-content -->
278
 /* eslint-disable */
246
 /* eslint-disable */
279
 import { mapState, mapActions } from "vuex";
247
 import { mapState, mapActions } from "vuex";
280
 import Log from "../../assets/Log";
248
 import Log from "../../assets/Log";
249
+import bondCalculator from "../misc/bondCaclculator";
281
 
250
 
282
 export default {
251
 export default {
252
+  components: {
253
+    bondCalculator
254
+  },
283
   data() {
255
   data() {
284
     return {
256
     return {
285
       hover: false,
257
       hover: false,

Loading…
Cancel
Save