mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
fix: networth doesn't load if there aren't any transactions
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.net_worth.utils.calculate_net_worth import (
|
||||
calculate_currency_net_worth,
|
||||
@@ -13,7 +9,6 @@ from apps.net_worth.utils.calculate_net_worth import (
|
||||
calculate_account_net_worth,
|
||||
calculate_historical_account_balance,
|
||||
)
|
||||
from apps.currencies.models import Currency
|
||||
|
||||
|
||||
# Create your views here.
|
||||
@@ -21,15 +16,24 @@ def net_worth_main(request):
|
||||
currency_net_worth = calculate_currency_net_worth()
|
||||
account_net_worth = calculate_account_net_worth()
|
||||
|
||||
historical_net_worth = calculate_historical_currency_net_worth()
|
||||
historical_currency_net_worth = calculate_historical_currency_net_worth()
|
||||
|
||||
labels = list(historical_net_worth.keys())
|
||||
currencies = list(historical_net_worth[labels[0]].keys())
|
||||
labels = (
|
||||
list(historical_currency_net_worth.keys())
|
||||
if historical_currency_net_worth
|
||||
else []
|
||||
)
|
||||
currencies = (
|
||||
list(historical_currency_net_worth[labels[0]].keys())
|
||||
if historical_currency_net_worth
|
||||
else []
|
||||
)
|
||||
|
||||
datasets = []
|
||||
for i, currency in enumerate(currencies):
|
||||
data = [
|
||||
float(month_data[currency]) for month_data in historical_net_worth.values()
|
||||
float(month_data[currency])
|
||||
for month_data in historical_currency_net_worth.values()
|
||||
]
|
||||
datasets.append(
|
||||
{
|
||||
@@ -47,8 +51,14 @@ def net_worth_main(request):
|
||||
|
||||
historical_account_balance = calculate_historical_account_balance()
|
||||
|
||||
labels = list(historical_account_balance.keys())
|
||||
accounts = list(historical_account_balance[labels[0]].keys())
|
||||
labels = (
|
||||
list(historical_account_balance.keys()) if historical_account_balance else []
|
||||
)
|
||||
accounts = (
|
||||
list(historical_account_balance[labels[0]].keys())
|
||||
if historical_account_balance
|
||||
else []
|
||||
)
|
||||
|
||||
datasets = []
|
||||
for i, account in enumerate(accounts):
|
||||
|
||||
Reference in New Issue
Block a user