diff --git a/app/__init__.py b/app/__init__.py index 1766761..31534e7 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -62,4 +62,15 @@ def create_app(config_name=None): def percent_filter(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 diff --git a/app/templates/investments/detail.html b/app/templates/investments/detail.html index 4817a95..b1a2b81 100644 --- a/app/templates/investments/detail.html +++ b/app/templates/investments/detail.html @@ -31,7 +31,7 @@