You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bondCaclculator.vue 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. <currency-input
  6. onClick="this.setSelectionRange(0, this.value.length)"
  7. name="price"
  8. :value="value"
  9. @input="value = $event"
  10. v-model="amount"
  11. id="gross-income"
  12. class="form-control mb-2"
  13. />
  14. <currency-input
  15. onClick="this.setSelectionRange(0, this.value.length)"
  16. name="deposit"
  17. :value="value"
  18. @input="value = $event"
  19. v-model="deposit"
  20. id="gross-income"
  21. class="form-control mb-2"
  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. <script>
  58. /* eslint-disable */
  59. export default {
  60. data() {
  61. return {
  62. amount: 1000000,
  63. deposit: 0,
  64. term: 10,
  65. rate: 7,
  66. isInputActive: false
  67. };
  68. },
  69. props: ["value"],
  70. methods: {
  71. calculate() {
  72. var rate = this.rate / 100 / 12;
  73. var years = this.term * 12;
  74. var topPart = rate * Math.pow(1 + rate, years);
  75. var bottomPart = Math.pow(1 + rate, years) - 1;
  76. var netAmnt = this.amount - this.deposit;
  77. var bond = (netAmnt * topPart) / bottomPart;
  78. }
  79. },
  80. computed: {
  81. totalMonthlyPayment() {
  82. var rate = this.rate / 100 / 12;
  83. var years = this.term * 12;
  84. var topPart = rate * Math.pow(1 + rate, years);
  85. var bottomPart = Math.pow(1 + rate, years) - 1;
  86. var netAmnt = this.amount - this.deposit;
  87. var bond = (netAmnt * topPart) / bottomPart;
  88. if (isNaN(bond)) {
  89. return 0;
  90. } else {
  91. return bond;
  92. }
  93. },
  94. grossIncome() {
  95. return this.totalMonthlyPayment * 3.335120643;
  96. }
  97. }
  98. };
  99. </script>
  100. <style lang="scss" scoped></style>