Invoice tax line shifted or mixed


#1

I just upgraded from IP 1.5.7 to 1.5.9 and everything looks good except for one thing.
In the window where i create the invoice, the line with the invoice tax is shifted or mixed…After Invoice Tax the order of items is: Amount,- BTW (tax) - 21.00 (percentage) - Trashcan.

ip159

I think the amount should be the last in this row to keep the amounts in line.

I cannot find that this a known issue so maybe i something went wrong with the update.

Any help would be appreciated.


#2

You are correct: the content order is reversed, even the wastebasket. This is how it looks in demo

I will check the code and see if there is an explanation for that behaviour.

Did you follow the update instructions in the wiki?

As for running the setup again, I don’t think it would fix this problem.


#3

Thank you Miquel. I did follow the update as in the wiki and I did some updates in the past without any problemt. So not sure what may cause this issue.
Do you know in which file these fields are made up?


#4

The code that renders this summary table is in file

  • invoiceplane-v15/application/modules/invoices/views/partial_item_table.php

starting approximately in the line 325-300, and the code for the Invoice Tax row is,

<td><?php _trans('invoice_tax'); ?></td>
    <td>
        <?php if ($invoice_tax_rates) {
            foreach ($invoice_tax_rates as $invoice_tax_rate) { ?>
                <form method="post"
                    action="<?php echo site_url('invoices/delete_invoice_tax/' . $invoice->invoice_id . '/' .          $invoice_tax_rate->invoice_tax_rate_id) ?>">
                <?php _csrf_field(); ?>
                <span class="amount">
                    <?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
                </span>
                <span class="text-muted">
                    <?php echo htmlsc($invoice_tax_rate->invoice_tax_rate_name) . ' ' . format_amount($invoice_tax_rate->invoice_tax_rate_percent) ?>
                </span>
                <button type="submit" class="btn btn-xs btn-link"
                    onclick="return confirm('<?php _trans('delete_tax_warning'); ?>');">
                    <i class="fa fa-trash-o"></i>
                </button>
            </form>

And now that I see the code the cause of the error is obvious: the string is built concatenating the elements in the reversed order you have reported,

  1. invoice_tax_rate_amount
  2. invoice_tax_rate_name
  3. invoice_tax_rate_percent
  4. fa-trash-o icon

which is not the one displayed in demo and the one we would expect.

I will investigate why and when the order got reversed and I will submit a pull-request to correct it in v1.5.10.

In the meanwhile, to restore the order, you could replace (make a backup copy of the file before editing it) the code with this one:

<td><?php _trans('invoice_tax'); ?></td>
    <td>
        <?php if ($invoice_tax_rates) {
            foreach ($invoice_tax_rates as $invoice_tax_rate) { ?>
                <form method="post"
                    action="<?php echo site_url('invoices/delete_invoice_tax/' . $invoice->invoice_id . '/' .          $invoice_tax_rate->invoice_tax_rate_id) ?>">
                <?php _csrf_field(); ?>
                <button type="submit" class="btn btn-xs btn-link"
                    onclick="return confirm('<?php _trans('delete_tax_warning'); ?>');">
                    <i class="fa fa-trash-o"></i>
                </button>
                <span class="text-muted">
                    <?php echo htmlsc($invoice_tax_rate->invoice_tax_rate_name) . ' ' . format_amount($invoice_tax_rate->invoice_tax_rate_percent) ?>
                </span>
                <span class="amount">
                    <?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
                </span>
            </form>

that yields,

image


#5

@Kovah the order was reversed in this commit,

that also reversed the order of the tax line in quotes view.

Is there a reason to keep it? I have tested the element sorting trash_button + tax_name + tax_rate + tax_amount and the delete feature works, thus, I think it is safe to make that change. Should I open a ticket and submit a PR?

Also, which format do you prefer?

  1. [trash-icon] US Std 7,00% 28,00€
  2. [trash-icon] (US Std 7,00%) 28,00€
  3. [trash-icon] (US Std 7,00 %) 28,00€
  4. none of the above (which one?)

#6

Many thanks, Miquel. I did the change and it is okay now!


#7

Maybe this?

US Std 7,00% 28,00€ [trash-icon]

#8

Not sure, the amount should be the rightmost element if we want it to align with amounts in previous lines.


#9

Ok, fine for me


#10

@Benny54 Ok and thanks for reporting the problem. Whenever you have time, remember to mark as correct answer the post with the solution.


#11

Ticket created:

IP-745 - Reorder tax line in invoice & quote views to display the amount at the right end

and pull-request submitted:


#12

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