Extract amount template

This commit is contained in:
2021-12-07 14:49:58 +00:00
parent 4a0759af8f
commit 6f4bff929e
6 changed files with 20 additions and 13 deletions
+1 -3
View File
@@ -29,9 +29,7 @@
<td>
<a href="transaction/{{.ID}}">{{.Memo}}</a>
</td>
<td style="text-align: right;{{if .Amount.GetPositive}}{{else}}color: red;{{end}}">
{{printf "%.2f" .Amount.GetFloat64}}
</td>
{{template "amount-cell" .Amount}}
</tr>
{{end}}
</table>
+11
View File
@@ -0,0 +1,11 @@
{{define "amount"}}
<span class="right {{if .GetPositive}}{{else}}negative{{end}}">
{{printf "%.2f" .GetFloat64}}
</span>
{{end}}
{{define "amount-cell"}}
<td class="right {{if .GetPositive}}{{else}}negative{{end}}">
{{printf "%.2f" .GetFloat64}}
</td>
{{end}}
+1 -1
View File
@@ -9,7 +9,7 @@
{{range .Accounts}}
<li>
<a href="/budget/{{$.Budget.ID}}/account/{{.ID}}">{{.Name}}</a>
<span class="right">{{printf "%.2f" .Balance.GetFloat64}}</span>
{{template "amount" .Balance}}
</li>
{{end}}
<li>
+1 -3
View File
@@ -24,9 +24,7 @@
<td>
<a href="transaction/{{.ID}}">{{.Memo}}</a>
</td>
<td style="text-align: right;{{if .Amount.GetPositive}}{{else}}color: red;{{end}}">
{{printf "%.2f" .Amount.GetFloat64}}
</td>
{{template "amount-cell" .Amount}}
</tr>
{{end}}
</table>
+2 -6
View File
@@ -28,12 +28,8 @@
</td>
<td>
</td>
<td style="text-align: right;{{if .Balance.GetPositive}}{{else}}color: red;{{end}}">
{{printf "%.2f" .Balance.GetFloat64}}
</td>
<td style="text-align: right;{{if .Activity.GetPositive}}{{else}}color: red;{{end}}">
{{printf "%.2f" .Activity.GetFloat64}}
</td>
{{template "amount-cell" .Balance}}
{{template "amount-cell" .Activity}}
</tr>
{{end}}
</table>
+4
View File
@@ -59,4 +59,8 @@ body {
.right {
text-align: right;
}
.negative {
color: #d50000;
}