diff --git a/hosting/models.py b/hosting/models.py
index 7b7a7792..0d42996e 100644
--- a/hosting/models.py
+++ b/hosting/models.py
@@ -521,6 +521,7 @@ class HostingBillLineItem(AssignPermissionsMixin, models.Model):
)
return item_detail
+
class VMDetail(models.Model):
user = models.ForeignKey(CustomUser)
vm_id = models.IntegerField(default=0)
diff --git a/hosting/templates/hosting/invoices.html b/hosting/templates/hosting/invoices.html
index f2486111..c0956a58 100644
--- a/hosting/templates/hosting/invoices.html
+++ b/hosting/templates/hosting/invoices.html
@@ -31,7 +31,7 @@
{{ invoice.order.vm_id }} |
{{ ips|get_value_from_dict:invoice.invoice_number|join:" " }} |
{% with line_items|get_value_from_dict:invoice.invoice_number as line_items_to_show %}
- {{ line_items_to_show.0.period_start | date:'Y-m-d' }} — {{ line_items_to_show.0.period_end | date:'Y-m-d' }} |
+ {{ period_start | date:'Y-m-d' }} — {{ period_end | date:'Y-m-d' }} |
{% endwith %}
{{ invoice.total_in_chf|floatformat:2|intcomma }} |
diff --git a/hosting/views.py b/hosting/views.py
index 2d7a3093..901dae20 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -1190,7 +1190,13 @@ class InvoiceListView(LoginRequiredMixin, ListView):
try:
vm_detail = VMDetail.objects.get(vm_id=mhb.order.vm_id)
ips_dict[mhb.invoice_number] = [vm_detail.ipv6, vm_detail.ipv4]
- line_items_dict[mhb.invoice_number] = HostingBillLineItem.objects.filter(monthly_hosting_bill=mhb)
+ all_line_items = HostingBillLineItem.objects.filter(monthly_hosting_bill=mhb)
+ for line_item in all_line_items:
+ if line_item.get_item_detail_str() != "":
+ context['period_start'] = line_item.period_start
+ context['period_end'] = line_item.period_end
+ break
+ line_items_dict[mhb.invoice_number] = all_line_items
except VMDetail.DoesNotExist as dne:
ips_dict[mhb.invoice_number] = ['--']
logger.debug("VMDetail for {} doesn't exist".format(
|