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

View file

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

View file

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

View file

@ -232,6 +232,20 @@ class ExpenseManageListView(CampViewMixin, EconomyTeamPermissionMixin, ListView)
model = Expense model = Expense
template_name = 'expense_manage_list.html' 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): class ExpenseManageDetailView(CampViewMixin, EconomyTeamPermissionMixin, UpdateView):
model = Expense model = Expense

View file

@ -22,6 +22,7 @@ Expenses | {{ block.super }}
<th>Description</th> <th>Description</th>
<th>Responsible Team</th> <th>Responsible Team</th>
<th>Approved</th> <th>Approved</th>
<th>Reimbursement?</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@ -33,6 +34,7 @@ Expenses | {{ block.super }}
<td>{{ expense.description }}</td> <td>{{ expense.description }}</td>
<td>{{ expense.responsible_team.name }} Team</td> <td>{{ expense.responsible_team.name }} Team</td>
<td>{{ expense.approval_status }}</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> <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> <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> </td>
@ -75,7 +77,17 @@ Expenses | {{ block.super }}
<td>{{ reim.notes|default:"N/A" }}</td> <td>{{ reim.notes|default:"N/A" }}</td>
<td>{{ reim.amount }} DKK</td> <td>{{ reim.amount }} DKK</td>
<td>{{ reim.paid }}</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> <td>
<a class="btn btn-primary" href="{% url "economy:reimbursement_detail" camp_slug=camp.slug pk=reim.pk %}">Details</a> <a class="btn btn-primary" href="{% url "economy:reimbursement_detail" camp_slug=camp.slug pk=reim.pk %}">Details</a>
</td> </td>

View file

@ -25,7 +25,11 @@
{% if not expense.paid_by_bornhack %} {% if not expense.paid_by_bornhack %}
<tr> <tr>
<th>Reimbursement?</th> <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> </tr>
{% endif %} {% endif %}
<tr> <tr>

View file

@ -19,8 +19,19 @@
<td>{{ reimbursement.created }}</td> <td>{{ reimbursement.created }}</td>
</tr> </tr>
<tr> <tr>
<th>Expenses</th> <th>Expenses covered by this Reimbursement</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> <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> </table>
</div> </div>
</div> </div>

View file

@ -6,5 +6,7 @@
{% include 'includes/reimbursement_detail_panel.html' %} {% 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 %} {% endblock content %}