Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

231 linhas
5.1 KiB

  1. <template>
  2. <div id="new" class="page">
  3. <h2>New Loan</h2>
  4. <section class="loans-list">
  5. <h3 v-for="(l, indx) in loans"
  6. :class="sel == indx ? 'sel' : ''"
  7. @click="() => sel = indx"
  8. >
  9. {{l.title}}
  10. </h3>
  11. <div class="add">
  12. <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
  13. fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"> <path d="M8 4a.5.5 0
  14. 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0
  15. 0 1 8 4z"/> </svg>
  16. </div>
  17. </section>
  18. <section class="form inputs">
  19. <h3>Loan</h3>
  20. <label>Name</label>
  21. <input :value="loans[sel].title"
  22. @input="(e) => loans[sel].title = stripLetters(e)">
  23. <button @click="del">Delete</button>
  24. </section>
  25. <section class="form inputs">
  26. <h3>Borrower</h3>
  27. <label>Number of Borrowers</label>
  28. <input :value="loans[sel].borrowers"
  29. @input="(e) => loans.forEach(l => l.borrowers = strip(e))">
  30. <label>Credit Score</label>
  31. <input :value="loans[sel].creditScore"
  32. @input="(e) => loans[sel].creditScore = strip(e)">
  33. <label>Monthly Income ($)</label>
  34. <input :value="loans[sel].mIncome"
  35. @input="(e) => loans[sel].mIncome = strip(e)">
  36. </section>
  37. <section class="radios form">
  38. <h3>Transaction Type</h3>
  39. <input type="radio" name="transaction_type" value="transaction"
  40. @input="e => loans[sel].transaction = 0"
  41. selected="loans[sel].transaction == 0">
  42. <label>Purchase</label>
  43. <input type="radio" name="transaction_type" value="refinance"
  44. @input="e => loans[sel].transaction = 1"
  45. selected="loans[sel].transaction == 1">
  46. <label>Refinance</label>
  47. </section>
  48. <section class="form inputs">
  49. <h3>Property Details</h3>
  50. <label>Price ($)</label>
  51. <input :value="loans[sel].price" @input="setPrice">
  52. <label>Type</label>
  53. <select id="" name="" v-model="loans[sel].property">
  54. <option value="attched">Single Family Attached</option>
  55. <option value="detached">Single Family Detached</option>
  56. <option value="lorise">Lo-rise (4 stories or less)</option>
  57. <option value="hirise">Hi-rise (over 4 stories)</option>
  58. </select>
  59. </section>
  60. <section class="radios form">
  61. <h3>Loan Type</h3>
  62. <input type="radio" name="loan_type" value="conv" v-model="loans[sel].type"
  63. >
  64. <label>Conventional</label>
  65. <input type="radio" name="loan_type" value="fha" v-model="loans[sel].type">
  66. <label>FHA</label>
  67. <input type="radio" name="loan_type" value="va" v-model="loans[sel].type">
  68. <label>VA</label>
  69. <input type="radio" name="loan_type" value="usda" v-model="loans[sel].type">
  70. <label>USDA</label>
  71. </section>
  72. <section class="form inputs">
  73. <h3>Loan Details</h3>
  74. <label>Loan Term (years)</label>
  75. <input :value="loans[sel].term"
  76. @input="(e) => loans[sel].term = parseInt(e.target.value.replace(/[^0-9]/g, ''))">
  77. <label>Loan Program</label>
  78. <select id="" name="" v-model="loans[sel].program">
  79. <option value="none">None</option>
  80. </select>
  81. <label>Loan to Value (%)</label>
  82. <input :value="loans[sel].ltv" @input="setLtv">
  83. <label>Loan Amount ($)</label>
  84. <input :value="loans[sel].amount"
  85. @input="setAmount">
  86. <label>Housing Expense DTI (%) - Optional</label>
  87. <input :value="loans[sel].housingDti" @input="setHousingDti">
  88. <label>Total DTI (%) - Optional</label>
  89. <input :value="loans[sel].dti" @input="setDti">
  90. </section>
  91. </div>
  92. </template>
  93. <script>
  94. // Strips non-digits from an input box event and returns it's rounded integer
  95. function strip(e) {
  96. return parseInt(e.target.value.replace(/\D/g, '') || 0)
  97. }
  98. function stripLetters(e) {
  99. return (e.target.value.replace(/\W/g, '') || '')
  100. }
  101. function del() {
  102. if (this.loans.length > 1) {
  103. let x = this.sel
  104. this.sel = 0
  105. this.loans.splice(x, 1)
  106. }
  107. }
  108. function setLtv(e) {
  109. let ltv = strip(e)
  110. let loan = this.loans[this.sel]
  111. if (!loan.price) return
  112. if (ltv > 100) ltv = 100
  113. if (ltv < 0) ltv = 0
  114. loan.ltv = ltv
  115. loan.amount = Math.round(ltv / 100 * loan.price)
  116. }
  117. function setAmount(e) {
  118. let amount = strip(e)
  119. let loan = this.loans[this.sel]
  120. if (!loan.price) return
  121. if (amount > loan.price) amount = loan.price
  122. if (amount < 0) amount = 0
  123. loan.amount = amount
  124. loan.ltv = Math.round(amount / loan.price * 100)
  125. }
  126. function setPrice(e) {
  127. let loan = this.loans[this.sel]
  128. let value = strip(e)
  129. loan.price = value
  130. loan.amount = Math.round(loan.ltv / 100 * value)
  131. }
  132. function setDti(e) {
  133. let dti = strip(e)
  134. let loan = this.loans[this.sel]
  135. if (!loan.price) return
  136. if (dti > 100) dti = 100
  137. if (dti < 0) dti = 0
  138. loan.dti = dti
  139. }
  140. function setHousingDti(e) {
  141. let housingDti = strip(e)
  142. let loan = this.loans[this.sel]
  143. if (!loan.price) return
  144. if (housingDti > 100) housingDti = 100
  145. if (housingDti < 0) housingDti = 0
  146. loan.housingDti = housingDti
  147. }
  148. const loans = [
  149. {
  150. title: "Loan Example",
  151. property: "",
  152. transaction: 0,
  153. type: "",
  154. price: 0,
  155. term: 0,
  156. ltv: 0,
  157. borrowers: 0,
  158. creditScore: 0,
  159. mIncome: 0,
  160. dti: 0,
  161. housingDti: 0,
  162. amount: 0,
  163. program: "",
  164. pud: false,
  165. zip: ''
  166. },
  167. {
  168. title: "Another One",
  169. property: "",
  170. transaction: 0,
  171. type: "",
  172. price: 0,
  173. term: 0,
  174. ltv: 0,
  175. borrowers: 0,
  176. creditScore: 0,
  177. mIncome: 0,
  178. dti: 0,
  179. housingDti: 0,
  180. program: "",
  181. pud: true,
  182. zip: ''
  183. }
  184. ]
  185. const propertyTypes = [
  186. ]
  187. export default {
  188. methods: {
  189. setPrice, setLtv, setAmount, setDti, setHousingDti,
  190. strip, stripLetters, del
  191. },
  192. props: ['user'],
  193. data() {
  194. return {
  195. loans: loans, sel: 0, loan: loans[0],
  196. }
  197. }
  198. }
  199. </script>