<!--
      (Do not remove this comment block.)
  Version: 2.0.x
   Last modified: December 7th 2009
        modified: May 13th 2007
        modified: November 28th 2006
        modified: August 12th 2006
	modified: February 28th 2005

  Maintainers:
               Alex Aycinena <alex.aycinena@gmail.com>
               Chris Lyttle <chris@wilddev.net>
               Neil Williams <linux@codehelp.co.uk>

  Author:
               Chris Lyttle <chris@wilddev.net>
  Translators:
               (translators put your name and email here)
-->

<chapter id="Reports">
  <title>Reports And Charts</title>

     <note><para>This section is a <quote>work in process</quote> all of the material has not been reviewed for V2.0.
      While it may not be strictly accurate, it is at least a "guide".</para></note>

   <para>Reports and Charts give <application>&app;</application> the ability to present an overview of financial
    data in various ways. This can range from a simple summary of account totals to an
    advanced portfolio view. This section will present an explanation of the main <application>&app;</application>
    reports and how to adjust them.</para>

   <para><application>&app;</application> has classified the main types of reports into four major classes. These
    are all available under the Reports menu.</para>

     <sect1 id="report-general">
      <title>General Reports</title>

       <para>The General Reports include the Account Summary Report, Custom Reports, the Tax Schedule Report and <acronym>TXF</acronym> Export, and the Transaction Report and also the reports in the Sample &amp; Custom menu.</para>

        <itemizedlist>
         <listitem>
          <para>Account Summary:</para>
         </listitem>

         <listitem id="report-taxreport">
          <para>Tax Schedule Report and <acronym>TXF</acronym> Export: The tax schedule report lists all taxable income and deductible expense amounts used in the preparation of US Income Tax returns. The purpose of the report is to provide a complete audit trail for these amounts. The report is intended to be used by a tax payer to manually prepare his or her own tax return, or alternatively, to be provided to a tax preparer for that purpose. The report can also be used to generate an export of all tax related income and expenses to a <acronym>TXF</acronym> (Tax eXchange Format) file (this is in addition to exporting to the <acronym>HTML</acronym> format that all reports allow). The <acronym>TXF</acronym> file can be imported into tax filing programs such as TaxCut or TurboTax. The report should be run, inspected carefully for errors or omissions, and then corrections made to transactions, report settings, currency conversion rates or the account structure as needed. This process should be repeated as often as needed until all the amounts on the report are correct before a final version is used and saved along with the tax returns.</para>

          <para> For accounts specified in the report options (none = all) that are also flagged as <guilabel>Tax-related</guilabel>, all transactions for the time period selected (also in the report options) are included. The report sorts transactions by date within account providing subtotals by account within tax code within Form or Schedule line number. Support is also provided for multiple copies of and for sub-line items for selected Forms/Schedules. Optionally uses special date processing to include federal estimated tax payments after year end.</para>

          <para>All totals are in USD since this is the currency required for filing US Income Tax returns. Non-USD transaction amounts are converted to USD using the transaction conversion rate to USD, if available. If not, a conversion rate from the price database is used (either the date nearest the transaction date or nearest the report date as specified in the report options; if none is available, transaction amounts are converted to zero and the report provides a comment accordingly). A complete audit trail of conversions is provided.</para>

          <note><para>For this to work, the user has to segregate taxable and non taxable
           income to different accounts, as well as deductible and non deductible expenses.
           The Income Tax Information dialog is used for this. To access the Income Tax
           Information dialog go to <menuchoice><guimenu>Edit</guimenu><guimenuitem>Tax Report Options</guimenuitem></menuchoice>. The user
           also must set the <acronym>TXF</acronym> category of each tax related account. The Income Tax
           Information dialog is described in the <xref linkend="set-tax-options"></xref> section.</para></note>

         </listitem>

         <listitem>
          <para>Transaction Report:</para>
         </listitem>

         <listitem>
          <para>Welcome Sample Report:</para>
         </listitem>

         <listitem>
          <para>Custom Multicolumn Report: This report is used to place multiple reports
           into a single report window to examine a set of financial information at a glance.</para>
         </listitem>

         <listitem>
          <para>Sample Graphs</para>
         </listitem>

         <listitem>
          <para>Sample Report with Examples:</para>
         </listitem>
        </itemizedlist>

   </sect1>

   <sect1 id="report-assets">
    <title>Assets &amp; Liabilities</title>

     <para>The Assets &amp; Liabilities reports includes the Balance Sheet report,
      Investment reports and the Net Worth report.</para>

      <itemizedlist>
       <listitem>
        <para>Advanced Portfolio:</para>
       </listitem>

       <listitem>
        <para>Asset Barchart:</para>
       </listitem>

       <listitem>
        <para>Asset Piechart:</para>
       </listitem>

       <listitem>
        <para>Average Balance:</para>
       </listitem>

       <listitem>
        <para>Balance Sheet: This report summarizes assets, liabilities, and equity.
         When properly maintained, assets should equal the sum of liabilities and equity.
         If that is not the case, there is some kind of internal imbalance in the
         accounts.</para>
       </listitem>

       <listitem>
        <para>General Journal:</para>
       </listitem>

       <listitem>
        <para>General Ledger:</para>
       </listitem>

       <listitem>
        <para>Investment Portfolio: This report summarizes the value of the stocks in
         the current portfolio.</para>
       </listitem>

       <listitem>
        <para>Liability Barchart:</para>
       </listitem>

       <listitem>
        <para>Liability Piechart:</para>
       </listitem>

       <listitem>
        <para>Net Worth Barchart: Net worth is the difference between the value of assets
         or liabilities.</para>
       </listitem>

       <listitem>
        <para>Price Scatterplot:</para>
       </listitem>
      </itemizedlist>
   </sect1>

   <sect1 id="report-income">
    <title>Income &amp; Expense</title>

     <para>The Income &amp; Expense reports includes the Cash Flow and Income Statement reports.</para>

      <itemizedlist>
       <listitem>
        <para>Budget Report:</para>
       </listitem>

       <listitem>
        <para>Cash Flow:</para>
       </listitem>

       <listitem>
        <para>Equity Statement:</para>
       </listitem>

       <listitem>
        <para>Expense Barchart:</para>
       </listitem>

       <listitem>
        <para>Expense Piechart:</para>
       </listitem>

       <listitem>
        <para>Expense vs Day of Week:</para>
       </listitem>

       <listitem>
        <para>Income Barchart:</para>
       </listitem>

       <listitem>
        <para>Income &amp; Expense Chart:</para>
       </listitem>

       <listitem>
        <para>Income Statement: This report summarizes sources of income and expenditure.
         (This report was called Profit &amp; Loss in gnucash-1.8.)</para>
       </listitem>

       <listitem>
        <para>Income Statement:</para>
       </listitem>

       <listitem>
        <para>Income vs Day of Week:</para>
       </listitem>

       <listitem>
        <para>Trial Balance: This report summarizes sources of income and expenditure.</para>
       </listitem>
      </itemizedlist>

   </sect1>

   <sect1 id="report-biz">
    <title>Business Reports</title>

      <para>The Business Reports includes Customer and Vendor Reports and Printable
       Invoices as well as Aging reports.</para>

       <itemizedlist>
        <listitem>
         <para>Customer Report:</para>
        </listitem>

        <listitem>
         <para>Easy Invoice:</para>
        </listitem>

        <listitem>
         <para>Employee Report:</para>
        </listitem>

        <listitem>
         <para>Fancy Invoice:</para>
        </listitem>

        <listitem>
         <para>Payable Aging:</para>
        </listitem>

        <listitem>
         <para>Printable Invoice:</para>
        </listitem>

        <listitem>
         <para>Receivable Aging:</para>
        </listitem>

        <listitem>
         <para>Vendor Report:</para>
        </listitem>
       </itemizedlist>

     </sect1>

     <sect1 id="report-custom">
      <title>Customizing Reports and Graphs</title>

        <para><application>&app;</application> reports have many options for customization. To access report options
         choose the <guibutton>Options</guibutton> button on the <emphasis>Toolbar</emphasis>.</para>

           <note> <para>Check changed Graphic Engine Options and describe Saving Customized Reports</para></note>
