From cdd358903befcf200cc28c9504aba6fd5ec5d768 Mon Sep 17 00:00:00 2001 From: Florian Hartmann Date: Tue, 18 Feb 2020 16:15:13 +0100 Subject: [PATCH] handle calculating scale without values --- financeplanner/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/financeplanner/views.py b/financeplanner/views.py index b5b9fab..6e5e225 100644 --- a/financeplanner/views.py +++ b/financeplanner/views.py @@ -96,7 +96,10 @@ def _floor_to_first_two_places(dec): def _calculate_scale(stats): - max_amount = max(stat["amount"] for stat in stats.values() if stat["amount"] is not None) + amounts = [stat["amount"] for stat in stats.values() if stat["amount"] is not None] + if not amounts: + return 100 + max_amount = max(amounts) return _floor_to_first_two_places(max_amount * Decimal("1.3"))