Invoice display in client dashboard

This commit is contained in:
Kumi 2021-04-20 10:00:24 +02:00
parent 574f34e556
commit 570810105e
3 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,4 @@
from django.views.generic import CreateView, UpdateView, TemplateView, ListView
from django.views.generic import CreateView, UpdateView, TemplateView, ListView, DetailView
from django.urls import reverse_lazy
from django.shortcuts import redirect
from django.contrib import messages
@ -71,9 +71,13 @@ class ClientProfileView(InConstructionMixin, LoginRequiredMixin, UpdateView):
except ClientProfile.DoesNotExist:
return redirect("clients:register")
class ClientDashboardView(InConstructionMixin, LoginRequiredMixin, TemplateView):
class ClientDashboardView(InConstructionMixin, ClientProfileRequiredMixin, DetailView):
model = ClientProfile
template_name = "clients/dashboard.html"
def get_object(self):
return self.request.user.clientprofile
class ClientBookingsView(InConstructionMixin, ClientProfileRequiredMixin, ListView):
model = Inquiry
template_name = "clients/bookings.html"

View file

@ -52,6 +52,7 @@ class Invoice(models.Model):
tax_rate = models.DecimalField(max_digits=4, decimal_places=2)
invoice = models.FileField(null=True, blank=True, upload_to=invoice_upload_path)
inquiry = models.OneToOneField(Inquiry, null=True, blank=True, on_delete=models.SET_NULL)
created = models.DateTimeField(auto_now_add=True)
@property
def price_net(self):

View file

@ -82,18 +82,22 @@
<div class="table-responsive">
<table class="table table-hover">
<tbody>
{% for invoice in object.user.invoice_set.all %}
{% if invoice.inquiry %}
<tr>
<td class="dash-list-icon invoice-icon"><i class="fa fa-bars"></i></td>
<td class="dash-list-text invoice-text">
<h4 class="invoice-title">Reiseanfrage</h4>
<ul class="list-unstyled list-inline invoice-info">
<li class="list-inline-item invoice-status green">Bezahlt</li>
<li class="list-inline-item invoice-order"> Anfrage: #00214</li>
<li class="list-inline-item invoice-date"> Erstellt: 25.03.2021</li>
<li class="list-inline-item invoice-status {% if invoice.is_paid %}green{% else %}red{% endif %}">{% if invoice.is_paid %}Bezahlt{% else %}Unbezahlt{% endif %}</li>
<li class="list-inline-item invoice-order"> Anfrage: #{{ invoice.inquiry.id }}</li>
<li class="list-inline-item invoice-date"> Erstellt: {{ invoice.created|date:"d.m.Y" }}</li>
</ul>
</td>
<td class="dash-list-btn"><button class="btn btn-orange">Rechnung anzeigen</button></td>
<td class="dash-list-btn"><a href="{{ invoice.invoice.url }}" class="btn btn-orange">Rechnung anzeigen</a></td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div><!-- end table-responsive -->