Jump to content

Reports Transactions - Tax rate missing for EU countrys


cluster

Recommended Posts

I need a CSV export from the paid billings> reports> transactions
however, the tax rate is missing here ...
I tried in vain to integrate this function in transactions.php (modules/reports) ;-)
How how can I extend the query and function so that the tax rate is shown?

"taxrate"=>"Tax Rate"

Link to comment
Share on other sites

you can do it in three parts...

first, add the checkbox to the filterfields array (doesn't have to be at the end, you can put it anywhere in the list)...

$filterfields = array("id"=>"ID","userid"=>"User ID","clientname"=>"Client Name","currency"=>"Currency","gateway"=>"Payment Method","date"=>"Date","description"=>"Description","invoiceid"=>"Invoice ID","transid"=>"Transaction ID","amountin"=>"Amount In","fees"=>"Fees","amountout"=>"Amount Out","rate"=>"Exchange Rate","refundid"=>"Refund ID","taxrate"=>"Tax Rate");

second, add taxrate SQL query to the filters array...

    $filters = array();
    foreach ($filterfield as $i => $val) {
        if ($val && array_key_exists($val, $filterfields)) {
            if ($val == 'clientname') {
                $val = "(SELECT CONCAT(firstname,' ',lastname) FROM tblclients WHERE id=tblaccounts.userid)";
            }
            if ($val == 'taxrate') {
                $val = "(SELECT taxrate FROM tblinvoices WHERE invoiceid=tblinvoices.id)";
            }
            $filters[] = ($filtertype[$i]=="like")
                ? $val . " LIKE '%" . db_escape_string($filterq[$i]) . "%'"
                : $val . "='" . db_escape_string($filterq[$i]) . "'";
        }
    }

the above block is already there, the only new part is the if $val=taxrate line..

finally, add it to the $fieldlist array.

    $fieldlist = array();
    foreach ($incfields AS $fieldname) {
        if (array_key_exists($fieldname,$filterfields)) {
            $reportdata["tableheadings"][] = $filterfields[$fieldname];
            if ($fieldname=="taxrate") $fieldname = "(SELECT taxrate FROM tblinvoices WHERE invoiceid=tblinvoices.id)";
            if ($fieldname=="clientname") $fieldname = "(SELECT CONCAT(firstname,' ',lastname) FROM tblclients WHERE id=tblaccounts.userid)";
            $fieldlist[] = $fieldname;
        }
    }

that should now allow you to export tax rate... :idea:

if you need taxrate2 too, you can expand the report to do the same by adding taxrate2 - SQL query would be the same except replace references to taxrate with taxrate2

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated