Selaa lähdekoodia

Add LTV and DTI elements

master
Immanuel Onyeka 2 vuotta sitten
vanhempi
commit
5a83670e03
1 muutettua tiedostoa jossa 44 lisäystä ja 10 poistoa
  1. +44
    -10
      components/new.vue

+ 44
- 10
components/new.vue Näytä tiedosto

@@ -71,44 +71,72 @@ selected="loans[sel].transaction == 1">
<option value="none">None</option>
</select>

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

</div>
</template>

<script>
function setLtv(loan, ltv) {
function setLtv(e) {
let ltv = parseInt(e.target.value.replace(/[^0-9]/g, '') || 0)
let loan = this.loans[this.sel]
if (!loan.price) return

if (ltv > 100) ltv = 100
if (ltv < 0) ltv = 0

loan.ltv = ltv
loan.amount = ltv / 100 * loan.price
loan.amount = Math.round(ltv / 100 * loan.price)
}

function setAmount(e) {
let amount = parseInt(e.target.value.replace(/[^0-9]/g, ''))
let amount = parseInt(e.target.value.replace(/[^0-9]/g, '') || 0)
let loan = this.loans[this.sel]
if (!loan.price) return

if (amount > loan.price) amount = loan.price
if (amount < 0) amount = 0
loan.amount = amount
loan.ltv = amount / loan.price * 100
loan.ltv = Math.round(amount / loan.price * 100)
}

function setPrice(e) {
let loan = this.loans[this.sel]
let value =
parseInt(e.target.value.replace(/[^0-9]/g, ''))
// Should check for NaN after backspace

console.log("the price is %s", value)
loan.price = value
loan.amount = Math.round(loan.ltv / 100 * value)
}

function setDti(e) {
let dti = parseInt(e.target.value.replace(/[^0-9]/g, '') || 0)
let loan = this.loans[this.sel]
if (!loan.price) return

this.loans[this.sel].price =
value
if (dti > 100) dti = 100
if (dti < 0) dti = 0
loan.dti = dti
}

function setHousingDti(e) {
let housingDti = parseInt(e.target.value.replace(/[^0-9]/g, '') || 0)
let loan = this.loans[this.sel]
if (!loan.price) return

if (housingDti > 100) housingDti = 100
if (housingDti < 0) housingDti = 0
loan.housingDti = housingDti
}

const loans = [
@@ -120,6 +148,8 @@ const loans = [
price: 0,
term: 0,
ltv: 0,
dti: 0,
housingDti: 0,
amount: 0,
program: "",
pud: false,
@@ -133,6 +163,8 @@ const loans = [
price: 0,
term: 0,
ltv: 0,
dti: 0,
housingDti: 0,
program: "",
pud: true,
zip: ''
@@ -144,7 +176,9 @@ const propertyTypes = [
]

export default {
methods: { setPrice },
methods: {
setPrice, setLtv, setAmount, setDti, setHousingDti
},
props: ['user'],
data() {
return {


Loading…
Peruuta
Tallenna