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