mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-13 00:02:53 +02:00
feat: revamp Yearly Overview
This commit is contained in:
@@ -11,7 +11,7 @@ urlpatterns = [
|
|||||||
name="yearly_overview_currency",
|
name="yearly_overview_currency",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"yearly-overview/<int:year>/data/",
|
"yearly-overview/<int:year>/currency/data/",
|
||||||
views.yearly_overview_by_currency,
|
views.yearly_overview_by_currency,
|
||||||
name="yearly_overview_currency_data",
|
name="yearly_overview_currency_data",
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from apps.accounts.models import Account
|
|||||||
from apps.currencies.models import Currency
|
from apps.currencies.models import Currency
|
||||||
from apps.currencies.utils.convert import convert
|
from apps.currencies.utils.convert import convert
|
||||||
from apps.transactions.models import Transaction
|
from apps.transactions.models import Transaction
|
||||||
|
from apps.common.decorators.htmx import only_htmx
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@@ -35,7 +36,9 @@ def index_yearly_overview_by_currency(request, year: int):
|
|||||||
previous_year = year - 1
|
previous_year = year - 1
|
||||||
|
|
||||||
month_options = range(1, 13)
|
month_options = range(1, 13)
|
||||||
currency_options = Currency.objects.all()
|
currency_options = Currency.objects.filter(
|
||||||
|
accounts__transactions__date__year=year
|
||||||
|
).distinct()
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@@ -50,6 +53,7 @@ def index_yearly_overview_by_currency(request, year: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_htmx
|
||||||
@login_required
|
@login_required
|
||||||
def yearly_overview_by_currency(request, year: int):
|
def yearly_overview_by_currency(request, year: int):
|
||||||
month = request.GET.get("month")
|
month = request.GET.get("month")
|
||||||
@@ -196,8 +200,6 @@ def yearly_overview_by_currency(request, year: int):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
print(result)
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"yearly_overview/fragments/currency_data.html",
|
"yearly_overview/fragments/currency_data.html",
|
||||||
@@ -208,6 +210,32 @@ def yearly_overview_by_currency(request, year: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def index_yearly_overview_by_account(request, year: int):
|
||||||
|
next_year = year + 1
|
||||||
|
previous_year = year - 1
|
||||||
|
|
||||||
|
month_options = range(1, 13)
|
||||||
|
account_options = (
|
||||||
|
Account.objects.filter(is_archived=False, transactions__date__year=year)
|
||||||
|
.select_related("group")
|
||||||
|
.distinct()
|
||||||
|
)
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"yearly_overview/pages/overview_by_account.html",
|
||||||
|
context={
|
||||||
|
"year": year,
|
||||||
|
"next_year": next_year,
|
||||||
|
"previous_year": previous_year,
|
||||||
|
"months": month_options,
|
||||||
|
"accounts": account_options,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_htmx
|
||||||
@login_required
|
@login_required
|
||||||
def yearly_overview_by_account(request, year: int):
|
def yearly_overview_by_account(request, year: int):
|
||||||
month = request.GET.get("month")
|
month = request.GET.get("month")
|
||||||
@@ -420,7 +448,6 @@ def yearly_overview_by_account(request, year: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(converted_amount, Decimal):
|
if isinstance(converted_amount, Decimal):
|
||||||
print(converted_amount)
|
|
||||||
result[month][account_id][
|
result[month][account_id][
|
||||||
f"exchange_{field}"
|
f"exchange_{field}"
|
||||||
] = converted_amount
|
] = converted_amount
|
||||||
|
|||||||
@@ -161,6 +161,6 @@
|
|||||||
hx-swap="innerHTML">
|
hx-swap="innerHTML">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user