From 69009f286f4bac8281207bc6923709b2201e4c12 Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Tue, 5 Dec 2023 17:19:30 -0500 Subject: [PATCH] Make dollar amounts more readable --- components/new/new.vue | 19 +++++++++---------- components/new/summary.vue | 2 +- skouter.go | 4 +++- views/report/comparison.tpl | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/components/new/new.vue b/components/new/new.vue index 5b0273c..702385f 100644 --- a/components/new/new.vue +++ b/components/new/new.vue @@ -5,7 +5,7 @@
-

@@ -46,14 +46,14 @@ class="bi bi-plus" viewBox="0 0 16 16"> loans[sel].mi.monthly = !loans[sel].mi.monthly" + "() => estimate.loans[sel].mi.monthly = !estimate.loans[sel].mi.monthly" @continue="generate" /> 1) { + if (this.estimate.loans.length > 1) { let x = this.sel this.sel = 0 - this.loans.splice(x, 1) + this.estimate.loans.splice(x, 1) } } @@ -176,7 +176,7 @@ function setAmount(e) { function setDti(e) { let dti = strip(e) - let loan = this.loans[this.sel] + let loan = this.estimate.loans[this.sel] if (!loan.price) return if (dti > 100) dti = 100 @@ -188,7 +188,7 @@ function setDti(e) { function setHousingDti(e) { let housingDti = strip(e) - let loan = this.loans[this.sel] + let loan = this.estimate.loans[this.sel] if (!loan.price) return if (housingDti > 100) housingDti = 100 @@ -238,7 +238,6 @@ export default { data() { return { estimate: estimate, - loans: estimate.loans, sel: 0, errors: [], hash: window.location.hash diff --git a/components/new/summary.vue b/components/new/summary.vue index 0e26aea..cd00dee 100644 --- a/components/new/summary.vue +++ b/components/new/summary.vue @@ -22,7 +22,7 @@ Credits: ${{format(loan.result.totalCredits)}}

diff --git a/skouter.go b/skouter.go index 3e0400f..8f0ec03 100644 --- a/skouter.go +++ b/skouter.go @@ -270,7 +270,7 @@ func cachePdf(name string) Page { // For calculating down payments diff := func(a, b int) string { - return strconv.FormatFloat(float64(b - a)/100, 'f', 2, 32) + return humanize.Commaf(float64(b - a)/100) } sortFees := func(ftype string, fees []Fee) []Fee { @@ -341,6 +341,8 @@ func (estimate *Estimate) makeResults() []Result { if loan.Mi.Monthly { result.TotalMonthly = result.TotalMonthly + int(loan.Mi.Rate/100/12*float32(loan.Amount)) + } else { + loan.Mi.Upfront = int(loan.Mi.Rate/100*float32(loan.Amount)) } for i := range loan.Fees { diff --git a/views/report/comparison.tpl b/views/report/comparison.tpl index 676d9c0..0777e03 100644 --- a/views/report/comparison.tpl +++ b/views/report/comparison.tpl @@ -30,11 +30,11 @@ Loan amount {{range .Estimate.Loans}}${{dollars .Amount}}{{end}} Down payment -{{range .Estimate.Loans}}${{diff .Amount $.Estimate.Price}}{{end}} +{{range .Estimate.Loans}}${{diff .Amount $.Estimate.Price }}{{end}} Closing costs {{range .Estimate.Loans}}${{dollars .Result.TotalFees}}{{end}} MI Premium - {{range .Estimate.Loans}}${{.Mi.Upfront}}{{end}} + {{range .Estimate.Loans}}${{dollars .Mi.Upfront}}{{end}} Credits {{range .Estimate.Loans}}${{dollars .Result.TotalCredits}}{{end}} Cash to close