<!--          
              suggest how to save report options E.g. Choose definite options when you
              want to see an Income Statement, so you want to save them for future and
              not to choose all the time.

                File -> Add Report   (in 2.0.5).
              But first, you must change the title of the report in the options. -->

        <para>Many reports share similar sorts of options. Some common ones include:</para>

        <itemizedlist>
          <listitem>
            <para>Report Name: Set the title of the report. This is also used to print the
             report for later viewing.</para>
          </listitem>

          <listitem>
            <para>Date Options: Reports typically specify either a single date, or a date
             range, for the report. Dates can be specified in two ways, either directly
             (using the date selector), or by selecting a relative date from the menu.
             Relative dates allow you to specify dates like <guilabel>Beginning of this year</guilabel> or
             <guilabel>Today</guilabel>.</para>
          </listitem>

          <listitem>
            <para>Step Size: This option is used on bar charts to determine the interval which
             each bar represents. Typical values are daily, weekly, monthly, and yearly.</para>
          </listitem>

          <listitem>
            <para>Accounts: Select the appropriate accounts for the report. Note that in some
             reports only certain types of accounts can be selected. For example, an expense
             piechart only allows expense accounts to be selected. </para>
          </listitem>

          <listitem>
            <para>Show Long Account Names: This option allows displaying either short account
             names (for example, Power) or long account names (for example, Utilities:Power).
            </para>
          </listitem>

          <listitem>
            <para>Include Subaccounts?: Summary reports typically have an include all
             subaccounts option, which if selected ensures that all subaccounts are included
             if the parent account is.</para>
          </listitem>

          <listitem>
            <para>Depth: This option allows the selection of how many levels the report
             displays subaccounts. If the subaccounts go deeper than selected, an overall value
             for all the subaccounts is calculated and included in a total. To make sure every
             account selected is individually displayed, select <guibutton>All</guibutton>.</para>
          </listitem>

          <listitem>
            <para>Style Sheet: Select a Style Sheet. Style sheets control how reports are
             displayed. At the moment, there are four style sheets: <guilabel>Default</guilabel>, <guilabel>Easy</guilabel>,
             <guilabel>Footer</guilabel> and <guilabel>Technicolor</guilabel>.
             You can customize each of these from the <menuchoice><guimenu>Edit</guimenu><guimenuitem>Style 
             Sheets...</guimenuitem></menuchoice> menu item.
             This is described in the Changing Style Sheets section. <xref linkend="change-style"></xref></para>
          </listitem>

          <listitem>
            <para>Plot Dimensions: There are width and height options for most graphs, which
             specify the displayed dimensions (in pixels).</para>
          </listitem>

          <listitem>
            <para>Report Currency: Select the report currency. Generally, values will be
             converted to this currency for display.</para>
          </listitem>

          <listitem>
            <para>Price Source: Select how stock and currency prices are calculated in this
             report. Choose between a weighted average of prices over all transactions, prices
             at current values, or prices at the time of the report date.</para>
          </listitem>

          <listitem>
            <para>Totals: Charts display totals in the chart legend if this option is selected.
            </para>
          </listitem>

          <listitem>
            <para>Maximum Slices: Controls the maximum number of slices displayed in a
             piechart - other accounts will be placed in a slice marked Other. </para>
          </listitem>

          <listitem>
            <para>Maximum Bars: Controls the maximum number of bars displayed in a barchart.
            </para>
          </listitem>

          <listitem>
            <para>Display Columns: Choose columns to show from the register.</para>
          </listitem>
        </itemizedlist>
      </sect1>

      <sect1 id="report-print">
        <title>Printing or Exporting Reports and Graphs</title>

          <note><para> Verify !!!  How customize printing with Gnome?</para></note>

        <para><application>&app;</application> is able to print reports and to export the reports to <acronym>HTML</acronym> (web) pages. The
         Print <application>&app;</application> Document dialog is accessed from the <guibutton>Print</guibutton> button on the <emphasis>Toolbar</emphasis> or
         go to <menuchoice><guimenu>File</guimenu><guimenuitem>Print</guimenuitem></menuchoice> in the menu. To Export a report to a web page (<acronym>HTML</acronym>) select
         the <guibutton>Export</guibutton> button on the <emphasis>Toolbar</emphasis> and type in a file name.</para>


        <para>The Print <application>&app;</application> Document dialog is used to select which Printer to send the
         print job to or to print to a File. It also contains a Preview button to view the
         document before printing. Press Print to send the job to the selected printer or
         <guibutton>Cancel</guibutton> to dismiss the Print dialog.</para>


        <para>Printing from an open register prints the Account Report, which is also called
         the Register Report. This lists transactions in the account with a total. Other
         reports print as viewed in the Report screen.</para>
      </sect1>

      <sect1 id="report-create">
        <title>Creating Reports and Graphs</title>

             <note><para>This section may need updating !!!</para> </note>

        <para>It is possible to write reports if the current ones are not suitable. To do this
         you will need to know Scheme (a LISP-like programming language), and it is an
         excellent idea to have a copy of the <application>&app;</application> source code available. </para>

        <para>The reporting interface is documented in the source code file
         <filename>src/report/report-system/doc/report-html.txt</filename>. The file <filename>src/report/utility-reports/hello-world.scm</filename>
         in the <application>&app;</application> source distribution provides a good example of how reports are
         developed.</para>

        <para>It is also necessary to access data from the engine to get information for your
         report. This is performed by a set of Scheme wrapper functions that are documented in
         the file <filename>src/g-wrap/gnc.html</filename>. Examine some of the other reports in src/scm/report for
         an indication of how they are used.</para>

        <para>At present, reports are produced by calling a <acronym>HTML</acronym>-generation API, which outputs
         a dialect of <acronym>HTML</acronym> and rendering this with a <acronym>HTML</acronym> widget. This has limitations,
         particularly when trying to align objects precisely, as might be necessary for
         printing onto pre-printed invoices for example.</para>
   </sect1>

</chapter>
