diff --git a/components/new/details.vue b/components/new/details.vue index 38a87b1..65d36ba 100644 --- a/components/new/details.vue +++ b/components/new/details.vue @@ -91,46 +91,49 @@

Loan Details

+@input="(e) => $emit('update:term', stripInt(e))"> - - + +@input="(e) => $emit('update:amount', e)"> - + - + +@input="(e) => { $emit('update:hoa', strip(e)) }"> +@input="(e) => { $emit('update:interest', stripPerc(e)) }"> +@input="(e) => $emit('update:interestDays', stripInt(e))"> +@input="(e) => { $emit('update:hazardEscrow', stripInt(e)) }"> +@input="(e) => $emit('update:hazard', strip(e))"> +@input="(e) => $emit('update:tax', strip(e))">
@@ -197,56 +200,6 @@ function addFee(fee, isDebit) { } -// Changes loan.ltv's and data() values, then syncs with data.amount -function setLtv(e) { - let ltv = strip(e) - let loan = this.loans[this.sel] - if (!this.estimate.price) return - - if (ltv > 100) ltv = 100 - if (ltv < 0) ltv = 0 - - loan.ltv = ltv - loan.amount = (ltv / 100 * this.estimate.price).toFixed(2) -} - -// Changes loan.amount\'s and data() values, then syncs with data.ltv -function setAmount(e) { - let amount = strip(e) - let loan = this.loans[this.sel] - if (!this.estimate.price) return - - if (amount > loan.price) amount = loan.price - if (amount < 0) amount = 0 - - loan.amount = amount - loan.ltv = (amount / this.estimate.price * 100).toFixed(2) -} - -function setDti(e) { - let dti = strip(e) - let loan = this.loans[this.sel] - if (!loan.price) return - - if (dti > 100) dti = 100 - if (dti < 0) dti = 0 - - e.target.value = dti - loan.dti = dti -} - -function setHousingDti(e) { - let housingDti = strip(e) - let loan = this.loans[this.sel] - if (!loan.price) return - - if (housingDti > 100) housingDti = 100 - if (housingDti < 0) housingDti = 0 - - e.target.value = housingDti - loan.housingDti = housingDti -} - function validate() { let errors = [] const estimate = this.estimate @@ -287,8 +240,7 @@ function validate() { export default { components: { FeeDialog }, methods: { - setLtv, setAmount, setDti, setHousingDti, strip, stripInt, - stripLetters, stripPerc, createFee, addFee, validate + strip, stripInt, stripLetters, stripPerc, createFee, addFee, validate }, props: ['estimate', 'loans', 'sel'], // Loan updates assume the currently selected loan is being modified, and @@ -303,10 +255,15 @@ export default { 'update:price', 'update:propertyType', + // Loan specific emits 'update:loanType', - 'update:loanTerm', - 'update:loanProgram', + 'update:term', + 'update:program', 'update:ltv', + 'update:amount', + 'update:housingDti', + 'update:dti', + 'update:hoa', ], data() { return { diff --git a/components/new/new.vue b/components/new/new.vue index 618f2ba..a42a511 100644 --- a/components/new/new.vue +++ b/components/new/new.vue @@ -31,9 +31,17 @@ class="bi bi-plus" viewBox="0 0 16 16"> estimate.creditScore = c" @update:mIncome="(m) => estimate.mIncome = m" @update:transaction="(t) => estimate.transaction = t" + @update:price="(p) => estimate.price = p" @update:property="(p) => estimate.property = p" @update:loanType="(lt) => loans[sel].type = lt" + @update:term="(lt) => loans[sel].term = lt" + @update:program="(p) => loans[sel].program = p" + @update:ltv="setLtv" + @update:amount="setAmount" + @update:housingDti="setHousingDti" + @update:dti="setDti" + @update:hoa="(hoa) => loans[sel].hoa = hoa" /> @@ -41,6 +49,7 @@ class="bi bi-plus" viewBox="0 0 16 16"> and data() values, then syncs with data.amount +function setLtv(e) { + let ltv = strip(e) + let loan = this.loans[this.sel] + if (!this.estimate.price) return + + if (ltv > 100) ltv = 100 + if (ltv < 0) ltv = 0 + + loan.ltv = ltv + loan.amount = (ltv / 100 * this.estimate.price).toFixed(2) +} + +// Changes loan.amount\'s and data() values, then syncs with data.ltv +function setAmount(e) { + let amount = strip(e) + let loan = this.loans[this.sel] + if (!this.estimate.price) return + + if (amount > loan.price) amount = loan.price + if (amount < 0) amount = 0 + + loan.amount = amount + loan.ltv = (amount / this.estimate.price * 100).toFixed(2) +} + +function setDti(e) { + let dti = strip(e) + let loan = this.loans[this.sel] + if (!loan.price) return + + if (dti > 100) dti = 100 + if (dti < 0) dti = 0 + + e.target.value = dti + loan.dti = dti +} + +function setHousingDti(e) { + let housingDti = strip(e) + let loan = this.loans[this.sel] + if (!loan.price) return + + if (housingDti > 100) housingDti = 100 + if (housingDti < 0) housingDti = 0 + + e.target.value = housingDti + loan.housingDti = housingDti +} + function generate() { this.errors = this.validate() if (this.errors.length) return @@ -139,7 +199,8 @@ function generate() { export default { components: { Summary, LoanDetails }, methods: { - generate, createFees, del, create, setPrice + generate, createFees, del, create, setPrice, setLtv, setAmount, + setDti, setHousingDti }, props: ['user', 'fees'], data() {