mirror of
https://github.com/peter-tanner/money-manager.git
synced 2024-11-30 14:20:17 +08:00
fix graphs: grouping and ignore deleted expenses
This commit is contained in:
parent
0a28f2f27d
commit
33c3e42864
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
etc/
|
||||
test.py
|
||||
localhost_config.py
|
||||
static/
|
||||
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
|
|
|
@ -14,9 +14,10 @@ Including another URLconf
|
|||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
from expenses.models import Expense, Timesheet
|
||||
|
||||
|
||||
|
@ -25,6 +26,8 @@ urlpatterns = [
|
|||
path("admin/summary/", include("summary.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
]
|
||||
if not settings.DEBUG:
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
|
||||
admin.site.site_header = "Yet another money manager"
|
||||
admin.site.index_title = f"Handling {Expense.objects.all().count() + Timesheet.objects.all().count()} documents..."
|
||||
|
|
|
@ -114,7 +114,7 @@ class TimesheetAdmin(AdminBase, AdminChartMixin, ImportExportModelAdmin):
|
|||
earliest = min([x.shift_start for x in queryset]).replace(day=1)
|
||||
|
||||
expenses_in_range = Expense.objects.filter(
|
||||
date__range=[earliest, timezone.now()]
|
||||
date__range=[earliest, timezone.now()], deleted=False
|
||||
)
|
||||
|
||||
labels = []
|
||||
|
@ -200,7 +200,7 @@ class ExpenseAdmin(AdminBase, AdminChartMixin, ImportExportModelAdmin):
|
|||
expenses = {
|
||||
k: {
|
||||
"label": k,
|
||||
"data": [0],
|
||||
"data": [],
|
||||
"backgroundColor": f"#{random.Random(x=1).randrange(0x1000000):06x}",
|
||||
}
|
||||
for k in set([x.category.name for x in queryset])
|
||||
|
@ -218,6 +218,8 @@ class ExpenseAdmin(AdminBase, AdminChartMixin, ImportExportModelAdmin):
|
|||
)
|
||||
)
|
||||
expenses_total.append(0)
|
||||
for k in expenses.keys():
|
||||
expenses[k]["data"].append(0)
|
||||
for x in queryset:
|
||||
if x.date.year == b.year and x.date.month == b.month:
|
||||
expenses_total[-1] += convert_money(x.price, "AUD").amount
|
||||
|
@ -225,7 +227,6 @@ class ExpenseAdmin(AdminBase, AdminChartMixin, ImportExportModelAdmin):
|
|||
x.price, "AUD"
|
||||
).amount
|
||||
|
||||
print(list(expenses))
|
||||
return {
|
||||
"labels": labels,
|
||||
"datasets": [
|
||||
|
|
4
run-local.sh
Executable file
4
run-local.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
source ../.venv/bin/activate
|
||||
python3 manage.py runserver --settings=localhost_config --insecure # Use internal static server
|
Loading…
Reference in New Issue
Block a user