|
@@ -0,0 +1,132 @@
|
|
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>
|