Retrieve user bills.
This commit is contained in:
parent
770c6c9c9b
commit
186d20ec20
|
@ -27,6 +27,7 @@ API_PATHS = {
|
|||
'saas-list': 'saas/',
|
||||
|
||||
# other
|
||||
'bill-list': 'bills/',
|
||||
'payment-source-list': 'payment-sources/',
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,25 @@ class OrchestraModel:
|
|||
return '%s object (%s)' % (self.__class__.__name__, self.id)
|
||||
|
||||
|
||||
class Bill(OrchestraModel):
|
||||
api_name = 'bill'
|
||||
param_defaults = {
|
||||
"number": "1",
|
||||
"type": "INVOICE",
|
||||
"total": 0.0,
|
||||
"is_sent": False,
|
||||
"created_on": "",
|
||||
"due_on": "",
|
||||
"comments": "",
|
||||
}
|
||||
|
||||
def pdf_url(self):
|
||||
# TODO (@slamora) create a view that exposes & downloads backend PDF
|
||||
import urllib.parse
|
||||
bill_url = self._json.get('url')
|
||||
return urllib.parse.urljoin(bill_url, 'document/')
|
||||
|
||||
|
||||
class BillingContact(OrchestraModel):
|
||||
param_defaults = {
|
||||
'name': None,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "musician/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load i18n l10n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
|||
<col span="1" style="width: 40%;">
|
||||
<col span="1" style="width: 10%;">
|
||||
<col span="1" style="width: 10%;">
|
||||
<col span="1" style="width: 10%;">
|
||||
</colgroup>
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
|
@ -21,7 +20,6 @@
|
|||
<th scope="col">Bill date</th>
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Total</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Download PDF</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -29,10 +27,9 @@
|
|||
{% for bill in object_list %}
|
||||
<tr>
|
||||
<th scope="row">{{ bill.number }}</th>
|
||||
<td>{{ bill.date|date:"SHORT_DATE_FORMAT" }}</td>
|
||||
<td>{{ bill.created_on }}</td>
|
||||
<td>{{ bill.type }}</td>
|
||||
<td>{{ bill.total_amount }}</td>
|
||||
<td class="font-weight-bold">{{ bill.status }}</td>
|
||||
<td>{{ bill.total|floatformat:2|localize }}€</td>
|
||||
<td><a class="text-dark" href="{{ bill.pdf_url }}" target="_blank" rel="noopener noreferrer"><i class="fas fa-file-pdf"></i></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -17,7 +17,7 @@ from .auth import logout as auth_logout
|
|||
from .forms import LoginForm
|
||||
from .mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||
UserTokenRequiredMixin)
|
||||
from .models import (DatabaseService, MailinglistService, MailService,
|
||||
from .models import (Bill, DatabaseService, MailinglistService, MailService,
|
||||
PaymentSource, SaasService, UserAccount)
|
||||
from .settings import ALLOWED_RESOURCES
|
||||
|
||||
|
@ -82,24 +82,6 @@ class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
class BillingView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequiredMixin, ListView):
|
||||
template_name = "musician/billing.html"
|
||||
|
||||
def get_queryset(self):
|
||||
# TODO (@slamora) retrieve user bills
|
||||
from django.utils import timezone
|
||||
return [
|
||||
{
|
||||
'number': 24,
|
||||
'date': timezone.now(),
|
||||
'type': 'subscription',
|
||||
'total_amount': '25,00 €',
|
||||
'status': 'paid',
|
||||
'pdf_url': 'https://example.org/bill.pdf'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class ProfileView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||
template_name = "musician/profile.html"
|
||||
|
||||
|
@ -146,6 +128,11 @@ class ServiceListView(CustomContextMixin, ExtendedPaginationMixin, UserTokenRequ
|
|||
return context
|
||||
|
||||
|
||||
class BillingView(ServiceListView):
|
||||
service_class = Bill
|
||||
template_name = "musician/billing.html"
|
||||
|
||||
|
||||
class MailView(ServiceListView):
|
||||
service_class = MailService
|
||||
template_name = "musician/mail.html"
|
||||
|
|
Loading…
Reference in a new issue