If Quantity equals Zero, hide Qty, Price and Total

When creating an invoice is it possible to hide the Qty, Price, and Total in the created invoice when adding a new row where the Quantity equals ‘0.00’ ?

ie,
New row added (or existing row), Item and/or Description field used to add a note to the client,
Quantity equals ‘0.00’ as no quantity or cost occurs on this row,
The outputted Invoice displays Qty, Price, Total for that row as blank, ie nothing to see

As it is by default:
image

As I would like it:
image

1 Like

I hope i can reproduce it, i’ll let you know

@webbouk do you have those amazing steps to reproduce please?
Maybe i’m missing something (again)…

Basically,

Create a new invoice and you see the field ‘Quantity’ is blank:

When filling in the first ‘Row’ it is up to the user to add a quantity if required (in this instance I’ve added 11 as the quantity…
Click ‘Save’

Add a new Row (add a note for the client) but leave the quantity field blank, Click Save…

You’ll notice that the Quantity, Price and other fields now show values even though the fields were left unfilled

It would be ideal if these fields, highlighted, remained blank when the Quantity was equal to zero (0)

By default they show zero quantity, price and total when the invoice is created…

Whereas it would be better if they remained blank, as this mock up shows…

I hope that explains it :slight_smile:

1 Like

Thanks for the great explanation!

1 Like

I’m not that clued up on php, more asp and VBscript, but something along the lines of …

if Quantity equals ‘0’ then do nothing
if Quantity greater than ‘0’ display ‘Quantity’ … added into the relevant section

with similar for the Price and Total

1 Like

Hi,

I think this is what you want…

This is easy to customize in your invoice pdf template.

<?php if ($item->item_price > 0) : ?>
    <td class="text-right">
        <?php echo format_currency($item->item_price); ?>
    </td>
<?php endif; ?>
1 Like

Got it but I had to change several lines to get it to show null value in the quantity, price and total columns

    <?php
    foreach ($items as $item) { ?>
        <tr>
            <td><?php _htmlsc($item->item_name); ?></td>
            <td><?php echo nl2br(htmlsc($item->item_description)); ?></td>
            <td class="text-right">
            <?php if ($item->item_quantity > 0) : ?>
                <?php echo format_amount($item->item_quantity); ?>
                <?php endif; ?>
                <?php if ($item->item_product_unit) : ?>
                    <br>
                    <small><?php _htmlsc($item->item_product_unit); ?></small>
                <?php endif; ?>
            </td>
            <td class="text-right">
           <?php if ($item->item_price > 0) : ?>
             <?php echo format_currency($item->item_price); ?>
           <?php endif; ?>
         </td>
        <?php if ($show_item_discounts) : ?>
                <td class="text-right">
                    <?php echo format_currency($item->item_discount); ?>
                </td>
            <?php endif; ?>
            <td class="text-right">
             <?php if ($item->item_total > 0) : ?>
                <?php echo format_currency($item->item_total); ?>
             <?php endif; ?>
            </td>
        </tr>
    <?php } ?>

Resulting PDF output…

1 Like

Please keep in mind, the case for when you invoice is a credit note.
Are you then using a different template?
Also the file. If it’s the one that comes with InvoicePlane, then you need to make a backup and next release replace it again with your copy

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.