<!--
      (Do not remove this comment block.)
  Version: 2.0.0
  Last modified: October 25th 2010
       modified: January 12th 2007
       modified: July 9th 2006
  Maintainers: 
               Cristian Marchi <cri.penta@gmail.com> 
               Chris Lyttle <chris@wilddev.net>
  Author:
  		Jon Lapham <lapham@extracta.com.br>
  	Updated	Bengt Thuree <bengt@thuree.com>
  Originally written by Carol Champagne.
  Translators:
               (translators put your name and email here)
-->
<chapter id="chapter_basics">
  <title>The Basics</title>

  <para>This chapter will introduce some of the basics of using <application>&app;</application>. It is
  recommended that you read through this chapter, before starting to do any
  real work with <application>&app;</application>. Next chapters will begin to show
  you hands on examples.</para>

  <sect1 id="basics-accounting1">
    <title>Accounting Concepts</title>

    <para><application>&app;</application> is easy enough to use that you do not need to have a
    complete understanding of accounting principles to find it useful.
    However, you will find that some basic accounting knowledge will prove to
    be invaluable as <application>&app;</application> was designed using these principles as a
    template. It is highly recommended that you understand this section of the
    guide before proceeding.</para>

    <sect2 id="basics-accounting52">
      <title>The 5 Basic Accounts</title>

      <para>Basic accounting rules group all finance related things into 5
      fundamental types of <quote>accounts</quote>. That is, everything that
      accounting deals with can be placed into one of these 5 accounts:</para>

      <itemizedlist>
        <listitem>
          <para><emphasis>Assets</emphasis> &mdash; things you own.</para>
        </listitem>

        <listitem>
          <para><emphasis>Liabilities</emphasis> &mdash; things you owe.</para>
        </listitem>

        <listitem>
          <para><emphasis>Equity</emphasis> &mdash; overall net worth.</para>
        </listitem>

        <listitem>
          <para><emphasis>Income</emphasis> &mdash; increases the value of your
          accounts.</para>
        </listitem>

        <listitem>
          <para><emphasis>Expenses</emphasis> &mdash; decreases the value of your
          accounts.</para>
        </listitem>
      </itemizedlist>

      <para>It is clear that it is possible to categorize your financial world
      into these 5 groups. For example, the cash in your bank account is an
      asset, your mortgage is a liability, your paycheck is income, and the
      cost of dinner last night is an expense.</para>
    </sect2>

    <sect2 id="basics-accountingequation2">
      <title>The Accounting Equation</title>

      <para>With the 5 basic accounts defined, what is the relationship
      between them? How does one type of account affect the others? Firstly,
      equity is defined by assets and liability. That is, your net worth is
      calculated by subtracting your liabilities from your assets:</para>

      <para><emphasis>Assets - Liabilities = Equity</emphasis></para>

      <para>Furthermore, you can increase your equity through income, and
      decrease equity through expenses. This makes sense of course, when you
      receive a paycheck you become <quote>richer</quote> and when you pay for dinner you
      become <quote>poorer</quote>. This is expressed mathematically in what is known as
      the Accounting Equation:</para>

      <para><emphasis>Assets - Liabilities = Equity + (Income -
      Expenses)</emphasis></para>

      <para>This equation must always be balanced, a condition that can only
      be satisfied if you enter values to multiple accounts. For example: if
      you receive money in the form of income you must see an equal increase
      in your assets. As another example, you could have an increase in assets
      if you have a parallel increase in liabilities.</para>

      <figure pgwide="1">
        <title>The basic accounts relationships</title>
        <screenshot id="basics-AccountRelationships">
          <mediaobject>
            <imageobject role="html">
              <imagedata fileref="figures/basics_AccountRelationships.png"
                         format="PNG" srccredit="Geert Janssens" ></imagedata>
            </imageobject>
            <imageobject role="fo">
              <imagedata fileref="figures/basics_AccountRelationships.svg"
                         format="SVG" srccredit="Geert Janssens"
                         contentwidth="4in"></imagedata>
            </imageobject>

            <textobject>
              <phrase>The basic accounts relationships</phrase>
            </textobject>

            <caption>
              <para>A graphical view of the relationship between the 5 basic
              accounts. Net worth (equity) increases through income and
              decreases through expenses. The arrows represent the movement of
              value.</para>
            </caption>
          </mediaobject>
        </screenshot>
      </figure>
    </sect2>

    <sect2 id="basics-accountingdouble2">
      <title>Double Entry</title>

      <para>The accounting equation is the very heart of a <firstterm>double entry
      accounting system</firstterm>. For every change in value of one account in the
      Accounting Equation, there must be a balancing change in another. This
      concept is known as the <firstterm>Principle of Balance</firstterm>, and
      is of fundamental importance for understanding <application>&app;</application> and other double
      entry accounting systems. When you work with <application>&app;</application>, you will always be
      concerned with at least 2 accounts, to keep the accounting equation
      balanced.</para>

      <para>Balancing changes (or transfers of money) among accounts are
      done by debiting one account and simultaneously crediting another.
      Accounting <firstterm>debits</firstterm> and
      <firstterm>credits</firstterm> do not mean <quote>decrease</quote>
      and <quote>increase</quote>. Debits and credits each increase certain
      types of accounts and decrease others. In asset and expense accounts,
      debits increase the balance and credits decrease the balance. In
      liability, equity and income accounts, credits increase the balance
      and debits decrease the balance.</para>

      <para>This accounting terminology can be confusing to new users,
      which is why <application>&app;</application> allows you to use the
      common terms <guilabel>Deposit</guilabel> and
      <guilabel>Withdrawal</guilabel>. If you prefer the formal accounting
      terms, you can change the account register column headings to use
      them in the <guilabel>General</guilabel> tab under
      <guilabel>Preferences</guilabel> (see the
      <application>&app;</application> Help Manual for more information on
      setting preferences).</para>

    </sect2>
  </sect1>

  <sect1 id="basics-entry1">
    <title>Data Entry Concepts</title>

    <para>When entering data in <application>&app;</application>, you should be aware of the 3 levels
    of organization in which <application>&app;</application> divides your data: files, accounts and
    transactions. These levels are presented in their order of complexity, one
    file contains many accounts and one account contains many transactions.
    This division is fundamental to understanding how to use <application>&app;</application>.</para>

    <sect2 id="basics-files2">
      <title>Files</title>

      <para><application>&app;</application> stores information at the
      highest level in files. A file can be stored on your computer either
      as a single <acronym>XML</acronym> file (in all versions of
      <application>&app;</application>), or in a <acronym>SQL</acronym>
      database (in <application>&app;</application> version 2.4 and higher).</para>

      <note>
        <para><acronym>SQL</acronym> is pronounced <quote>sequel</quote>,
        so in spoken and written language we would say <quote>a SQL
        database</quote>.</para>
      </note>

      <para>With the <acronym>XML</acronym> file format,
      <application>&app;</application> stores your data in an
      <acronym>XML</acronym> data file, usually in compressed format
      (although this can be changed in the <guilabel>General</guilabel>
      tab of the <application>&app;</application> <guilabel>Preferences</guilabel>).</para>

      <para>With <acronym>SQL</acronym> storage,
      <application>&app;</application> stores your data in a
      <acronym>SQL</acronym> database under the database application you
      select (SQLite3, MySQL or PostgreSQL).</para>

      <para>You will need one main file or database for each set of
      accounts you are maintaining. To learn how to create and manage
      <application>&app;</application> files, see <xref
      linkend="basics-files1"/>.</para>

      <note>
        <para>If you think you might need more than one set of accounts,
        you might want to consult a professional accountant or bookkeeper
        before proceeding. Most users will probably have only one data
        file.</para>
      </note>

      <para>Backup files and log files are automatically generated by
      <application>&app;</application> when appropriate. Backup and log
      files are described in <xref linkend="basics-backup1"/>.</para>
    </sect2> <!-- basics-files2 -->
    <sect2 id="basics-accounts2">
      <title>Accounts</title>

      <para>An <firstterm>account</firstterm> keeps track of what you own,
      owe, spend or receive. Each <application>&app;</application> file can
      contain any number of accounts, and each account can contain many
      sub-accounts up to an arbitrary number of levels. This simple feature
      gives <application>&app;</application> much of its power in managing
      your finances, as you will see in later chapters.</para>

      <para>Examples of accounts include: checking accounts, savings
      accounts, credit card accounts, mortgages, and loans. Each
      <application>&app;</application> account tracks the activity for that
      <quote>real</quote> account, and can inform you of its status.</para>

      <para>In addition, accounts are also used to categorize the money you
      receive or spend. For example, you can create expense accounts to
      track the money you pay on utilities or groceries. Even though these
      are not accounts that receive statements, they allow you to determine
      how much money is being spent in each of these areas.</para>

      <para>Accounts will be covered in more detail in <xref
      linkend="chapter_accts"/>.</para>
    </sect2> <!-- basics-accounts2 -->
    <sect2 id="basics-transactions2">
      <title>Transactions</title>

      <para>A <firstterm>transaction</firstterm> represents the movement of
      money among accounts. Whenever you spend or receive money, or
      transfer money between accounts, that is a transaction.</para>

      <para>Examples of transactions are: paying a phone bill, transferring
      money from savings to checking, buying a pizza, withdrawing money,
      and depositing a paycheck. <xref linkend="chapter_txns"/> goes more
      in depth on how to enter transactions.</para>

      <para>In double entry accounting, transactions always involve at
      least two accounts&ndash;a source account and a destination account.
      <application>&app;</application> manages this by inserting a line
      into the transaction for every account that is affected, and
      recording the amounts involved in each line. A line within a
      transaction that records the account and amount of money involved is
      called a <firstterm>split</firstterm>. A transaction can contain an
      arbitrary number of splits.</para>

      <para>Splits in transactions will be covered in <xref
      linkend="txns-registers-multiaccount2"/></para>
    </sect2> <!-- basics-transactions2 -->
  </sect1> <!-- basics-entry1 -->

  <sect1 id="basics-interface1">
    <title>Interface</title>

    <para>The very first time you open <application>&app;</application>, you will see the
    <guilabel>Welcome to &app;!</guilabel> screen. From there, <application>&app;</application>
    provides other tools to help you easily find what you are looking for.
    Let&rsquo;s take a look at some of the common screens and screen boxes you will
    see.</para>

    <sect2 id="basics-tip2">
      <title>Tip of the Day</title>

      <para><application>&app;</application> provides a <guilabel>Tip of the Day</guilabel> screen to
      give helpful hints for using the program:</para>

      <screenshot id="basics-TipOfDay">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/basics_TipOfDay.png" format="PNG"
                       srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The Tip of the Day</phrase>
          </textobject>

          <caption>
            <para>This image shows the <guilabel>Tip of the
            Day</guilabel>.</para>
          </caption>
        </mediaobject>
      </screenshot>

      <para>These tips provide useful information for beginning users. To view
      more of the tips, click <guibutton>Forward</guibutton> to continue. If you
      do not wish to see this screen box on start-up, deselect the box next to
      <guilabel>Show tips at startup</guilabel>. When you have
      finished viewing the helpful tips, click <guibutton>Close</guibutton> to
      close the <guilabel>Tip of the Day</guilabel> screen.</para>
    </sect2>

    <sect2 id="basics-main2">
      <title>Account Tree Window</title>

      <para>You should now see the <guilabel>Accounts</guilabel> window, which
      appears as shown below. The exact layout of the account tree will depend
      on which default accounts you selected during the New Account Hierarchy
      Setup. In this example, the <guilabel>Common Accounts</guilabel> are shown.</para>

      <screenshot id="basics-Accounts">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/basics_Accounts.png" format="PNG"
                       srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The Account Tree Window</phrase>
          </textobject>

          <caption>
            <para>This image shows the <guilabel>Accounts</guilabel>
            window.</para>
          </caption>
        </mediaobject>
      </screenshot>

      <para>The Account Tree window provides an overview of the data contained
      in the current file. It contains a list of account names and their
      current balances. From this window, you can open any of the accounts.
      The individual account windows are called account registers. <application>&app;</application>
      allows you to have as many account registers open as you wish.</para>

      <para>At the top of this window is the <emphasis>Titlebar</emphasis>, which displays the
      file name (once you have saved the file.) Below that is the <emphasis>Menubar</emphasis>.
      You can access the menu options by either clicking on these menu
      headings or by using shortcuts and access keys (see <xref linkend="basics-shortcut2" />). 
      Next is the <emphasis>Toolbar</emphasis>, which contains buttons
      for the most common functions.</para>
      
      <para>The account tree appears below the <emphasis>Toolbar</emphasis>. Once you have
      started creating accounts, the account names will appear in the account
      tree. You can customize which headings show up by using the
      small <guiicon>down-arrow</guiicon> at the far right just above the account tree.</para>

      <para>At the bottom is the <emphasis>Statusbar</emphasis>, which tells you
      information about what you own (Net Assets) and how much money you have
      made (Profits).</para>


    </sect2>

    <sect2 id="basics-register2">
      <title>Account Register Window</title>

      <para>The Account Register windows are used to enter and edit your
      account data. As the name suggests, they look similar to a checkbook
      register. When you double-click an account name in the
      <guilabel>Accounts</guilabel> window, the <guilabel>Register</guilabel>
      window for that account will open.</para>

      <screenshot id="basics-CheckAccount">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_CheckAccount.png" format="PNG"
                       srccredit="Bengt Thuree" width="510"></imagedata>
          </imageobject>
          
          <imageobject role="fo">
            <imagedata fileref="figures/basics_CheckAccount.png" format="PNG"
                       srccredit="Bengt Thuree" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The Checking Account Register</phrase>
          </textobject>

          <caption>
            <para>This image shows the <guilabel>Checking Account - Register
            </guilabel> with several transactions.</para>
          </caption>
        </mediaobject>
      </screenshot>

      <para><xref linkend="chapter_txns"></xref> explains more about account 
      register windows and how to
      enter data into them. For now, note that the parts of an account
      register window are similar to the parts of the account tree window
      described earlier. The <emphasis>Titlebar</emphasis> at the top contains the account name.
      Below that, the <emphasis>Menubar</emphasis> contains menu options related to the account
      register. <emphasis>Toolbar</emphasis> buttons simplify common data entry functions. The
      <emphasis>Statusbar</emphasis> at the bottom of the window, displays some account balances
      covered in <xref linkend="chapter_txns"></xref>. At the bottom of the 
      account register window,
      information appears about the current location of the cursor.</para>
      
      <note>
      <para>In the register windows, you can resize the various columns that 
        <application>&app;</application> displays, but keep in mind that 
        the description column will automatically expand to fill all unused
        space.  Therefore you should increase the size of all your other columns
        first and then decrease the size of the description column.</para>
      </note>
      
    </sect2>

    <sect2 id="basics-toolbar2">
      <title>Toolbar Buttons</title>

      <para>Both the account tree window and the account register window
      contain <emphasis>Toolbar</emphasis> buttons. These buttons provide quick access to common
      functions such as <guibutton>Save</guibutton> and
      <guibutton>Open</guibutton> in the account tree window and
      <guibutton>Record</guibutton> and <guibutton>Delete</guibutton> in the
      account register window. If you are not sure what a button does, move
      the mouse pointer over that button, and you should see a description of
      the function appear.</para>

      <para>Here is a summary of the account tree window buttons:</para>

      <itemizedlist>
        <listitem>
          <para><guibutton>Save</guibutton> &mdash; Save
          the current file to disk.</para>
        </listitem>

        <listitem>
          <para><guibutton>Close</guibutton> &mdash; Close the
          current notebook page.</para>
        </listitem>

        <listitem>
          <para><guibutton>Open</guibutton>, <guibutton>Edit</guibutton>,
          <guibutton>New</guibutton> and <guibutton>Delete</guibutton> &mdash; These
          are functions related to accounts. They are discussed in 
          <xref linkend="chapter_accts"></xref>.</para>
        </listitem>
      </itemizedlist>
      
      <para>Register buttons are discussed in <xref linkend="chapter_txns"></xref>.
      </para>
    </sect2>

    <sect2 id="basics-options2">
      <title>Menu Items</title>

      <para>The account tree window and the account register window both
      contain menu headings in a <emphasis>Menubar</emphasis>. Clicking on a menu heading brings
      up the menu items for that heading.</para>

      <para>You can click on the account tree menu headings and then move the
      mouse pointer over the menu items to see what they do. As the pointer
      moves over a menu item, a description of the item appears in the lower
      left-hand corner of the window (inside the <emphasis>Statusbar</emphasis>). To select a menu item, click on
      it.</para>

      <para>You can also access the most common menu items in a window by
      right-clicking the mouse anywhere in that window. In the account tree
      window, this will bring up a list of account items. In the account
      register window, this will bring up a list of transaction items.</para>

      <para>Other ways of accessing menu items are through keyboard shortcuts
      and access keys, described next.</para> </sect2>

    <sect2 id="basics-shortcut2">
      <title>Menu Shortcuts</title>

      <para>All of the menu items have access keys which are
      marked by underlined characters in the menu names. Pressing the
      <keycap>Alt</keycap> key with the underlined character in the menu
      heading will bring up the menu items for that heading. Once the menu
      items are displayed, type the underlined character in the menu item to
      activate it. For example, typing <keycombo><keycap>Alt</keycap>
      <keycap>F</keycap></keycombo> in the main window brings up the <guimenu>File</guimenu>
      menu, then typing <keycap>S</keycap> will save the file.  Access keys
      are fixed and cannot be changed by users.</para>

      <para>Some of the more commonly used menu items also have shortcut keys
      that directly activate the command without having to traverse the menu
      structure.  These shortcuts typically use the <keycap>Ctrl</keycap>
      key, although they can use any key combination.  Menu shortcuts are
      displayed at the end of each menu item.</para>
    </sect2>
  </sect1>

  <sect1 id="basics-help1">
    <title>Getting Help</title>

    <para><application>&app;</application> offers help in many ways. We have already covered the <link linkend="basics-tip2">
    <guilabel>Tip of the Day</guilabel></link> screen that gives you helpful hints
    upon start-up of your <application>&app;</application> session. <application>&app;</application> also offers an extensive
    help manual.</para>

    <sect2 id="basics-manual2">
      <title>Help Manual</title>

      <para>Once you have opened <application>&app;</application>, you will see the <guilabel>Account
      Tree</guilabel> window <guilabel>Help</guilabel> menu heading, which
      opens the on-line manual. The on-line manual is organized by topic, and
      you can expand each topic into its subtopics.</para>

      <para>Topics are listed on the left side. To select a topic or subtopic,
      click on it, and you should see the text for that topic appear on the
      right. Use the <guibutton>Back</guibutton> and
      <guibutton>Forward</guibutton> buttons to navigate through your topic
      choices, and print any text using the <guibutton>Print</guibutton>
      button.</para>
    </sect2>

    <sect2 id="basics-web2">
      <title>Web Access</title>

      <para>The <guilabel>&app; Help</guilabel> window also acts as a simple
      web browser, so you can pull up a web site for additional information.
      You can open any web site under this window by clicking the
      <guibutton>Open</guibutton> <emphasis>Toolbar</emphasis> button and then typing in the URL.
      Use the <guibutton>Back</guibutton>, <guibutton>Forward</guibutton>,
      <guibutton>Reload</guibutton>, <guibutton>Stop</guibutton>, and
      <guibutton>Print</guibutton> buttons as you would in a standard
      browser.</para>

      <para>The <ulink
      url="http://www.gnucash.org"><citetitle>&app;</citetitle></ulink> web
      site contains helpful information about the program and about any
      updates to it. It also contains links to the <application>&app;</application> mailing lists for
      developers and users, and you can search the <ulink
      url="https://lists.gnucash.org/cgi-bin/namazu.cgi"><citetitle>archives
      of <application>&app;</application> mailing lists</citetitle></ulink> for discussions on a
      particular topic. If you don&rsquo;t find the answers you are looking for, you
      can post your question to the <ulink
      url="https://lists.gnucash.org/mailman/listinfo/gnucash-user"><citetitle>&app;
      user list</citetitle></ulink>, and someone on the list will attempt to
      answer you.</para>

      <para>The most updated <guilabel>&app; FAQ</guilabel> is also located
      on the <ulink url="http://wiki.gnucash.org/wiki/FAQ"><citetitle>&app;
      FAQ website</citetitle></ulink>, and contains answers to the popular
      questions.</para>
    </sect2>

    <sect2 id="basics-topic2">
      <title>Topic Search</title>

      <para>The online manual also provides a search function. To search for a
      particular topic, click the <guilabel>Search</guilabel> tab at the
      bottom of the help window and type in your topic in the field provided.
      Click the <guibutton>Search</guibutton> button to complete your search.
      A list of choices should appear in the box below, clicking a choice will
      bring up its text on the right.</para>
    </sect2>
  </sect1>

  <sect1 id="basics-files1">
    <title>Storing your financial data</title>

    <para><application>&app;</application> is able to <link linkend="basics-store-data">store</link>
    your financial data in files or <acronym>SQL</acronym> databases so that they can be 
    <link linkend="basics-open-data">opened</link> and modified at a later time. 
    But first you need to <link linkend="basics-create-data">create</link> a container for your data.</para>
    
    <sect2 id="basics-create-data">
    <title>Creating a file</title>
    <para>To create a new <application>&app;</application> file do the following:</para>

    <orderedlist>
      <listitem>
        <para>From the <application>&app;</application> <emphasis>Menubar</emphasis>, choose <menuchoice><guimenu>File</guimenu>
        <guimenuitem>New File</guimenuitem></menuchoice>. The <guilabel>New Account Hierarchy setup</guilabel>
        assistant will start.</para>
        <note>
          <para>If you are running <application>&app;</application> for the first time, you will be presented 
          with the <guilabel>Cannot find default values</guilabel> screen or with the 
          <guilabel>Welcome to &app;!</guilabel> screen. Both are described in detail in the 
          <application>&app;</application> manual.</para>
        </note>
      </listitem>

      <listitem>
        <para>Set your preferences in the assistant and move through the screens with the 
        <guibutton>Forward</guibutton>, <guibutton>Cancel</guibutton> and <guibutton>Previous</guibutton>
        buttons.</para>
      </listitem>
    </orderedlist>

    </sect2>
    
    <sect2 id="basics-store-data">
    <title>Saving data</title>
    <para>Follow these steps to save the file under your preferred name:</para>

    <orderedlist>
      <listitem>
        <para>Choose <menuchoice><guimenu>File</guimenu> <guimenuitem>Save
        As...</guimenuitem></menuchoice> from the <emphasis>Menubar</emphasis> or select the
        <guibutton>Save</guibutton> <emphasis>Toolbar</emphasis> button. <application>&app;</application> will bring
        up the save window.</para>
      </listitem>

      <listitem>
        <para>Select the <guilabel>Data Format</guilabel> of the file you are saving from the 
        drop down list. The default selection is <acronym>XML</acronym> but if you have set up a 
        database back end you can change to that format.</para>
        <para>Depending on the selected <guilabel>Data Format</guilabel> the window can change as 
        described in the following.</para>  
      </listitem>

      <listitem>
      <para></para>
        <itemizedlist>
          <listitem>
            <para>If you selected <acronym>XML</acronym> or <acronym>sqlite3</acronym> you will see a screen like this:</para>

        <figure>
        <title>Save screen when <acronym>XML</acronym> or <acronym>sqlite3</acronym> is selected.</title>
        <screenshot id="basics-SaveXML">
          <mediaobject>
            <imageobject role="html">
              <imagedata fileref="figures/basics_SaveXML.png" format="PNG"
                         srccredit="Cristian Marchi" width="510px"></imagedata>
            </imageobject>

            <imageobject role="fo">
              <imagedata fileref="figures/basics_SaveXML.png" format="PNG"
                         srccredit="Cristian Marchi"></imagedata>
            </imageobject>

            <textobject>
              <phrase>The Save screen</phrase>
            </textobject>

            <caption>
              <para>This image shows the <guilabel>Save</guilabel> screen when the selected 
              <guilabel>Data Format</guilabel> is <acronym>XML</acronym> or <acronym>sqlite3</acronym>.</para>
            </caption>
          </mediaobject>
        </screenshot>
        </figure>

            <para>Type your chosen filename in the <guilabel>Name</guilabel> field. It is not necessary to specify an 
            extension when you write the file name. <application>&app;</application> will automatically add the extension 
            <filename>.gnucash</filename> to the file.</para>
            <note>
              <para>The <filename>.gnucash</filename> extension was introduced in the 2.3 series of <application>&app;</application>.
              For already existing files, the extension will never be changed. So if you open an existing file named 
              <filename>Myoldfile</filename>, that name won&rsquo;t be changed if the file is saved. You might use the 
              <guimenuitem>Save As...</guimenuitem> command and give the file a new name in order to have it saved with the 
              extension <filename>.gnucash</filename>.</para>
            </note>
            <para>Select the path where the file will be saved by browsing the tree in the lower panes.</para>
            <tip>
              <para>Click on the <guibutton>Create Folder</guibutton> button to create a new folder with a
              custom name in the selected path.</para>
            </tip>
          </listitem>
        
          <listitem>
            <para>If you selected <acronym>mysql</acronym> or <acronym>postgres</acronym>
            <guilabel>Data Format</guilabel> you will see a screen like this:</para>

            <figure>
            <title>Save screen when <acronym>mysql</acronym> or <acronym>postgres</acronym> is selected.</title>        
            <screenshot id="basics-SaveSQL">
              <mediaobject>
                <imageobject role="html">
                  <imagedata fileref="figures/basics_SaveSQL.png" format="PNG"
                             srccredit="Marchi Cristian" width="510px"></imagedata>
                </imageobject>

                <imageobject role="fo">
                  <imagedata fileref="figures/basics_SaveSQL.png" format="PNG"
                             srccredit="Cristian Marchi"></imagedata>
                </imageobject>

                <textobject>
                  <phrase>The Save screen</phrase>
                </textobject>

                <caption>
                  <para>This image shows the <guilabel>Save</guilabel> screen when the selected 
                  <guilabel>Data Format</guilabel> is <acronym>mysql</acronym> or <acronym>postgres</acronym>.</para>
                </caption>
              </mediaobject>
            </screenshot>
            </figure>

            <para>Enter in this window the <guilabel>Database Connection</guilabel> information:
            <guilabel>Host</guilabel>, <guilabel>Database</guilabel>, <guilabel>Username</guilabel> 
            and <guilabel>Password</guilabel>.</para>
            <warning>
              <para>Saving to <acronym>mysql</acronym> or <acronym>postgres</acronym> requires the proper permissions in that 
              database, that is you need to have the permissions to create a new database with the given database name, or 
              you need to have write access to an existing database with the given database name.</para>
            </warning>
          </listitem>
        </itemizedlist>
      </listitem>

      <listitem>
        <para>Click the <guibutton>Save As</guibutton> button to save the
        file.</para>
      </listitem>
    </orderedlist>

    <para>If you are keeping track of finances for a single household, you
    need only one file. But if you are also tracking business finances or want
    to keep data separate for some reason, then you will need more than one
    file.</para>

    <para>Before ending each <application>&app;</application> session, be sure to save your data
    changes using <menuchoice><guimenu>File</guimenu>
    <guimenuitem>Save</guimenuitem></menuchoice> or the <guibutton>Save</guibutton> <emphasis>Toolbar</emphasis>
    button.
    <note>
        <para>As it is very important to save your data frequently to avoid losing them for whatever reason,
        <application>&app;</application> is able to automatically save the opened file every a certain amount of time.
        This interval can be set in the <guilabel>General</guilabel> tab under 
        <menuchoice><guimenu>Edit</guimenu><guimenuitem>Preferences</guimenuitem></menuchoice>
        (<menuchoice><guimenu>Gnucash</guimenu><guimenuitem>Preferences</guimenuitem></menuchoice> on Mac OS X).
        Keep in mind that this option is relevant only if you are saving in <acronym>XML</acronym> format.
        If you are working with a database, the <guibutton>Save</guibutton> button and the <guimenuitem>Save</guimenuitem>
        menu entry will be grayed out because changes are stored right away.</para>
    </note>
    </para>
    </sect2>
    
    <sect2 id="basics-open-data">
    <title>Opening data</title>
    <para>To open an existing file or database, select <menuchoice><guimenu>File</guimenu>
    <guimenuitem>Open</guimenuitem></menuchoice> from the menu. In the window that will open,
    select the <guilabel>Data Format</guilabel>. If you selected <guilabel>File</guilabel> choose the file you want to open
    by browsing the folders in the lower panes. Else, enter the required <guilabel>Database Connection</guilabel> 
    information.</para>
    <tip>
      <para><application>&app;</application> keeps a list of the recently opened files. Open the <guilabel>File</guilabel>
      menu and you will see listed the names of recently opened files. Click on the one you want to load to open it.</para>
    </tip>
    </sect2>

  </sect1>

  <sect1 id="basics-backup1">
    <title>Backing Up and Recovering Data</title>

    <para><application>&app;</application> creates several types of files to help ensure that your data
    is not lost. If you look in the folder where your saved <filename>.gnucash</filename> file resides, you may see other
    files generated by <application>&app;</application> with the following extensions: <filename>.gnucash</filename>,
    <filename>.log</filename>, <filename>.LCK</filename>, <filename>.LNK</filename> in the same directory 
    as your primary data file. What each of these files does is presented below.</para>
    
    <note>
    <para>The following sections are relevant only if you are saving your financial data in the <acronym>XML</acronym> format</para>
    </note>
 
    <programlisting>
      $ ls 
      myfile.gnucash
      myfile.gnucash.20100414185747.gnucash
      myfile.gnucash.20100414223248.log
      myfile.gnucash.20100415114340.gnucash
      myfile.gnucash.20100415154508.log
      myfile.gnucash.20100415173322.gnucash
      myfile.gnucash.20100415194251.log
      myfile.gnucash.7f0982.12093.LNK
      myfile.gnucash.LCK
    </programlisting>

    <sect2 id="basics-backupxac2">
      <title>Backup file (.gnucash)</title>

      <para>Each time you save your data file, a backup copy will also be
      saved with the extension <filename>.YYYYMMDDHHMMSS.gnucash</filename>. This backup file is a complete copy of
      your previous data file, and the filename format refers to the data
      file, year, month, day and time of the backup. For example, the filename
      <filename>myfile.gnucash.20100414185747.gnucash</filename> indicates this is a
      backup copy of the file <filename>myfile</filename> saved in the year 
      2010, April 14, at 6:57:47 p.m.</para>

      <para>To restore an old backup file, simply open the <filename>.YYYYMMDDHHMMSS.gnucash</filename> file with the
      date to which you wish to return. Be sure to save this file under a
      different name.</para>
      
      <note>
       <para><application>&app;</application> versions 2.3.15 and older create backup files with the old extension
         <filename>.YYYYMMDDHHMMSS.xac</filename> instead of the actual extension <filename>.YYYYMMDDHHMMSS.gnucash</filename>. 
         So if you upgrade from the 2.2 series to the 2.4 series, you may end up with both <filename>.YYYYMMDDHHMMSS.xac</filename> 
         and <filename>.YYYYMMDDHHMMSS.gnucash</filename> backup files in your directory.</para>
      </note>
    </sect2>

    <sect2 id="basics-backuplog2">
      <title>Log file (.log)</title>

      <para>Each time you open a file in <application>&app;</application>, a <filename>.log</filename> file is created and saved
      with the same name format as the <filename>.YYYYMMDDHHMMSS.gnucash</filename> backup files. As you make changes
      to the open data file, the log file saves only those changes. Log files
      are not a full backup of your data file - they simply record changes you
      have made to the data file in the current <application>&app;</application> session.</para>

      <para>In case you exit <application>&app;</application> inadvertently, possibly due to a power
      outage or a system wide crash, it is possible to recover most of your
      work since the last time you saved your <application>&app;</application> file using this log
      file. This is the procedure:</para>

      <orderedlist>
        <listitem>
          <para>Open the last saved <application>&app;</application> file.</para>
        </listitem>

        <listitem>
          <para>Go to <menuchoice><guimenu>File</guimenu><guisubmenu>Import</guisubmenu> 
          <guimenuitem>Replay &app; .log file</guimenuitem></menuchoice>
          and select the one .log file with the same date as the saved file
          you just opened. Make sure that you picked the right .log file, or
          you will possibly wreak havoc in your accounts.</para>
        </listitem>
      </orderedlist>

      <para>Log replaying will recover any transaction affecting the balance
      entered since the last save, including those created from scheduled
      transactions and business features (invoices, bills, etc.).</para>

      <warning>
        <para>Changes to the scheduled transactions, invoices or
        bills themselves are NOT recovered, and their transactions that were
        recovered may not be properly associated with them, and should thus be
        double-checked. Especially for business transactions, you may have to
        delete and re-create some of them. If you do not, although the balance
        will be correct, some reports may not.</para>
      </warning>
    </sect2>

    <sect2 id="basics-backuplock2">
      <title>Lock files (.LNK and .LCK)</title>

      <para>You may occasionally see <filename>.LNK</filename> and <filename>.LCK</filename> files appear. These do not
      store any data, but they are created to prevent more than one user from
      opening the same file at the same time. These files are automatically
      created when you open the file, to lock it so no one else can access it.
      When you close your <application>&app;</application> session or open another file, <application>&app;</application>
      unlocks the first data file by deleting the <filename>.LCK</filename> and <filename>.LNK</filename> files.</para>

      <para>If <application>&app;</application> crashes while you have a data file open, the <filename>.LCK</filename> and
      <filename>.LNK</filename> files are not deleted. The next time you try to open <application>&app;</application>, you
      will get a warning message that the file is locked. The warning message
      appears because the <filename>.LNK</filename> and <filename>.LCK</filename> files are still in your directory. It is
      safe to choose <guibutton>Yes</guibutton> to open the file, but you should delete the <filename>.LNK</filename> and
      <filename>.LCK</filename> files (using a terminal window or your file manager). Once those
      files are deleted, you will not get the warning message again unless
      <application>&app;</application> crashes.</para>
    </sect2>

    <sect2 id="basics-backupmanage2">
      <title>File Management</title>

      <para>So which files should you keep around? Keep your main data file,
      of course. It&rsquo;s a
      good idea to keep some of the more recent <filename>.YYYYMMDDHHMMSS.gnucash</filename> backup files, but you can safely
      delete the <filename>.log</filename> files since they are not complete copies of your data.</para>

      <note>
        <para>If you upgraded from a <application>&app;</application> version prior to 2.4, you may also have backup files
        in the old <filename>.xac</filename> format. For these files you can apply the same principle described above for
        <filename>.YYYYMMDDHHMMSS.gnucash</filename> backup files.</para>
      </note>

      <para>You should also delete any <filename>.LCK</filename> and <filename>.LNK</filename> files that you see after
      closing <application>&app;</application>. If you decide to back up your data file to another
      disk manually, it&rsquo;s enough to back up the main data file - not the <filename>.YYYYMMDDHHMMSS.gnucash</filename>
      backup files.</para>

      <note>
        <para>By default <application>&app;</application> will automatically delete any <filename>.log</filename> and <filename>.YYYYMMDDHHMMSS.gnucash</filename>
        backup files that are older than 30 days. You can change this behavior in the <application>&app;</application>
        preferences in the <guilabel>General</guilabel> tab under <menuchoice><guimenu>Edit</guimenu>
        <guimenuitem>Preferences</guimenuitem></menuchoice>
        (<menuchoice><guimenu>Gnucash</guimenu><guimenuitem>Preferences</guimenuitem></menuchoice> on Mac OS X).</para>
      </note>
      
    </sect2>
  </sect1>

  <sect1 id="basics-together1">
    <title>Putting It All Together</title>

    <note>
      <para>This section begins a tutorial that will continue throughout this
      book. At the end of each chapter, you will see a <guilabel>Putting It
      All Together</guilabel> section that walks you through examples to
      illustrate concepts discussed in that section. Each <guilabel>Putting It
      All Together</guilabel> section builds on the previous one, so be sure
      to save your file for easy access.</para>
    </note>

    <para>Let&rsquo;s get started!</para>

    <orderedlist>
      <listitem>
        <para>First, let&rsquo;s create a file to store your real data. Open <application>&app;</application>
        and select <menuchoice><guimenu>File</guimenu><guimenuitem>New File</guimenuitem></menuchoice>
        from the <emphasis>Menubar</emphasis>. This will start the <guilabel>New Account Hierarchy Setup</guilabel> assistant that allows
        you to create several accounts at once.</para>
        <note>
          <para>If you are running <application>&app;</application> for the first time, you will be presented with the
          <guilabel>Cannot find default values</guilabel> screen which is described in details in the 
          <application>&app;</application> manual.</para>
        </note>

      <screenshot id="basics-NewAccountHierarchySetup">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup.png"
                       format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
          </imageobject>

          <imageobject role="fo">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup.png"
                       format="PNG" srccredit="Cristian Marchi" ></imagedata>
          </imageobject>
        
          <textobject>
            <phrase>The New Account Hierarchy Setup assistant</phrase>
          </textobject>

          <caption>
            <para>This image shows the first screen of the <guilabel>New
            Account Hierarchy Setup</guilabel> assistant.</para>
          </caption>
        </mediaobject>
      </screenshot>
      
      <para>The first screen of the assistant gives you a description of what the assistant does.
      Click the <guibutton>Forward</guibutton> button to proceed to the next screen.</para>
    </listitem>

    <listitem>
      <para>In the second screen, select the currency to use for the new accounts from the dropdown list.
      Then press the <guibutton>Forward</guibutton> button.</para>
      <note>
        <para>The currency you select here, will be assigned to all the
        <guilabel>accounts</guilabel> created in this assistant.</para>
      </note>
      
      <screenshot id="basics-NewAccountHierarchySetup-currency">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_currency.png"
                       format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
          </imageobject>

          <imageobject role="fo">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_currency.png"
                       format="PNG" srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The New Account Hierarchy Setup assistant - Currency</phrase>
          </textobject>

          <caption>
            <para>This image shows the second screen of the <guilabel>New
            Account Hierarchy Setup</guilabel> assistant where you select the
            currency.</para>
          </caption>
        </mediaobject>
      </screenshot>
    </listitem>

    <listitem>
      <para>In the third screen select the <guilabel>Common Accounts</guilabel> group in the 
      <guilabel>Categories</guilabel> pane. Then press the <guibutton>Forward</guibutton> button to
      proceed.</para>
      <note>
        <para>If you want, you can select one or more of the predefined account-groups here. For more
        information on account types, see <xref linkend="accts-types1"></xref>.</para>
      </note>

      <screenshot id="basics-NewAccountHierarchySetup-Accounts">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Accounts.png"
                       format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
          </imageobject>

          <imageobject role="fo">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Accounts.png"
                       format="PNG" srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The New Account Hierarchy Setup assistant - Choose
            accounts</phrase>
          </textobject>

          <caption>
            <para>This image shows the third screen of the <guilabel>New
            Account Hierarchy Setup</guilabel> assistant where you choose the
            various accounts.</para>
          </caption>
        </mediaobject>
      </screenshot>
    </listitem> 

    <listitem>
      <para>In the fourth screen you will be able to set an <guilabel>Opening
      Balance</guilabel> on each of the accounts, as well as indicate if
      the account should be a <guilabel>Placeholder</guilabel>. As these features will be 
      described in next chapters, leave all as configured by <application>&app;</application> 
      and click <guibutton>Forward</guibutton> to open the last screen of the assistant.</para>
      
      <screenshot id="basics-NewAccountHierarchySetup-Setup.png">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Setup.png"
                       format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
          </imageobject>

          <imageobject role="fo">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Setup.png"
                       format="PNG" srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The New Account Hierarchy Setup assistant - Configure</phrase>
          </textobject>

          <caption>
            <para>This image shows the fourth screen of the <guilabel>New
            Account Hierarchy Setup</guilabel> assistant where you can set
            <guilabel>Opening Balance</guilabel>.</para>
          </caption>
        </mediaobject>
      </screenshot>
    </listitem>

    <listitem>
      <para>In the last screen of the assistant, click <guibutton>Apply</guibutton> to create all the accounts and
      leave the assistant.</para>

      <screenshot id="basics-NewAccountHierarchySetup-Finish">
        <mediaobject>
          <imageobject role="html">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Finish.png"
                       format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
          </imageobject>

          <imageobject role="fo">
            <imagedata fileref="figures/basics_NewAccountHierarchySetup_Finish.png"
                       format="PNG" srccredit="Cristian Marchi" ></imagedata>
          </imageobject>

          <textobject>
            <phrase>The New Account Hierarchy Setup assistant - Finish</phrase>
          </textobject>

          <caption>
            <para>This image shows the last screen of the <guilabel>New
            Account Hierarchy Setup</guilabel> assistant.</para>
          </caption>
        </mediaobject>
      </screenshot>
    </listitem>

    <listitem>
        <para>Your main window should now look something like this:</para>

          <screenshot id="basics-EmptyAccounts">
            <mediaobject>
              <imageobject role="html">
                <imagedata fileref="figures/basics_EmptyAccounts.png"
                           format="PNG" srccredit="Cristian Marchi" width="510"></imagedata>
              </imageobject>
              
              <imageobject role="fo">
                <imagedata fileref="figures/basics_EmptyAccounts.png"
                           format="PNG" srccredit="Cristian Marchi" ></imagedata>
              </imageobject>

              <textobject>
                <phrase>The Main window showing the test file</phrase>
              </textobject>
            </mediaobject>
          </screenshot>
        
        <para>Next, create a file to store test data. This is the file that
        will be used in the tutorials throughout this manual. Click
        <menuchoice><guimenu>File</guimenu><guimenuitem>Save As...</guimenuitem></menuchoice> (or press 
        <keycombo><keycap>Shift</keycap><keycap>Ctrl</keycap><keycap>S</keycap></keycombo> on your keyboard)
        to open the <guilabel>Save As...</guilabel> dialog. Select <emphasis>XML</emphasis> as data
        format, name the file <filename>gcashdata_1</filename> and select the folder where 
        the file will be saved.</para>
    </listitem>
    
  </orderedlist>
    
  </sect1>
</chapter>
