Attempt period from line_items
This commit is contained in:
parent
77669c962c
commit
a3a2016cb4
2 changed files with 14 additions and 9 deletions
|
@ -30,7 +30,9 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="xs-td-inline" data-header="{% trans 'VM ID' %}">{{ invoice.order.vm_id }}</td>
|
<td class="xs-td-inline" data-header="{% trans 'VM ID' %}">{{ invoice.order.vm_id }}</td>
|
||||||
<td class="xs-td-inline" data-header="{% trans 'IP Address' %}">{{ ips|get_value_from_dict:invoice.invoice_number|join:"<br/>" }}</td>
|
<td class="xs-td-inline" data-header="{% trans 'IP Address' %}">{{ ips|get_value_from_dict:invoice.invoice_number|join:"<br/>" }}</td>
|
||||||
<td class="xs-td-inline" data-header="{% trans 'Period' %}">{{ invoice.period_start | date:'Y-m-d' }} — {{ invoice.period_end | date:'Y-m-d' }}</td>
|
{% with line_items|get_value_from_dict:invoice.invoice_number as line_items_to_show %}
|
||||||
|
<td class="xs-td-inline" data-header="{% trans 'Period' %}">{{ line_items_to_show.period_start | date:'Y-m-d' }} — {{ line_items_to_show.period_end | date:'Y-m-d' }}</td>
|
||||||
|
{% endwith %}
|
||||||
<td class="xs-td-inline" data-header="{% trans 'Amount' %}">{{ invoice.total_in_chf|floatformat:2|intcomma }}</td>
|
<td class="xs-td-inline" data-header="{% trans 'Amount' %}">{{ invoice.total_in_chf|floatformat:2|intcomma }}</td>
|
||||||
<td class="text-right last-td">
|
<td class="text-right last-td">
|
||||||
<a class="btn btn-order-detail" href="{% url 'hosting:invoices' invoice.invoice_number %}">{% trans 'See Invoice' %}</a>
|
<a class="btn btn-order-detail" href="{% url 'hosting:invoices' invoice.invoice_number %}">{% trans 'See Invoice' %}</a>
|
||||||
|
|
|
@ -61,7 +61,7 @@ from .forms import (
|
||||||
from .mixins import ProcessVMSelectionMixin, HostingContextMixin
|
from .mixins import ProcessVMSelectionMixin, HostingContextMixin
|
||||||
from .models import (
|
from .models import (
|
||||||
HostingOrder, HostingBill, HostingPlan, UserHostingKey, VMDetail,
|
HostingOrder, HostingBill, HostingPlan, UserHostingKey, VMDetail,
|
||||||
GenericProduct, MonthlyHostingBill
|
GenericProduct, MonthlyHostingBill, HostingBillLineItem
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -1179,21 +1179,24 @@ class InvoiceListView(LoginRequiredMixin, ListView):
|
||||||
except CustomUser.DoesNotExist as dne:
|
except CustomUser.DoesNotExist as dne:
|
||||||
logger.debug("User does not exist")
|
logger.debug("User does not exist")
|
||||||
cu = self.request.user
|
cu = self.request.user
|
||||||
mabs = MonthlyHostingBill.objects.filter(customer__user=cu)
|
mhbs = MonthlyHostingBill.objects.filter(customer__user=cu)
|
||||||
else:
|
else:
|
||||||
mabs = MonthlyHostingBill.objects.filter(
|
mhbs = MonthlyHostingBill.objects.filter(
|
||||||
customer__user=self.request.user
|
customer__user=self.request.user
|
||||||
)
|
)
|
||||||
ips_dict = {}
|
ips_dict = {}
|
||||||
for mab in mabs:
|
line_items_dict = {}
|
||||||
|
for mhb in mhbs:
|
||||||
try:
|
try:
|
||||||
vm_detail = VMDetail.objects.get(vm_id=mab.order.vm_id)
|
vm_detail = VMDetail.objects.get(vm_id=mhb.order.vm_id)
|
||||||
ips_dict[mab.invoice_number] = [vm_detail.ipv6, vm_detail.ipv4]
|
ips_dict[mhb.invoice_number] = [vm_detail.ipv6, vm_detail.ipv4]
|
||||||
|
line_items_dict[mhb.invoice_number] = HostingBillLineItem.objects.filter(monthly_hosting_bill=mhb)
|
||||||
except VMDetail.DoesNotExist as dne:
|
except VMDetail.DoesNotExist as dne:
|
||||||
ips_dict[mab.invoice_number] = ['--']
|
ips_dict[mhb.invoice_number] = ['--']
|
||||||
logger.debug("VMDetail for {} doesn't exist".format(
|
logger.debug("VMDetail for {} doesn't exist".format(
|
||||||
mab.order.vm_id
|
mhb.order.vm_id
|
||||||
))
|
))
|
||||||
|
context['line_items'] = line_items_dict
|
||||||
context['ips'] = ips_dict
|
context['ips'] = ips_dict
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue