summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-05-13 10:52:31 +1000
committerYingtong Li <runassudo@yingtongli.me>2020-05-13 10:58:57 +1000
commit787b16733dc4df1a8078bd4f0413a6fece68b9ed (patch)
tree330700bda410cf2117a6f5ea52d1028dc681fd84
parent435aa15d17c27f6a71743123a5d4337c66b8cadf (diff)
Cross-reference reimbursement claims on budget page
-rw-r--r--sstreasury/jinja2/sstreasury/budget_view.html35
-rw-r--r--sstreasury/views.py9
2 files changed, 43 insertions, 1 deletions
diff --git a/sstreasury/jinja2/sstreasury/budget_view.html b/sstreasury/jinja2/sstreasury/budget_view.html
index 707f834..d4d37ea 100644
--- a/sstreasury/jinja2/sstreasury/budget_view.html
+++ b/sstreasury/jinja2/sstreasury/budget_view.html
@@ -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">
diff --git a/sstreasury/views.py b/sstreasury/views.py
index 9b1da59..689a451 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -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
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.