Browse Source

Check and display common errors

master
Immanuel Onyeka 2 years ago
parent
commit
2e6ae94c0c
2 changed files with 60 additions and 11 deletions
  1. +9
    -0
      assets/main.css
  2. +51
    -11
      components/new.vue

+ 9
- 0
assets/main.css View File

@@ -5,6 +5,7 @@
--text-light: #1D262E; --text-light: #1D262E;
--text-lighter: #28323B; --text-lighter: #28323B;
--text-lightest: #A1A7AD; --text-lightest: #A1A7AD;
--text-important: #922724;
--outline: #DFE3E8; --outline: #DFE3E8;
--brand: #0f6b4b; --brand: #0f6b4b;
--shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; --shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
@@ -63,6 +64,12 @@ menu.sidebar {
gap: 20px; gap: 20px;
} }


div.errors {
color: var(--text-important);
margin: 20px 0;
min-height: 40px 0;
}

menu.sidebar a { menu.sidebar a {
color: var(--text); color: var(--text);
display: flex; display: flex;
@@ -190,6 +197,8 @@ section.loans-list {
.loans-list h3 { .loans-list h3 {
cursor: pointer; cursor: pointer;
width: fit-content; width: fit-content;
min-height: 20px;
min-width: 20px;
} }


.loans-list .add svg { .loans-list .add svg {


+ 51
- 11
components/new.vue View File

@@ -23,7 +23,7 @@ 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="form inputs"> <section class="form inputs">
<h3>Loan</h3> <h3>Loan</h3>
<label>Name</label> <label>Name</label>
<input :value="loans[sel].title" <input :value="loans[sel].title" required
@input="(e) => loans[sel].title = stripLetters(e)"> @input="(e) => loans[sel].title = stripLetters(e)">
<button @click="del">Delete</button> <button @click="del">Delete</button>
</section> </section>
@@ -53,13 +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="estimate.transaction" <input selected type="radio" name="transaction_type" value="0"
@input="e => estimate.transaction = 0" v-model="estimate.transaction" >
selected="estimate.transaction == 0">
<label>Purchase</label> <label>Purchase</label>
<input type="radio" name="transaction_type" value="estimate.refinance" <input type="radio" name="transaction_type" value="1"
@input="e => estimate.transaction = 1" v-model="estimate.transaction">
selected="estimate.transaction == 1">
<label>Refinance</label> <label>Refinance</label>
</section> </section>


@@ -190,7 +188,13 @@ selected="estimate.transaction == 1">
</section> </section>


<section class="form inputs"> <section class="form inputs">
<button>Generate</button> <button @click="generate">Generate</button>

<div class="errors">
<span v-for="e in errors">{{e}}</span>
</div>

</section> </section>


</div> </div>
@@ -199,6 +203,7 @@ selected="estimate.transaction == 1">
<script> <script>
import Dialog from "./dialog.vue" import Dialog from "./dialog.vue"


// The default fees of a new loan
const fees = [ const fees = [
{ name: 'Processing fee', type: 'Lender Fees', amount: 500 }, { name: 'Processing fee', type: 'Lender Fees', amount: 500 },
{ name: 'Underwriting fee', type: 'Lender Fees', amount: 500 }, { name: 'Underwriting fee', type: 'Lender Fees', amount: 500 },
@@ -212,6 +217,7 @@ const fees = [
{ name: 'State Tax', type: 'Government', amount: 2411.00 }, { name: 'State Tax', type: 'Government', amount: 2411.00 },
] ]


// The default values of a new estimate
const example = { const example = {
title: "Example", title: "Example",
type: "", type: "",
@@ -226,13 +232,14 @@ const example = {
hazardEscrow: 0, // Hazard insurance escrow in months (0 is none) hazardEscrow: 0, // Hazard insurance escrow in months (0 is none)
tax: 0, // Real Estate taxes monthly payment tax: 0, // Real Estate taxes monthly payment
taxEscrow: 0, // Months to escrow (0 is none) taxEscrow: 0, // Months to escrow (0 is none)
hoa: 0, // Home owner's association monthly fee hoa: 100, // Home owner's association monthly fee
program: "", program: "",
pud: true, // Property under development pud: true, // Property under development
zip: '', zip: '',
fees: fees, fees: fees,
} }


// The default loans on a new estimate
const loans = [ const loans = [
Object.assign({}, example, {fees: createFees()}), Object.assign({}, example, {fees: createFees()}),
Object.assign( Object.assign(
@@ -241,6 +248,7 @@ const loans = [
), ),
] ]


// Default estimate fields
const estimate = { const estimate = {
property: "", property: "",
transaction: 0, transaction: 0,
@@ -258,7 +266,7 @@ const newFee = {
// Clone loan from initial example as a new loan // Clone loan from initial example as a new loan
function create() { function create() {
this.estimate.loans.push( this.estimate.loans.push(
Object.assign({}, loans[0], {fees: createFees()}) Object.assign({}, example, {fees: createFees()})
) )
} }


@@ -397,12 +405,43 @@ function setHousingDti(e) {
loan.housingDti = housingDti loan.housingDti = housingDti
} }


function generate() {
this.errors = this.validate()
}

function validate() {
let errors = []
const estimate = this.estimate

// Alternative attribute names for error messages
const names = {
term: "loan term",
ltv: "loan to value",
hazard: "hazard insurance",
hazardEscrow: "hazard insurance escrow",
}

if (!estimate.property) {
errors.push("Missing property type.")
} else if (!estimate.price) {
errors.push("Missing property price.")
} else if (!estimate.borrowers) {
errors.push("Missing number of borrowers.")
} else if (!estimate.creditScore) {
errors.push("Missing credit score.")
} else if (!estimate.mIncome) {
errors.push("Missing monthly income.")
}

return errors
}

export default { export default {
components: { Dialog }, components: { Dialog },
methods: { methods: {
setPrice, setLtv, setAmount, setDti, setHousingDti, strip, stripInt, setPrice, setLtv, setAmount, setDti, setHousingDti, strip, stripInt,
stripLetters, stripPerc, del, create, createFees, createFee, resetFees, stripLetters, stripPerc, del, create, createFees, createFee, resetFees,
addFee addFee, generate, validate
}, },
computed: { computed: {
validFee, validFee,
@@ -414,6 +453,7 @@ export default {
loans: estimate.loans, loans: estimate.loans,
sel: 0, sel: 0,
newFee: null, newFee: null,
errors: [],
} }
}, },
} }


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