mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-03-18 07:24:00 +01:00
fix: wrong calculations
This commit is contained in:
@@ -15,8 +15,10 @@ from apps.transactions.utils.calculations import (
|
||||
|
||||
|
||||
def net_worth_main(request):
|
||||
transactions_queryset = Transaction.objects.filter(is_paid=True).order_by(
|
||||
"account__group",
|
||||
transactions_queryset = Transaction.objects.filter(
|
||||
is_paid=True, account__is_archived=False
|
||||
).order_by(
|
||||
"account__group__name",
|
||||
"account__name",
|
||||
)
|
||||
currency_net_worth = calculate_currency_totals(
|
||||
|
||||
@@ -155,6 +155,7 @@ def calculate_account_totals(transactions_queryset, ignore_empty=False):
|
||||
"account__is_asset",
|
||||
"account__is_archived",
|
||||
"account__group__name",
|
||||
"account__group__id",
|
||||
"account__currency__id",
|
||||
"account__currency__code",
|
||||
"account__currency__name",
|
||||
@@ -162,6 +163,7 @@ def calculate_account_totals(transactions_queryset, ignore_empty=False):
|
||||
"account__currency__prefix",
|
||||
"account__currency__suffix",
|
||||
"account__exchange_currency",
|
||||
"id",
|
||||
).annotate(
|
||||
expense_current=Coalesce(
|
||||
Sum(
|
||||
@@ -239,6 +241,7 @@ def calculate_account_totals(transactions_queryset, ignore_empty=False):
|
||||
"is_asset": total["account__is_asset"],
|
||||
"is_archived": total["account__is_archived"],
|
||||
"group": total["account__group__name"],
|
||||
"group_id": total["account__group__id"],
|
||||
},
|
||||
"currency": {
|
||||
"code": total["account__currency__code"],
|
||||
|
||||
@@ -72,8 +72,10 @@ def yearly_overview_by_currency(request, year: int):
|
||||
if currency:
|
||||
filter_params["account__currency_id"] = int(currency)
|
||||
|
||||
transactions = Transaction.objects.filter(**filter_params).exclude(
|
||||
Q(category__mute=True) & ~Q(category=None)
|
||||
transactions = (
|
||||
Transaction.objects.filter(**filter_params)
|
||||
.exclude(Q(category__mute=True) & ~Q(category=None))
|
||||
.order_by("account__group__name", "account__name")
|
||||
)
|
||||
|
||||
data = calculate_currency_totals(transactions)
|
||||
@@ -144,8 +146,8 @@ def yearly_overview_by_account(request, year: int):
|
||||
if account:
|
||||
filter_params["account_id"] = int(account)
|
||||
|
||||
transactions = Transaction.objects.filter(**filter_params).order_by(
|
||||
"account__group__name", "account__name", "id"
|
||||
transactions = Transaction.objects.filter(**filter_params).exclude(
|
||||
Q(category__mute=True) & ~Q(category=None)
|
||||
)
|
||||
|
||||
data = calculate_account_totals(transactions)
|
||||
|
||||
Reference in New Issue
Block a user