Attempt to show relevant lines when we have more than 1 line item
This commit is contained in:
parent
3fbc4528d9
commit
e782d27739
2 changed files with 81 additions and 68 deletions
|
@ -89,6 +89,15 @@
|
||||||
<div>
|
<div>
|
||||||
<h4>{% trans "Invoice summary" %}</h4>
|
<h4>{% trans "Invoice summary" %}</h4>
|
||||||
{% if vm %}
|
{% if vm %}
|
||||||
|
{% if line_items %}
|
||||||
|
<table>
|
||||||
|
<tr><th>Product</th><th>Period</th><th>Quantity</th><th>Unit Price</th><th>Total</th></tr>
|
||||||
|
{% for line_item in line_items %}
|
||||||
|
<tr><td>{% if line_item.description|len > 0 %}{{line_item.description}}{% else %}{{line_item.stripe_plan.stripe_plan_id}}{% endif %}</td><td>{{ line_item.period_start | date:'Y-m-d' }} — {{ line_item.period_end | date:'Y-m-d' }}</td><td>{{line_item.quantity}}</td><td>{{line_item.unit_amount}}</td><td>{{line_item.amount}}</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
<tr><td colspan="4">Grand Total</td><td>{{total_in_chf}}</td></tr>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
<strong>{% trans "Product" %}:</strong>
|
<strong>{% trans "Product" %}:</strong>
|
||||||
{% if vm.name %}
|
{% if vm.name %}
|
||||||
|
@ -163,6 +172,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
<strong>{% trans "Product" %}:</strong>
|
<strong>{% trans "Product" %}:</strong>
|
||||||
|
|
|
@ -1322,6 +1322,9 @@ class InvoiceDetailView(LoginRequiredMixin, DetailView):
|
||||||
context['total_in_chf'] = obj.total_in_chf()
|
context['total_in_chf'] = obj.total_in_chf()
|
||||||
context['invoice_number'] = obj.invoice_number
|
context['invoice_number'] = obj.invoice_number
|
||||||
context['discount_on_stripe'] = obj.discount_in_chf()
|
context['discount_on_stripe'] = obj.discount_in_chf()
|
||||||
|
if obj.lines_data_count > 1:
|
||||||
|
# special case, we pass the details of each of the line items
|
||||||
|
context['line_items'] = obj.hostingbilllineitem_set.all()
|
||||||
return context
|
return context
|
||||||
else:
|
else:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
Loading…
Reference in a new issue