The SimpleInvoices forum has moved to Google Plus - this forum is now read-only
Reports not working 100%... query errors?
  • ReallyNAReallyNA July 2010

    Hi there,

    I noticed that there some error on reports. For example, the Report TAX - Total Tax is not separating the Real and Draft status of invoices preferences.

    Link: http://www.simpleinvoices.org/demo/index.php?module=reports&view=report_tax_total

    Example: I have Invoice and Quotes. Since Quotes are set as draft (since there is no REAL transaction yet) I don't want the tax involved on Quotes to be showed on reports.. and all of the others reports.

    I change the query on modules/reports/report_tax_total.php and now I think the issue is solved. Please can someone check if this is correct and if yes, maybe this can be fixed on svn for later versions.

    The code - before - not working:


    <?php
    // include phpreports library
    require_once("./include/reportlib.php");

    $sSQL = "select sum(ii.tax_amount) as sum_tax_total from ".TB_PREFIX."invoice_items ii";

    $oRpt->setXML("./modules/reports/report_tax_total.xml");

    // include phpreports run code
    include("./include/reportrunlib.php");

    $smarty -> assign('pageActive', 'report');
    $smarty -> assign('active_tab', '#home');
    ?>

    The code - "fixed" - separating real from draft:

    <?php
    // include phpreports library
    require_once("./include/reportlib.php");

    $sSQL = "select sum(ii.tax_amount) as sum_tax_total from ".TB_PREFIX."invoice_items ii, ".TB_PREFIX."invoices i, ".TB_PREFIX."preferences p
    where
    i.preference_id = p.pref_id
    and
    i.id = ii.invoice_id
    and
    p.status = '1';
    ";

    $oRpt->setXML("./modules/reports/report_tax_total.xml");

    // include phpreports run code
    include("./include/reportrunlib.php");

    $smarty -> assign('pageActive', 'report');
    $smarty -> assign('active_tab', '#home');
    ?>


    Justin, can you confirm that this is the real fix?

    BTW: how can I get this fixed on statements? I want to list just the "real" documents. Same for total of products sold.. just want the ones that are on real documents.

  • justinjustin July 2010

    thanks NA

    your code looks fine - should be correct - have added to fix this in our todo list
    refer: http://code.google.com/p/simpleinvoices/wiki/todo

    re statements
    - good idea, have added this to our ideas list
    -- refer: http://code.google.com/p/simpleinvoices/wiki/ideas
    - re how to fix now - just need to do a similar edit as your first one to the statement code

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA July 2010

    Hey people,

    About the same subject with the reports not working 100%...

    Can someone help me to correct the statements reports? I want to list just the "real" documents but can't find the correct way to do that.

    I Really need this, because I'm getting a lot of invoices and I need to print the statements to check all the values.. but getting wrong values is really annoying :/

  • ReallyNAReallyNA July 2010

    Anyone? Pretty please?

  • justinjustin July 2010

    hey reallyna

    at line 68
    http://code.google.com/p/simpleinvoices/source/browse/trunk/modules/statement/index.php#68

    add

    $invoice->having_and2 = "real";

    this should make statements only show 'real' invoices

    give it a test and let us know if it works OK

    sorry for the delay - very busy at the moment

    cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA July 2010

    Hey Justin

    I did what you suggest but nothing changed.

    Don't we need to change the sql query also? To "call" some info from si_preferences table? How the index file knows what "real" is?

    Thanks again

  • ReallyNAReallyNA July 2010

    Does someone have work on the reports sometime?

    Can't find a way to solve this out.

  • ReallyNAReallyNA August 2010

    Statements Solved.

    Refer to: http://simpleinvoices.org/forum/discussion/1415/how-to-only-show-real-invoices-in-statements

    I'm going to investigate how can we solve the product sales report to show only the products in real documents.

  • mattantwestmattantwest August 2010

    Hi ReallyNA,

    Try taking a look at the code that powers the real invoices filter, if you apply this to the product sales reports you should be able to get the results you desire.
    Let me know if you need any help on this.

    Matt

  • justinjustin August 2010

    thanks matt!!!

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au

Categories