Browse Source

Add MI and HOA fields

master
Immanuel Onyeka 2 years ago
parent
commit
e2cf14d10a
2 changed files with 72 additions and 52 deletions
  1. +5
    -0
      components/mi.vue
  2. +67
    -52
      components/new.vue

+ 5
- 0
components/mi.vue View File

@@ -0,0 +1,5 @@
<template>
</template>

<script>
</script>

+ 67
- 52
components/new.vue View File

@@ -41,10 +41,10 @@ class="bi bi-plus" viewBox="0 0 16 16"> <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0
<h3>Borrower</h3> <h3>Borrower</h3>
<label>Number of Borrowers</label> <label>Number of Borrowers</label>
<input :value="estimate.borrowers" <input :value="estimate.borrowers"
@input="(e) => estimate.borrowers = strip(e)"> @input="(e) => estimate.borrowers = stripInt(e)">
<label>Credit Score</label> <label>Credit Score</label>
<input :value="estimate.creditScore" <input :value="estimate.creditScore"
@input="(e) => estimate.creditScore = strip(e)"> @input="(e) => estimate.creditScore = stripInt(e)">
<label>Monthly Income ($)</label> <label>Monthly Income ($)</label>
<input :value="estimate.mIncome" <input :value="estimate.mIncome"
@input="(e) => estimate.mIncome = strip(e)"> @input="(e) => estimate.mIncome = strip(e)">
@@ -53,11 +53,11 @@ class="bi bi-plus" viewBox="0 0 16 16"> <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0


<section class="radios form"> <section class="radios form">
<h3>Transaction Type</h3> <h3>Transaction Type</h3>
<input type="radio" name="transaction_type" value="transaction" <input type="radio" name="transaction_type" value="estimate.transaction"
@input="e => estimate.transaction = 0" @input="e => estimate.transaction = 0"
selected="estimate.transaction == 0"> selected="estimate.transaction == 0">
<label>Purchase</label> <label>Purchase</label>
<input type="radio" name="transaction_type" value="refinance" <input type="radio" name="transaction_type" value="estimate.refinance"
@input="e => estimate.transaction = 1" @input="e => estimate.transaction = 1"
selected="estimate.transaction == 1"> selected="estimate.transaction == 1">
<label>Refinance</label> <label>Refinance</label>
@@ -109,46 +109,42 @@ selected="estimate.transaction == 1">
<input :value="loans[sel].housingDti" @input="setHousingDti"> <input :value="loans[sel].housingDti" @input="setHousingDti">
<label>Total DTI (%) - Optional</label> <label>Total DTI (%) - Optional</label>
<input :value="loans[sel].dti" @input="setDti"> <input :value="loans[sel].dti" @input="setDti">
<label>Home Owner's Association ($/month)</label>
<input :value="loans[sel].hoa"
@input="(e) => { loans[sel].hoa = strip(e) }">

<label>Interest Rate (%)</label> <label>Interest Rate (%)</label>
<input :value="loans[sel].interest" @input="setInterest"> <input :value="loans[sel].interest"
@input="(e) => { loans[sel].interest = stripPerc(e) }">
<label>Days of Interest</label> <label>Days of Interest</label>
<input :value="loans[sel].interestDays" @input="setInterestDays"> <input :value="loans[sel].interestDays"

@input="(e) => {loans[sel].interestDays = stripInt(e)}">
<label>Hazard Insurance Escrowed?</label> <label>Hazard Insurance Escrow (months)</label>
<input type="checkbox" :value="loans[sel].hazardEscrowed" @input=""> <input :value="loans[sel].hazardEscrow"
<label>Months to Escrow Hazard Insurance</label> @input="(e) => {loans[sel].hazardEscrow = stripInt(e)}">
<input :value="loans[sel].hazardMonths" @input=""> <label>Hazard Insurance ($/month)</label>
<label>Hazard Insurance ($/monthly)</label> <input :value="loans[sel].hazard"
<input :value="loans[sel].hazard" @input="setHazard"> @input="(e) => {loans[sel].hazard = strip(e)}">

<label>Real Estate Tax Escrow (months)</label>
<label>Taxes Escrowed?</label> <input :value="loans[sel].taxEscrow"
<input type="checkbox" :value="loans[sel].taxEscrowed" @input=""> @input="e => {loans[sel].taxEscrow = stripInt(e)}">
<label>Months to Escrow Real Estate Tax</label> <label>Real Estate Tax ($/month)</label>
<input :value="loans[sel].taxEscrow" @input=""> <input :value="loans[sel].tax"
<label>Real Estate Tax ($/monthly)</label> @input="(e) => {loans[sel].tax = strip(e)}">
<input :value="loans[sel].tax" @input="setTax">
</section> </section>


