Display total reimbursement amount per budget

This commit is contained in:
Yingtong Li 2023-04-30 21:28:26 +10:00
parent 9c0d7122f6
commit faa81ca803
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 11 additions and 2 deletions

View File

@ -252,6 +252,11 @@
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
<tr>
<td style="font-weight:bold" colspan="2">Total paid:</td>
<td style="font-weight:bold">{{ '${:.2f}'.format(claims_total_paid) }}</td>
<td></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,5 +1,6 @@
# Society Self-Service # Society Self-Service
# Copyright © 2018–2021 Yingtong Li (RunasSudo) # Copyright © 2018–2023 Yingtong Li (RunasSudo)
# Copyright © 2023 MUMUS Inc.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -258,14 +259,17 @@ def budget_view(request, budget, revision):
if revision.state == models.BudgetState.APPROVED.value and 'revision' not in request.GET: if revision.state == models.BudgetState.APPROVED.value and 'revision' not in request.GET:
claims = models.ReimbursementClaim.objects.filter(Q(budget_id=str(budget.id)) | Q(budget_id__endswith='-{}'.format(budget.id))).all() claims = models.ReimbursementClaim.objects.filter(Q(budget_id=str(budget.id)) | Q(budget_id__endswith='-{}'.format(budget.id))).all()
claims_total_paid = sum(c.get_total() for c in claims if c.state == models.ClaimState.PAID.value)
else: else:
claims = None claims = None
claims_total_paid = 0
return render(request, 'sstreasury/budget_view.html', { return render(request, 'sstreasury/budget_view.html', {
'revision': revision, 'revision': revision,
'history': history, 'history': history,
'is_latest': 'revision' not in request.GET, 'is_latest': 'revision' not in request.GET,
'claims': claims 'claims': claims,
'claims_total_paid': claims_total_paid
}) })
@login_required @login_required