Invoice Help

Solved
AmyEmms
New Member
3 0 0

Hi

I'm trying to tidy up my invoice, but I've got a little stuck. The code below gives me a table with a subtotal, discount and total.

Screen Shot 2021-02-24 at 12.20.18.png

 

When there isn't a discount, the table goes all out of whack! What do I do to the code?

Screen Shot 2021-02-24 at 12.23.51.png

 

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<tr> {% if discounts_savings != 0 %}
<td>Sub Total</td>
<td>{% for discount in discounts %}{{ discount.savings | times: -1 | plus: subtotal_price | money }}{% endfor %}</td>
{% else %}
<td>{{ subtotal_price | money }}</td>
{% endif %}
{% for discount in discounts %}
<tr>
<td>Includes discount "{{ discount.code }}"</td>
<td>{{ discount.savings | money }}</td>
</tr>
{% endfor %}
<tr>
<td><strong>Total price:</strong></td>
<td><strong>{{ total_price | money }}</strong></td>
</tr>
{% if total_paid != total_price %}
<tr>
<td><strong>Total paid:</strong></td>
<td><strong>{{ total_paid | money }}</strong></td>
</tr>
<tr>
<td><strong>Outstanding Amount:</strong></td>
<td><strong>{{ total_price | minus: total_paid | money }}</strong></td>
</tr>
{% endif %}
</table>

0 Likes
peterloane
Excursionist
31 4 11

This is an accepted solution.

Hi 

See if this helps

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<tr> {% if discounts_savings != 0 %}
<td>Sub Total</td>
<td>{% for discount in discounts %}{{ discount.savings | times: -1 | plus: subtotal_price | money }}{% endfor %}</td>
{% else %}
<td>Sub Total</td>
<td>{{ subtotal_price | money }}</td>
{% endif %}
{% for discount in discounts %}
<tr>
<td>Includes discount "{{ discount.code }}"</td>
<td>{{ discount.savings | money }}</td>
</tr>
{% endfor %}
<tr>
<td><strong>Total price:</strong></td>
<td><strong>{{ total_price | money }}</strong></td>
</tr>
{% if total_paid != total_price %}
<tr>
<td><strong>Total paid:</strong></td>
<td><strong>{{ total_paid | money }}</strong></td>
</tr>
<tr>
<td><strong>Outstanding Amount:</strong></td>
<td><strong>{{ total_price | minus: total_paid | money }}</strong></td>
</tr>
{% endif %}
</table>

 

Regards

 

Peter 

0 Likes
AmyEmms
New Member
3 0 0

Sorted now. Thanks Peter. 

0 Likes
peterloane
Excursionist
31 4 11

Your welcome. Glad it sorted the issue. 

 

0 Likes