diff --git a/components/new/details.vue b/components/new/details.vue
index 9beeffc..5d8062c 100644
--- a/components/new/details.vue
+++ b/components/new/details.vue
@@ -20,14 +20,14 @@
Borrower
- $emit('update:borrowers', stripInt(e))">
+ $emit('update:borrowerNum', stripInt(e))">
- $emit('update:creditScore', stripInt(e))">
+ $emit('update:borrowerCredit', stripInt(e))">
- $emit('update:mIncome', strip(e))">
+ $emit('update:borrowerIncome', strip(e))">
@@ -64,26 +64,27 @@
Loan Type
$emit('update:loanType', e.target.value)"
>
$emit('update:loanType', e.target.value)">
$emit('update:loanType', e.target.value)">
$emit('update:loanType', e.target.value)">
@@ -217,55 +218,16 @@ function validate() {
"Accept": "application/json",
"Authorization": `Bearer ${this.token}`,
},
- }).then(response => {
- if (response.ok) { return response.json() }
- response.text().then(t => this.errors = [t])
- }).then(result => {
- if (result) this.$emit('continue', result)
- })
- /*
- 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.")
- }
-
- estimate.loans.forEach(l => {
- if (errors.length) return
-
- if (!l.amount) {
- errors.push(`${l.title} Loan amount cannot be zero`)
- } else if (!l.interest) {
- errors.push(`${l.title} Interest rate cannot be zero`)
- } else if (!l.term) {
- errors.push(`${l.title} Loan term cannot be zero`)
+ }).then(resp => {
+ if (resp.ok && resp.status == 200) {
+ this.errors = []
+ this.$emit('continue')
+ return
+ } else {
+ resp.text().then(t => this.errors = [t])
}
})
-
- if (errors.length) {
- this.errors = errors
- return false
- }
-
- return true
- */
+
}
function generate() {
@@ -288,9 +250,9 @@ export default {
emits: [
'del',
'update:name',
- 'update:borrowers',
- 'update:creditScore',
- 'update:mIncome',
+ 'update:borrowerNum',
+ 'update:borrowerCredit',
+ 'update:borrowerIncome',
'update:transaction',
'update:price',
'update:property',
diff --git a/components/new/new.vue b/components/new/new.vue
index 635d494..586fa08 100644
--- a/components/new/new.vue
+++ b/components/new/new.vue
@@ -29,9 +29,9 @@ class="bi bi-plus" viewBox="0 0 16 16"> loans[sel].title = name"
@del="del"
- @update:borrowers="(b) => estimate.borrowers = b"
- @update:creditScore="(c) => estimate.creditScore = c"
- @update:mIncome="(m) => estimate.mIncome = m"
+ @update:borrowerNum="(b) => estimate.borrower.num = b"
+ @update:borrowerCredit="(c) => estimate.borrower.credit = c"
+ @update:borrowerIncome="(m) => estimate.borrower.income = m"
@update:transaction="(t) => estimate.transaction = t"
@update:price="setPrice"
@update:property="(p) => estimate.property = p"
@@ -94,7 +94,7 @@ const loans = [
Object.assign({}, example,),
Object.assign(
Object.assign({}, example),
- {title: "Another One", mi: {rate: 0}}
+ {title: "Another One", mi: {rate: 0}, type: {}}
),
]
@@ -103,9 +103,7 @@ const estimate = {
property: "",
transaction: 0,
price: 0,
- borrowers: 0,
- creditScore: 0,
- mIncome: 0,
+ borrower: {num: 0, credit: 0, income: 0},
loans: loans,
}
@@ -116,7 +114,10 @@ function loan() {
// Clone loan from initial example as a new loan
function create() {
this.estimate.loans.push(
- Object.assign({}, example, {fees: this.createFees()})
+ Object.assign(
+ {},
+ example, {fees: this.createFees()}
+ )
)
}
@@ -153,7 +154,8 @@ function setLtv(e) {
if (ltv < 0) ltv = 0
this.loan.ltv = ltv
- this.loan.amount = (ltv / 100 * this.estimate.price).toFixed(2)
+ let num = ltv / 100 * this.estimate.price
+ this.loan.amount = Math.round(num*100) / 100
}
// Changes loan.amount\'s and data() values, then syncs with data.ltv
@@ -165,7 +167,8 @@ function setAmount(e) {
if (amount < 0) amount = 0
this.loan.amount = amount
- this.loan.ltv = (amount / this.estimate.price * 100).toFixed(2)
+ let num = amount / this.estimate.price * 100
+ this.loan.ltv = Math.round(num*100) / 100
}
function setDti(e) {
diff --git a/skouter.go b/skouter.go
index da477f3..ed1f031 100644
--- a/skouter.go
+++ b/skouter.go
@@ -88,8 +88,8 @@ type Loan struct {
Id int `json:id`
EstimateId int `json:estimate_id`
Type LoanType `json:"loanType"`
- Amount int `json:"loanAmount"`
- Amortization string `json:"loanAmount"`
+ Amount int `json:"amount"`
+ Amortization string `json:"amortization"`
Term int `json:"term"`
Ltv float32 `json:"ltv"`
Dti float32 `json:"dti"`
@@ -928,12 +928,15 @@ func checkFHA(l Loan, b Borrower) error {
func checkEstimate(e Estimate) error {
if e.Property == "" { return errors.New("Empty property type") }
if e.Price == 0 { return errors.New("Empty property price") }
+
if e.Borrower.Num == 0 {
return errors.New("Missing number of borrowers")
}
+
if e.Borrower.Credit == 0 {
return errors.New("Missing borrower credit score")
}
+
if e.Borrower.Income == 0 {
return errors.New("Missing borrower credit income")
}
@@ -965,7 +968,6 @@ func checkEstimate(e Estimate) error {
if err != nil { return err }
}
- println("done")
return nil
}