@@ -319,6 +319,11 @@ section.form .fee { | |||||
display: flex; | display: flex; | ||||
} | } | ||||
section.form .fee.required { | |||||
display: flex; | |||||
background: #ddd; | |||||
} | |||||
section.form .fee img { | section.form .fee img { | ||||
margin-left: auto; | margin-left: auto; | ||||
} | } | ||||
@@ -99,6 +99,7 @@ function getFees() { | |||||
}).then (result => { | }).then (result => { | ||||
if (!result || !result.length) return // Exit if token is invalid or no fees are saved | if (!result || !result.length) return // Exit if token is invalid or no fees are saved | ||||
this.fees = result | this.fees = result | ||||
console.log(result) | |||||
}) | }) | ||||
} | } | ||||
@@ -26,7 +26,7 @@ | |||||
<input :value="estimate.borrower.credit" | <input :value="estimate.borrower.credit" | ||||
@input="(e) => $emit('update:borrowerCredit', stripInt(e))"> | @input="(e) => $emit('update:borrowerCredit', stripInt(e))"> | ||||
<label>Monthly Income ($)</label> | <label>Monthly Income ($)</label> | ||||
<input :value="estimate.borrower.income" | |||||
<input :value="estimate.borrower.income/100" | |||||
@input="(e) => $emit('update:borrowerIncome', strip(e))"> | @input="(e) => $emit('update:borrowerIncome', strip(e))"> | ||||
</section> | </section> | ||||
@@ -141,14 +141,14 @@ | |||||
<section class="form inputs"> | <section class="form inputs"> | ||||
<h3>Fees</h3> | <h3>Fees</h3> | ||||
<div v-for="(fee, indx) in loan.fees" | <div v-for="(fee, indx) in loan.fees" | ||||
:key="fee.name + indx" class="fee" | |||||
:key="fee.name + indx" class="fee" :class="fee.required && 'required'" | |||||
> | > | ||||
<label> | <label> | ||||
${{(fee.amount / 100).toFixed(2)}} | ${{(fee.amount / 100).toFixed(2)}} | ||||
{{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br> | {{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br> | ||||
{{fee.type}} | {{fee.type}} | ||||
</label> | </label> | ||||
<img width="21" height="21" src="/assets/image/icon/x-red.svg" | |||||
<img v-if="!fee.required" width="21" height="21" src="/assets/image/icon/x-red.svg" | |||||
@click="() => loan.fees.splice(indx, 1)"> | @click="() => loan.fees.splice(indx, 1)"> | ||||
</div> | </div> | ||||
<button @click="resetFees">Reset</button> | <button @click="resetFees">Reset</button> | ||||
@@ -172,7 +172,8 @@ | |||||
<label>monthly</label> | <label>monthly</label> | ||||
</div> | </div> | ||||
<div class="row"> | <div class="row"> | ||||
<input :value="loan.mi.rate" @input="e => $emit('update:manualMI', stripPerc(e))" /> | |||||
<input :value="loan.mi.rate" | |||||
@input="e => $emit('update:manualMI', stripPerc(e))" /> | |||||
</div> | </div> | ||||
</section> | </section> | ||||
@@ -31,12 +31,12 @@ class="bi bi-plus" viewBox="0 0 16 16"> <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 | |||||
@del="del" | @del="del" | ||||
@update:borrowerNum="(b) => estimate.borrower.num = b" | @update:borrowerNum="(b) => estimate.borrower.num = b" | ||||
@update:borrowerCredit="(c) => estimate.borrower.credit = c" | @update:borrowerCredit="(c) => estimate.borrower.credit = c" | ||||
@update:borrowerIncome="(m) => estimate.borrower.income = m" | |||||
@update:borrowerIncome="(m) => estimate.borrower.income = m*100" | |||||
@update:transaction="(t) => estimate.transaction = t" | @update:transaction="(t) => estimate.transaction = t" | ||||
@update:price="setPrice" | @update:price="setPrice" | ||||
@update:property="(p) => estimate.property = p" | @update:property="(p) => estimate.property = p" | ||||
@update:loanType="(lt) => loan.type.id = lt" | |||||
@update:loanType="changeLoanType" | |||||
@update:term="(lt) => loan.term = lt" | @update:term="(lt) => loan.term = lt" | ||||
@update:program="(p) => loans[sel].program = p" | @update:program="(p) => loans[sel].program = p" | ||||
@update:ltv="setLtv" | @update:ltv="setLtv" | ||||
@@ -135,7 +135,7 @@ function del() { | |||||
function setPrice(value) { | function setPrice(value) { | ||||
this.estimate.price = Math.round(value*100) | this.estimate.price = Math.round(value*100) | ||||
this.estimate.loans[this.sel].fees.forEach(fee => { | this.estimate.loans[this.sel].fees.forEach(fee => { | ||||
if (fee.perc) fee.amount = (fee.perc / 100 * value).toFixed(2) | |||||
if (fee.perc) fee.amount = Math.round(fee.perc * value) | |||||
}) | }) | ||||
this.estimate.loans.forEach(l => {l.ltv = 0; l.amount = 0}) | this.estimate.loans.forEach(l => {l.ltv = 0; l.amount = 0}) | ||||
} | } | ||||
@@ -192,6 +192,29 @@ function setHousingDti(e) { | |||||
loan.housingDti = housingDti | loan.housingDti = housingDti | ||||
} | } | ||||
function changeLoanType(id) { | |||||
if (id == this.loan.type.id) return | |||||
// Set mandatory upfront MIP in fees if type is FHA | |||||
let i = this.loan.fees.findIndex( | |||||
l => l.required && l.name == "FHA Upfront MIP" | |||||
) | |||||
if (id == 2) { | |||||
this.loan.fees.push({ | |||||
amount: Math.round(this.estimate.price*1.75/100), | |||||
perc: 1.75, | |||||
name: "FHA Upfront MIP", | |||||
type: "Required", | |||||
id: 0, | |||||
required: true | |||||
}) | |||||
} else if (i >= 0) { | |||||
this.loan.fees.splice(i, 1) | |||||
} | |||||
this.loan.type.id = id | |||||
} | |||||
function generate() { | function generate() { | ||||
window.location.hash = 'new/summary' | window.location.hash = 'new/summary' | ||||
} | } | ||||
@@ -202,7 +225,7 @@ export default { | |||||
components: { LoanSummary, LoanDetails }, | components: { LoanSummary, LoanDetails }, | ||||
methods: { | methods: { | ||||
generate, createFees, del, create, setPrice, setLtv, setAmount, | generate, createFees, del, create, setPrice, setLtv, setAmount, | ||||
setDti, setHousingDti | |||||
setDti, setHousingDti, changeLoanType | |||||
}, | }, | ||||
computed: { loan }, | computed: { loan }, | ||||
props: ['user', 'fees', 'token'], | props: ['user', 'fees', 'token'], | ||||
@@ -70,7 +70,7 @@ type Fee struct { | |||||
Id int `json:"id"` | Id int `json:"id"` | ||||
LoanId int `json:"loan_id"` | LoanId int `json:"loan_id"` | ||||
Amount int `json:"amount"` | Amount int `json:"amount"` | ||||
Perc int `json:"perc"` | |||||
Perc float32 `json:"perc"` | |||||
Type string `json:"type"` | Type string `json:"type"` | ||||
Notes string `json:"notes"` | Notes string `json:"notes"` | ||||
Name string `json:"name"` | Name string `json:"name"` | ||||