05/31 Template fix

This commit is contained in:
2026-05-31 21:30:57 -04:00
parent 8b1594da5a
commit 842923cb89
3 changed files with 13 additions and 2 deletions
+11
View File
@@ -62,4 +62,15 @@ def create_app(config_name=None):
def percent_filter(value): def percent_filter(value):
return format_percent(value) return format_percent(value)
@app.template_filter('shares')
def shares_filter(value):
"""Format share quantity — strips trailing zeros, keeps up to 8 decimal places."""
try:
f = float(value)
except (TypeError, ValueError):
return '0'
# Format to 8 decimal places then strip trailing zeros
s = '{:.8f}'.format(f).rstrip('0').rstrip('.')
return s if s else '0'
return app return app
+1 -1
View File
@@ -31,7 +31,7 @@
<div class="row g-2 mt-1"> <div class="row g-2 mt-1">
<div class="col-6"> <div class="col-6">
<div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;">Shares</div> <div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;">Shares</div>
<div class="mono" style="font-size:16px;font-weight:600;">{{ "%.6f"|format(inv.shares|float)|replace('000000','').rstrip('0').rstrip('.') }}</div> <div class="mono" style="font-size:16px;font-weight:600;">{{ inv.shares | shares }}</div>
</div> </div>
<div class="col-6"> <div class="col-6">
<div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;">Avg Cost</div> <div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;">Avg Cost</div>
+1 -1
View File
@@ -135,7 +135,7 @@
</div> </div>
</td> </td>
<td class="text-end mono" style="font-size:12px;color:var(--muted);"> <td class="text-end mono" style="font-size:12px;color:var(--muted);">
{{ "%.4f"|format(inv.shares|float) | replace('.0000','') }} {{ inv.shares | shares }}
</td> </td>
<td class="text-end"> <td class="text-end">
{% if inv.current_price %} {% if inv.current_price %}