<section class="form inputs"> <section class="form radios">
<h3>Interest Rates</h3> <h3>Mortgage Insurance</h3>
<label>Loan Term (years)</label> <input type="radio" name="transaction_type" value="transaction"
<input :value="loans[sel].term" @input="e => estimate.transaction = 0"
@input="(e) => loans[sel].term = strip(e)"> selected="estimate.transaction == 0">

<label>National MI</label>
<label>Loan Program</label> <input type="radio" name="transaction_type" value="refinance"
<select id="" name="" v-model="loans[sel].program"> @input="e => estimate.transaction = 1"
<option value="none">None</option> selected="estimate.transaction == 1">
</select> <label>MGIC</label>

<label>Loan to Value (%)</label>
<input :value="loans[sel].ltv" @input="setLtv">
<label>Loan Amount ($)</label>
<input :value="loans[sel].amount"
@input="setAmount">
<label>Housing Expense DTI (%) - Optional</label>
<input :value="loans[sel].housingDti" @input="setHousingDti">
<label>Total DTI (%) - Optional</label>
<input :value="loans[sel].dti" @input="setDti">
</section> </section>


</div> </div>
@@ -166,11 +162,10 @@ const example = {
interest: 0, interest: 0,
interestDays: 0, interestDays: 0,
hazard: 0, // Hazard insurance monthly payment hazard: 0, // Hazard insurance monthly payment
hazardMonths: 0, // Hazard insurance months hazardEscrow: 0, // Hazard insurance escrow in months (0 is none)
hazardEscrowed: true, // If hazard insurance is escrowed
tax: 0, // Real Estate taxes monthly payment tax: 0, // Real Estate taxes monthly payment
taxEscrow: 0, // Months to escrow taxEscrow: 0, // Months to escrow (0 is none)
taxEscrowed: true, // If tax is escrowed hoa: 0, // Home owner's association monthly fee
program: "", program: "",
pud: true, // Property under development pud: true, // Property under development
zip: '' zip: ''
@@ -196,13 +191,36 @@ function create() {
this.estimate.loans.push(Object.assign({}, loans[0])) this.estimate.loans.push(Object.assign({}, loans[0]))
} }


// Strips non-digits from an input box event and returns it's rounded integer // Strips non-digits from an input box event and returns it's rounded integer.
// It also preserves current valid entry (.)
function strip(e) { function strip(e) {
let valid = e.target.value.match(/\d+\.?\d?\d?/)?.[0] ?? ""
e.target.value = valid
return Number(valid || 0)
}

function stripInt(e) {
let value = parseInt(e.target.value.replace(/\D/g, '') || 0) let value = parseInt(e.target.value.replace(/\D/g, '') || 0)
e.target.value = value e.target.value = value
return value return value
} }


function stripPerc(e) {
let num = strip(e)

if (num > 100) {
num = 100
e.target.value = num
}

if (num < 0) {
num = 0
e.target.value = num
}

return num
}

function stripLetters(e) { function stripLetters(e) {
let value = (e.target.value.replace(/[^\w\s]/g, '').slice(0, 20) || '') let value = (e.target.value.replace(/[^\w\s]/g, '').slice(0, 20) || '')
e.target.value = value e.target.value = value
@@ -227,8 +245,7 @@ function setLtv(e) {
if (ltv < 0) ltv = 0 if (ltv < 0) ltv = 0


loan.ltv = ltv loan.ltv = ltv
e.target.value = ltv loan.amount = (ltv / 100 * this.estimate.price).toFixed(2)
loan.amount = Math.round(ltv / 100 * this.estimate.price)
} }


// Changes loan.amount's <input> and data() values, then syncs with data.ltv // Changes loan.amount's <input> and data() values, then syncs with data.ltv
@@ -241,15 +258,13 @@ function setAmount(e) {
if (amount < 0) amount = 0 if (amount < 0) amount = 0


loan.amount = amount loan.amount = amount
e.target.value = amount loan.ltv = (amount / this.estimate.price * 100).toFixed(2)
loan.ltv = Math.round(amount / this.estimate.price * 100)
} }


// Updates the property price for all loans // Updates the property price for all loans
function setPrice(e) { function setPrice(e) {
let value = strip(e) let value = strip(e)
this.estimate.price = value this.estimate.price = value
e.target.value = value
} }


function setDti(e) { function setDti(e) {
@@ -278,8 +293,8 @@ function setHousingDti(e) {


export default { export default {
methods: { methods: {
setPrice, setLtv, setAmount, setDti, setHousingDti, setPrice, setLtv, setAmount, setDti, setHousingDti, strip, stripInt,
strip, stripLetters, del, create stripLetters, stripPerc, del, create
}, },
props: ['user'], props: ['user'],
data() { data() {


||||||
x
 
000:0
Loading…
Cancel
Save