Add missing data for snapshot html plot
This commit is contained in:
parent
344a1558af
commit
60c875c2a5
1 changed files with 24 additions and 0 deletions
|
@ -231,6 +231,30 @@ class SnapshotUpdateView(NummiUpdateView):
|
||||||
data["transactions_url"] = reverse_lazy(
|
data["transactions_url"] = reverse_lazy(
|
||||||
"snapshot_transactions", args=(snapshot.pk,)
|
"snapshot_transactions", args=(snapshot.pk,)
|
||||||
)
|
)
|
||||||
|
if _transactions:
|
||||||
|
data["categories"] = (
|
||||||
|
_transactions.values(
|
||||||
|
"category", "category__name", "category__icon"
|
||||||
|
)
|
||||||
|
.annotate(
|
||||||
|
sum=models.Sum("value"),
|
||||||
|
sum_m=models.Sum("value", filter=models.Q(value__lt=0)),
|
||||||
|
sum_p=models.Sum("value", filter=models.Q(value__gt=0)),
|
||||||
|
)
|
||||||
|
.order_by("-sum")
|
||||||
|
)
|
||||||
|
data["cat_lim"] = max(
|
||||||
|
map(
|
||||||
|
lambda x: abs(x) if x else 0,
|
||||||
|
data["categories"]
|
||||||
|
.aggregate(
|
||||||
|
max=models.Max("sum_p"),
|
||||||
|
min=models.Min("sum_m"),
|
||||||
|
)
|
||||||
|
.values(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
data["cat_lim_m"] = -data["cat_lim"]
|
||||||
|
|
||||||
return data | {
|
return data | {
|
||||||
"new_transaction_url": reverse_lazy(
|
"new_transaction_url": reverse_lazy(
|
||||||
|
|
Loading…
Reference in a new issue