Show total tax in sales by client report

I use this code to show total sales in a certain period. Now I want to subtract $report_total_tax with $report_total, but I am not a programmer. Can anyone help me out with this?
I tried the following code to get the tax but without luck.

<?php echo ''.format_currency($report_total_tax-$report_total).''; ?>ā€™

This is the used code:

THX Freek

1 Like

The line you pasted here is not in the code you pasted,

You are on the right track. What result are you getting.

Just a few things

a) Set the values as numbers, not strings

$report_inv_count = 0;
$report_total = 0;
$report_total_tax = 0;

b) Split the code for more readability. While your code is correct, rather split the echos with the sums

        <td><?php _htmlsc(format_client($result)); ?></td>
        <td class="amount"><?php echo $result->invoice_count; ?></td>
        <td class="amount"><?php echo format_currency($result->sales); ?></td>
        <td class="amount"><?php echo format_currency($result->sales_with_tax); ?></td>            
        $report_inv_count = $result->invoice_count + $report_inv_count;
        $report_total = $result->sales + $report_total;
        $report_total_tax = $result->sales_with_tax + $report_total_tax;       

c) Relook your use of isset. isset() means there is no value, which is the not the same as empty value. Since your variables are numbers, use number tests

if( ($report_inv_count > 0) && ($report_total > 0) && ($report_total_tax > 0) )


if( ($report_inv_count) && ($report_total) && ($report_total_tax) )

1 Like

I added the following code but no results are shown and also no error.
ā€˜<?php echo ''.format_currency($report_total_tax - $report_total).''; ?>ā€™
I am not a scripter so this is a little outside my scope.
THX Freek