I’m doing customization on the invoice template but in the second I duplicate and start working I got result like in the image. As you can see empty lines produces zeros.
I need to add 14 lines to match the sizes of my paper invoice so please dont tell me to remove unused lines. In the original version of the invoice I’m able to add as many lines as I want and it still looks the same(empty)
@fohteh I needed the same for my invoice template and did the following.
I added empty lines based on my max lines, in your case 14, and substracted real invoice lines.
Like this:
<!-- First loop which is already in template, look for it -->
{% for line in lines %}
<tr>
<td> ... </td>
</tr>
{% endfor %}
<!-- Second loop to add missing empty lines -->
{% assign blank_lines = 14 | minus:lines.size %}
{% for i in (1..blank_lines) %}
<tr>
<td> </td>
</tr>
{% endfor %}
For de table data <td> part of the second loop, you best copy that from the first loop because it may have columns that do not always appear on the invoice and place in the value part as shown in the example.
@fohteh, if you are happy with the look of default template, I guess I can make some modifications to it so if no description is entered and unit price is 0.00, then you will get empty line.
That way you wouldn’t need to do anything with HTML, just make sure all your invoices have 20 lines or so. Would that work for you?
I actually modified the default template to match my original paper invoice. So making changes in the original invoice would only correct the empty lines.
I exactly need 11 lines for the invoice. But also I need to be able to add items in those lines whenever 2 or more products to be listed.
If you can work on my code then the problem might be solved. But I can’t add it here its too long. Any idea how can I send it to you?
I actually checked the latest version and Manager doesn’t show quantity and amounts on invoices in default template if line item is empty.
So if you really insist on custom HTML, you probably need to use some “if / else” expression.
For example:
{% if qty != 0 %} {{ qty }} {% endif %}
This way qty variable prints only if it’s not zero.
I can’t help with debugging custom HTML issues. I’m more than happy to keep improving default invoice template so no HTML is needed in the first place. As it stands now, default invoice template doesn’t show anything in quantity or amount columns if the line item is empty.
If you use custom HTML template, it shows those columns and zeroes because that’s what is in that template to do. So everything works as expected.
You will need to understand HTML (or have someone to help you) otherwise don’t use any HTML template and stick to default look & feel which is a bit more sophisticated (automatically hiding columns which are not relevant or hiding zeroes).
I have taken a default template (which @lubos has recently given an extra last line) and adjusted it to your needs. You will have to do some translation into turkish yourself.
Now you will have 11 lines on your invoice with no zero in the empty lines. Even so for normal line items with a quantity of 0. (See addition @lubos from Sept. 2). Also any additional lines from 11 upward will be added if need be.
@fohteh, the option will work only if you are not using custom HTML. Once you use custom HTML, you will need to use HTML markup to make custom field visible on printed invoice just like @Hans has suggested.