parent
278d252cfd
commit
574d1d2875
3 changed files with 36 additions and 7 deletions
|
@ -58,5 +58,30 @@
|
|||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
</tbody>
|
||||
{% if categories %}
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="row" colspan="2" class="l">{% translate "Total" %}</th>
|
||||
<td class="value">{{ total_m|pmrvalue }}</td>
|
||||
<td class="bar m">
|
||||
<div style="width: {% widthratio total_m max -100 %}%"></div>
|
||||
{% if total < 0 %}
|
||||
<div class="tot" style="width:{% widthratio total max -100 %}%">
|
||||
<span>{{ total|pmrvalue }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="bar p">
|
||||
<div style="width: {% widthratio total_p max 100 %}%"></div>
|
||||
{% if total > 0 %}
|
||||
<div class="tot" style="width:{% widthratio total max 100 %}%">
|
||||
<span>{{ total|pmrvalue }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="value">{{ total_p|pmrvalue }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django import template
|
||||
from django.db import models
|
||||
from django.db.models.functions import Greatest
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -18,10 +19,9 @@ def category_plot(transactions):
|
|||
)
|
||||
return {
|
||||
"categories": categories,
|
||||
"max": max(
|
||||
categories.aggregate(
|
||||
max=models.Max("sum_p", default=0),
|
||||
min=models.Min("sum_m", default=0),
|
||||
).values(),
|
||||
),
|
||||
}
|
||||
} | categories.aggregate(
|
||||
max=Greatest(models.Sum("sum_m"), models.Sum("sum_p")),
|
||||
total_m=models.Sum("sum_m"),
|
||||
total_p=models.Sum("sum_p"),
|
||||
total=models.Sum("value"),
|
||||
)
|
||||
|
|
|
@ -70,3 +70,7 @@ table.full-width col.bar {
|
|||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.plot tfoot {
|
||||
background: var(--bg-01);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue