@@ -162,6 +162,15 @@ type Estimate struct { | |||
Loans []Loan `json:"loans"` | |||
} | |||
type Report struct { | |||
Title string | |||
Name string | |||
Avatar string | |||
Letterhead string | |||
User User | |||
Estimate Estimate | |||
} | |||
type Password struct { | |||
Old string `json:"old"` | |||
New string `json:"new"` | |||
@@ -1849,14 +1858,7 @@ func showPDF(w http.ResponseWriter, r *http.Request) { | |||
if err != nil { w.WriteHeader(500); return } | |||
users, err := queryUsers(db, 1) | |||
info := struct { | |||
Title string | |||
Name string | |||
Avatar string | |||
Letterhead string | |||
User User | |||
Estimate Estimate | |||
}{ | |||
info := Report{ | |||
Title: "test PDF", | |||
Name: "idk-random-name", | |||
User: users[0], | |||
@@ -1905,14 +1907,7 @@ func getPdf(w http.ResponseWriter, db *sql.DB, r *http.Request) { | |||
} | |||
users, err := queryUsers(db, claims.Id) | |||
info := struct { | |||
Title string | |||
Name string | |||
Avatar string | |||
Letterhead string | |||
User User | |||
Estimate Estimate | |||
}{ | |||
info := Report{ | |||
Title: "test PDF", | |||
Name: "idk-random-name", | |||
User: users[0], | |||
@@ -1,9 +1,69 @@ | |||
{{define "comparison"}} | |||
<section class="comparison"> | |||
<div class="box"> | |||
hello | |||
</div> | |||
<section id="comparison"> | |||
<table> | |||
<thead><tr> | |||
<th></th>{{range $l := .Estimate.Loans}}<th>{{$l.Name}}</th>{{end}} | |||
</tr></thead> | |||
<tbody> | |||
<tr><td>Type</td> | |||
{{range .Estimate.Loans}}<td>{{.Type.Name}}</td>{{end}}</tr> | |||
<tr><td>Term</td> | |||
{{range .Estimate.Loans}}<td>{{.Term}} Years</td>{{end}}</tr> | |||
<tr><td>Amortization</td> | |||
{{range .Estimate.Loans}}<td>{{.Amortization}}</td>{{end}}</tr> | |||
<tr><td>Interest rate</td> | |||
{{range .Estimate.Loans}}<td>{{.Interest}}%</td>{{end}}</tr> | |||
<tr><td>Monthly MI</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Mi.Premium}}/month</td>{{end}}</tr> | |||
<tr><td>Real estate taxes</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Tax}}/month</td>{{end}}</tr> | |||
<tr class="total"><td>Total monthly</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalMonthly}}</td>{{end}}</tr> | |||
<tr class="gap"></tr> | |||
<tr><td>Purchase price</td> | |||
{{range .Estimate.Loans}}<td>${{dollars $.Estimate.Price}}</td>{{end}}</tr> | |||
<tr><td>Loan amount</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Amount}}</td>{{end}}</tr> | |||
<tr><td>Down payment</td> | |||
{{range .Estimate.Loans}}<td>${{diff .Amount $.Estimate.Price}}</td>{{end}}</tr> | |||
<tr><td>Closing costs</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalFees}}</td>{{end}}</tr> | |||
<tr><td>MI Premium</td> | |||
{{range .Estimate.Loans}}<td>${{.Mi.Upfront}}</td>{{end}}</tr> | |||
<tr><td>Credits</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalCredits}}</td>{{end}}</tr> | |||
<tr class="total"><td>Cash to close</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.CashToClose}}</td>{{end}}</tr> | |||
</tbody> | |||
</table> | |||
</section> | |||
{{end}} | |||
<style scoped> | |||
table { | |||
width: 100%; | |||
margin-top: 20px; | |||
} | |||
tr.gap { | |||
height: 20px; | |||
} | |||
tr.total { | |||
text-decoration: underline; | |||
font-weight: bold; | |||
} | |||
table td:first-child { | |||
font-weight: bold; | |||
} | |||
tbody tr:nth-child(odd) { | |||
background: #F5F5F3; | |||
} | |||
table td { | |||
padding: 4px; | |||
} | |||
</style> | |||
{{end}} |
@@ -12,7 +12,7 @@ | |||
Get an official quote before choosing a loan.</p> | |||
</div> | |||
{{template "header" .}} | |||
{{template "summary" .}} | |||
{{template "comparison" .}} | |||
<div class="break"></div> | |||
@@ -21,9 +21,8 @@ Get an official quote before choosing a loan.</p> | |||
Get an official quote before choosing a loan.</p> | |||
</div> | |||
{{template "header" .}} | |||
{{template "comparison" .}} | |||
{{template "summary" .}} | |||
<div class="break"></div> | |||
</body> | |||
<style> | |||
@@ -1,69 +1,10 @@ | |||
{{define "summary"}} | |||
<section id="summary"> | |||
<table> | |||
<thead><tr> | |||
<th></th>{{range $l := .Estimate.Loans}}<th>{{$l.Name}}</th>{{end}} | |||
</tr></thead> | |||
<tbody> | |||
<tr><td>Type</td> | |||
{{range .Estimate.Loans}}<td>{{.Type.Name}}</td>{{end}}</tr> | |||
<tr><td>Term</td> | |||
{{range .Estimate.Loans}}<td>{{.Term}} Years</td>{{end}}</tr> | |||
<tr><td>Amortization</td> | |||
{{range .Estimate.Loans}}<td>{{.Amortization}}</td>{{end}}</tr> | |||
<tr><td>Interest rate</td> | |||
{{range .Estimate.Loans}}<td>{{.Interest}}%</td>{{end}}</tr> | |||
<tr><td>Monthly MI</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Mi.Premium}}/month</td>{{end}}</tr> | |||
<tr><td>Real estate taxes</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Tax}}/month</td>{{end}}</tr> | |||
<tr class="total"><td>Total monthly</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalMonthly}}</td>{{end}}</tr> | |||
<tr class="gap"></tr> | |||
<tr><td>Purchase price</td> | |||
{{range .Estimate.Loans}}<td>${{dollars $.Estimate.Price}}</td>{{end}}</tr> | |||
<tr><td>Loan amount</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Amount}}</td>{{end}}</tr> | |||
<tr><td>Down payment</td> | |||
{{range .Estimate.Loans}}<td>${{diff .Amount $.Estimate.Price}}</td>{{end}}</tr> | |||
<tr><td>Closing costs</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalFees}}</td>{{end}}</tr> | |||
<tr><td>MI Premium</td> | |||
{{range .Estimate.Loans}}<td>${{.Mi.Upfront}}</td>{{end}}</tr> | |||
<tr><td>Credits</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.TotalCredits}}</td>{{end}}</tr> | |||
<tr class="total"><td>Cash to close</td> | |||
{{range .Estimate.Loans}}<td>${{dollars .Result.CashToClose}}</td>{{end}}</tr> | |||
</tbody> | |||
</table> | |||
<section class="summary"> | |||
<h2>{{.}}</h2> | |||
<div class="box"> | |||
hello | |||
</div> | |||
</section> | |||
{{end}} | |||
<style scoped> | |||
table { | |||
width: 100%; | |||
margin-top: 20px; | |||
} | |||
tr.gap { | |||
height: 20px; | |||
} | |||
tr.total { | |||
text-decoration: underline; | |||
font-weight: bold; | |||
} | |||
table td:first-child { | |||
font-weight: bold; | |||
} | |||
tbody tr:nth-child(odd) { | |||
background: #F5F5F3; | |||
} | |||
table td { | |||
padding: 4px; | |||
} | |||
</style> | |||
{{end}} |