show unapproved expenses seperately in backoffice, crosslink expenses and reimbursements in list and detailviews on main page and in backoffice

This commit is contained in:
Thomas Steen Rasmussen 2018-08-30 19:32:23 +02:00
parent 698beaaffd
commit ac54e4cb16
8 changed files with 121 additions and 41 deletions

View file

@ -7,43 +7,80 @@
{% endblock extra_head %}
{% block content %}
<div class="row">
<h2>Expenses for {{ camp.title }}</h2>
<div class="lead">
This page shows all expenses for {{ camp.title }}.
</div>
<h2>Manage Expenses for {{ camp.title }}</h2>
{% if unapproved_expenses %}
<div class="lead">
This table shows unapproved expenses for {{ camp.title }}.
</div>
<table class="table table-hover">
<thead>
<tr>
<th>User</th>
<th>Description</th>
<th>Amount</th>
<th>Paid by</th>
<th>Approved?</th>
<th>Reimbursement?</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for expense in unapproved_expenses %}
<tr>
<td>{{ expense.user }}</td>
<td>{{ expense.description }}</td>
<td>{{ expense.amount }} DKK</td>
<td>{% if expense.paid_by_bornhack %}BornHack{% else %}{{ expense.user }}{% endif %}</td>
<td>{{ expense.approval_status }}</td>
<td>{% if expense.reimbursement %}<a href="{% url 'backoffice:reimbursement_detail' camp_slug=camp.slug pk=expense.reimbursement.pk %}" class="btn btn-primary">Details</a>{% else %}N/A{% endif %}</td>
<td>
<a class="btn btn-primary" href="{% url "backoffice:expense_detail" camp_slug=camp.slug pk=expense.pk %}">Details</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<hr>
<div class="lead">
This table shows all expenses for {{ camp.title }}.
</div>
<br>
<div class="row">
<table class="table table-hover">
<thead>
<tr>
<th>User</th>
<th>Description</th>
<th>Amount</th>
<th>Paid by</th>
<th>Approved?</th>
<th>Reimbursement?</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for expense in expense_list %}
<tr>
<td>{{ expense.user }}</td>
<td>{{ expense.description }}</td>
<td>{{ expense.amount }} DKK</td>
<td>{% if expense.paid_by_bornhack %}BornHack{% else %}{{ expense.user }}{% endif %}</td>
<td>{{ expense.approval_status }}</td>
<td>{{ expense.reimbursement.pk }}</td>
<td>
<a class="btn btn-primary" href="{% url "backoffice:expense_manage_detail" camp_slug=camp.slug pk=expense.pk %}">Details</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>User</th>
<th>Description</th>
<th>Amount</th>
<th>Paid by</th>
<th>Approved?</th>
<th>Reimbursement?</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for expense in expense_list %}
<tr>
<td>{{ expense.user }}</td>
<td>{{ expense.description }}</td>
<td>{{ expense.amount }} DKK</td>
<td>{% if expense.paid_by_bornhack %}BornHack{% else %}{{ expense.user }}{% endif %}</td>
<td>{{ expense.approval_status }}</td>
<td>{% if expense.reimbursement %}<a href="{% url 'backoffice:reimbursement_detail' camp_slug=camp.slug pk=expense.reimbursement.pk %}" class="btn btn-primary">Details</a>{% else %}N/A{% endif %}</td>
<td>
<a class="btn btn-primary" href="{% url "backoffice:expense_detail" camp_slug=camp.slug pk=expense.pk %}">Details</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
$(document).ready(function(){

View file

@ -2,7 +2,7 @@
{% load bootstrap3 %}
{% block content %}
<h3>Reimbursement Details</h3>
<h3>Manage Reimbursement</h3>
{% include 'includes/reimbursement_detail_panel.html' %}

View file

@ -20,7 +20,7 @@ urlpatterns = [
path('village_orders/', VillageOrdersView.as_view(), name='village_orders'),
path('village_to_order/', VillageToOrderView.as_view(), name='village_to_order'),
path('economy/expenses/', ExpenseManageListView.as_view(), name='expense_manage_list'),
path('economy/expenses/<uuid:pk>/', ExpenseManageDetailView.as_view(), name='expense_manage_detail'),
path('economy/expenses/<uuid:pk>/', ExpenseManageDetailView.as_view(), name='expense_detail'),
path('economy/reimbursements/', ReimbursementListView.as_view(), name='reimbursement_list'),
path('economy/reimbursements/<uuid:pk>/', ReimbursementDetailView.as_view(), name='reimbursement_detail'),
path('economy/reimbursements/create/', ReimbursementCreateUserSelectView.as_view(), name='reimbursement_create_userselect'),

View file

@ -232,6 +232,20 @@ class ExpenseManageListView(CampViewMixin, EconomyTeamPermissionMixin, ListView)
model = Expense
template_name = 'expense_manage_list.html'
def get_queryset(self, **kwargs):
"""
Exclude unapproved expenses
"""
queryset = super().get_queryset(**kwargs)
return queryset.exclude(approved__isnull=True)
def get_context_data(self, **kwargs):
"""
Include unapproved expenses seperately
"""
context = super().get_context_data(**kwargs)
context['unapproved_expenses'] = Expense.objects.filter(camp=self.camp, approved__isnull=True)
return context
class ExpenseManageDetailView(CampViewMixin, EconomyTeamPermissionMixin, UpdateView):
model = Expense

View file

@ -22,6 +22,7 @@ Expenses | {{ block.super }}
<th>Description</th>
<th>Responsible Team</th>
<th>Approved</th>
<th>Reimbursement?</th>
<th>Actions</th>
</tr>
</thead>
@ -33,6 +34,7 @@ Expenses | {{ block.super }}
<td>{{ expense.description }}</td>
<td>{{ expense.responsible_team.name }} Team</td>
<td>{{ expense.approval_status }}</td>
<td>{% if expense.reimbursement %}<a href="{% url 'economy:reimbursement_detail' camp_slug=camp.slug pk=expense.reimbursement.pk %}" class="btn btn-primary">Details</a>{% else %}N/A{% endif %}</td>
<td>
<a class="btn btn-primary" href="{% url 'economy:expense_detail' camp_slug=camp.slug pk=expense.uuid %}"><i class="fas fa-search"></i> Details</a>
</td>
@ -75,7 +77,17 @@ Expenses | {{ block.super }}
<td>{{ reim.notes|default:"N/A" }}</td>
<td>{{ reim.amount }} DKK</td>
<td>{{ reim.paid }}</td>
<td>{% for expense in reim.expenses.all %}{{ expense.pk }}<br>{% endfor %}</td>
<td>
{% for expense in reim.expenses.all %}
{% if not expense.paid_by_bornhack %}
{% if request.resolver_match.app_name == "backoffice" %}
<a href="{% url 'backoffice:expense_detail' camp_slug=camp.slug pk=expense.pk %}" class="btn btn-primary">Details</a> {{ expense.amount }} DKK - {{ expense.description }}<br>
{% else %}
<a href="{% url 'economy:expense_detail' camp_slug=camp.slug pk=expense.pk %}" class="btn btn-primary">Details</a> {{ expense.amount }} DKK - {{ expense.description }}<br>
{% endif %}
{% endif %}
{% endfor %}
</td>
<td>
<a class="btn btn-primary" href="{% url "economy:reimbursement_detail" camp_slug=camp.slug pk=reim.pk %}">Details</a>
</td>

View file

@ -25,7 +25,11 @@
{% if not expense.paid_by_bornhack %}
<tr>
<th>Reimbursement?</th>
<td>{% if expense.reimbursement %}<a class="btn btn-primary" href="{% url 'economy:reimbursement_detail' camp_slug=camp.slug %}">{{ expense.reimbursement.pk }}</a>{% else %}N/A{% endif %}</td>
{% if request.resolver_match.app_name == "backoffice" %}
<td>{% if expense.reimbursement %}<a class="btn btn-primary" href="{% url 'backoffice:reimbursement_detail' camp_slug=camp.slug pk=expense.reimbursement.pk %}">{{ expense.reimbursement.pk }}</a>{% else %}N/A{% endif %}</td>
{% else %}
<td>{% if expense.reimbursement %}<a class="btn btn-primary" href="{% url 'economy:reimbursement_detail' camp_slug=camp.slug pk=expense.reimbursement.pk %}">{{ expense.reimbursement.pk }}</a>{% else %}N/A{% endif %}</td>
{% endif %}
</tr>
{% endif %}
<tr>

View file

@ -19,8 +19,19 @@
<td>{{ reimbursement.created }}</td>
</tr>
<tr>
<th>Expenses</th>
<td>{% for expense in reimbursement.expenses.all %}{% if not expense.paid_by_bornhack %}{{ expense.pk }} - {{ expense.amount }} DKK - {{ expense.description }}<br>{% endif %}{% endfor %}</td>
<th>Expenses covered by this Reimbursement</th>
<td>
{% for expense in reimbursement.expenses.all %}
{% if not expense.paid_by_bornhack %}
{% if request.resolver_match.app_name == "backoffice" %}
<a href="{% url 'backoffice:expense_detail' camp_slug=camp.slug pk=expense.pk %}" class="btn btn-primary">{{ expense.pk }}</a> {{ expense.amount }} DKK - {{ expense.description }}<br>
{% else %}
<a href="{% url 'economy:expense_detail' camp_slug=camp.slug pk=expense.pk %}" class="btn btn-primary">{{ expense.pk }}</a> {{ expense.amount }} DKK - {{ expense.description }}<br>
{% endif %}
{% endif %}
{% endfor %}
</td>
</tr>
</table>
</div>
</div>

View file

@ -6,5 +6,7 @@
{% include 'includes/reimbursement_detail_panel.html' %}
<a href="{% url 'economy:expense_list' camp_slug=camp.slug %}" class="btn btn-primary">Back to list</a>
{% endblock content %}