Cross-reference reimbursement claims on budget page

This commit is contained in:
Yingtong Li 2020-05-13 10:52:31 +10:00
parent 435aa15d17
commit 787b16733d
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 43 additions and 1 deletions

View File

@ -222,6 +222,41 @@
{% endif %}
{% endfor %}
</div>
{% if claims is not none %}
<h2>Reimbursement claims</h2>
{% if claims %}
<table class="ui celled table">
<thead>
<tr>
<th class="nine wide">Purpose</th>
<th class="four wide">Status</th>
<th class="two wide">Total</th>
<th class="one wide">View</th>
</tr>
</thead>
<tbody>
{% for claim in claims %}
<tr>
<td>{{ claim.purpose }}</td>
<td>{{ claim.get_state_display() }}</td>
<td>{{ '${:.2f}'.format(claim.get_total()) }}</td>
<td>
<a href="{{ url('claim_view', kwargs={'id': claim.id}) }}" class="ui tiny primary icon button"><i class="eye icon"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="ui warning message">
<p>This list will not include invoices, or other transactions tracked outside of Self Service.</p>
</div>
{% else %}
<p>There are no claims to display.</p>
{% endif %}
{% endif %}
{% endif %}
<div class="ui modal">

View File

@ -21,6 +21,7 @@ from django.core.validators import validate_email
from django.conf import settings
from django.db import transaction
from django.db.models import Q
from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.urls import reverse
@ -251,10 +252,16 @@ def budget_view(request, budget, revision):
history = list(itertools.chain(budget.budgetrevision_set.all(), revision.budget.budgetcomment_set.all()))
history.sort(key=lambda x: x.time, reverse=True)
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()
else:
claims = None
return render(request, 'sstreasury/budget_view.html', {
'revision': revision,
'history': history,
'is_latest': 'revision' not in request.GET
'is_latest': 'revision' not in request.GET,
'claims': claims
})
@login_required