<!--
      (Do not remove this comment block.)
  Version: 2.0.0
  Last modified: July 9th 2006
  Maintainers: 
               Chris Lyttle <chris@wilddev.net>
  Author:
  		Jon Lapham <lapham@extracta.com.br>
  	Updated	Bengt Thuree <bengt@thuree.com>
  Originally designed by Carol Champagne.
  Translators:
               (translators put your name and email here)
-->
<chapter id="chapter10">
  <title>Multiple Currencies</title>

  <para>This chapter will show you how to setup your GnuCash accounts to use
  multiple currencies.</para>

  <sect1 id="currency_concepts1">
    <title>Basic Concepts</title>

    <para>GnuCash supports the use of multiple currencies in different
    accounts. For example, you can have a bank account setup in Euros, and
    another using Hong Kong Dollars.</para>

    <para>Some of the issues which arise when using multiple currencies is how
    do you transfer funds between accounts with different currencies? How do
    you calculate the overall value when you have mized currency accounts? How
    do reports deal with mixed currencies?</para>
  </sect1>

  <sect1 id="currency_acct1">
    <title>Account Setup</title>

    <para>Your default account currency is set in <guimenu>Edit</guimenu>
    -&gt; <guimenu>Preferences</guimenu> -&gt; <guimenu>Accounts</guimenu>
    -&gt; <guilabel>Default Currency</guilabel>. You should set this parameter
    correctly, as it will save you much time when building your account
    structure.</para>

    <para>When you create a new account, you have the option to define the
    commodity. For currency accounts, you can specify any one of the hundreds
    of currencies supported by GnuCash by simply selecting it from the
    currency commodity list. You will notice that the default currency is
    always whatever you have defined in the preferences. So, if you mostly
    work with Euros, but have the occasional Ethiopian Birr account, be sure
    to set your preferences to Euro.</para>

    <para>As an example, let's set up a typical bank account scenario where
    you mostly work in US Dollars, but do also have a European bank account
    using the Euro currency, as well as one bank account in Hong Kong using
    Hong Kong Dollars. So, setup 3 bank accounts, one using the Euro currency,
    one in US Dollars, and another in Hong Kong Dollars. One possible account
    structure for this would be:</para>

    <literallayout>
-Assets                          (USD)
   -Current Assets           (USD)
      -US Bank                 (USD)
      -European Bank       (EUR)
      -HK Bank             (HKD)
-Equity                          (USD)
   -Opening Balances
      -USD            (USD)
      -EUR            (EUR)   
      -EUR            (HKD)

Note: the currency of each account is shown in parenthesis.
 </literallayout>

    <para>Since in this example you mostly work in USD, all of the parent
    accounts are set to USD. Of course, if you mostly work in Euros, you could
    change the currency of these parent accounts to EUR. To totals shown in
    the account tree window will always be converted to the currency of each
    particular account. Notice, we also setup 3 Starting Balances equity
    accounts, used to initially populate the 3 banks.</para>

    <note>
      <para>You could also setup just a single Starting Balance account and
      use a currency transfer to populate the "different currency" accounts.
      However, this is more advanced option, which is explained in a later
      section (<xref linkend="currency_purchase2" />.</para>
    </note>

    <para>Below you see the result of this example, in which you start with
    USD 10,000, EUR 10,000 as well as HKD 10,000 in the three bank accounts.
    Notice that the total of the parent accounts only show the value of the
    currency of subaccounts with matching currencies. In the future you can
    setup the exchange rates between the currencies, and the parent accounts
    will calculate the converted value of all subaccounts. See the later
    section (<xref linkend="currency_howto1" />) on how to do this.</para>

    <screenshot id="currency_main1">
      <mediaobject>
        <imageobject>
          <imagedata fileref="figures/currency_main1.png" format="PNG"
                     srccredit="Bengt Thuree" />
        </imageobject>

        <textobject>
          <phrase>Initial multi currency Account Bank Setup</phrase>
        </textobject>

        <caption><para>Initial setup of 3 bank accounts with different
        currencies. </para></caption>
      </mediaobject>
    </screenshot>

    <para>Notice that the "Total (Report)" column is being displayed. This is
    configured in the column header row, select <guibutton>Arrow
    down</guibutton> and select <quote>Total(USD)</quote>.</para>
  </sect1>

  <sect1 id="currency_support1">
    <title>GnuCash Currency Support</title>

    <para>GnuCash supports over a hundred currencies, from the Andorran Franc
    to the Zimbabwe Dollar. You will also find supports for some lesser
    popular currencies like the US Dollar, Canadian Dollar, European Euro, and
    British Pound.</para>
  </sect1>

  <sect1 id="currency_prefs1">
    <title>Setting International Preferences</title>

    <para>GnuCash allows you to specify the following international related
    preferences</para>

    <itemizedlist>
      <listitem>
        <para>Default currency you want the newly created registers to
        have</para>
      </listitem>

      <listitem>
        <para>Default currency for the reports</para>
      </listitem>

      <listitem>
        <para>Date and Time formats</para>
      </listitem>

      <listitem>
        <para>Euro support</para>
      </listitem>
    </itemizedlist>

    <para>For a full explanation of the International Preferences available,
    see <xref linkend="basics-prefs1" /></para>
  </sect1>

  <sect1 id="currency_howto1">
    <title>Recording/Updating Currency Exchange (How-To)</title>

    <para>GnuCash allows you to update the Currency Exchange Rates in two
    different ways, manual and automatic. In the following two sections we
    will work through both ways.</para>

    <para>Before we start, lets have a quick look at the Chart of
    Accounts</para>

    <screenshot id="currency_main1a">
      <mediaobject>
        <imageobject>
          <imagedata fileref="figures/currency_main1.png" format="PNG"
                     srccredit="Bengt Thuree" />
        </imageobject>

        <textobject>
          <phrase>Initial multi currency Account Bank Setup</phrase>
        </textobject>

        <caption><para>Initial setup of 3 bank accounts with different
        currencies. </para></caption>
      </mediaobject>
    </screenshot>

    <sect2 id="currency_howto_Manual">
      <title>Manually Updating Exchange Rates</title>

      <para>Open the Price Editor by going to <guimenu>Tools</guimenu> -&gt;
      <guimenu>Price Editor</guimenu>.</para>

      <screenshot id="currency_BeforeGetOnlineQuotes">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_BeforeGetOnlineQuotes.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Price Editor window</phrase>
          </textobject>

          <caption><para>Price Editor Window. </para></caption>
        </mediaobject>
      </screenshot>

      <para>Click on the <guibutton>Add</guibutton> button to add a new
      currency exchange. A window will appear to allow you to select the
      commodity you wish to define the exchange rate for. Click on
      <guibutton>Select</guibutton> and set the <guilabel>Type</guilabel> to
      Currency and the <guilabel>Currency/security</guilabel> to EUR (Euro).
      This window should appear like this:</para>

      <screenshot id="currency_selectcurr">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_selectcurr.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Select Euro Commodity</phrase>
          </textobject>

          <caption><para>Price Editor Select Commodity Window</para></caption>
        </mediaobject>
      </screenshot>

      <para>Click <guibutton>Ok</guibutton> and in the Select Commodity
      window, set the exchange rate between the selected commodity and the
      selected currency. In this example, you will set the exchange rate to 1
      EUR to 1 USD.</para>

      <screenshot id="currency_selectcomm">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_selectcomm.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Select Commodity</phrase>
          </textobject>

          <caption><para>Price Editor Select Commodity Window</para></caption>
        </mediaobject>
      </screenshot>

      <screenshot id="currency_peditor">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_peditor.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Price Editor Window</phrase>
          </textobject>

          <caption><para>The Price Editor window after setting the exchange
          rate between Euros and US Dollars</para></caption>
        </mediaobject>
      </screenshot>

      <screenshot id="currency_main2">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_main2.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart of Accounts</phrase>
          </textobject>

          <caption><para>Chart of Accounts after setting the exchange rate
          between Euros and US Dollars.</para></caption>
        </mediaobject>
      </screenshot>

      <para>Observe that since you have no exchange rate for HKD, GnuCash do
      not convert the HKD accounts to USD. This will be added in the next
      section.</para>
    </sect2>

    <sect2 id="currency_howto_Auto">
      <title>Automatic Updating Exchange Rates (How-To)</title>

      <para>In the previous section you saw how you could manually define a
      new currency exchange rate, but there must be an easier way to do it.
      And there is.</para>

      <para>Open the Price Editor by going to <guimenu>Tools</guimenu> -&gt;
      <guimenu>Price Editor</guimenu>.</para>

      <screenshot id="currency_BeforeGetOnline">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_peditor.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Price Editor window</phrase>
          </textobject>

          <caption><para>Price Editor Window before you obtain online quotes.
          </para></caption>
        </mediaobject>
      </screenshot>

      <para>Click on the <guibutton>Get Quotes</guibutton> button to
      automatically load the various exchange rates you need.</para>

      <note><para>
         If the <guibutton>Get Quotes</guibutton> button is disabled, 
         that means that the perl module Finance::Quote is not installed. 
         For information on how to install it, please see 
         <xref linkend="invest-stockprice-auto2" ></xref>
      </para></note>

      <para><screenshot id="currency_AfterGetOnlineQuotes">
          <mediaobject>
            <imageobject>
              <imagedata fileref="figures/currency_AfterGetOnlineQuotes.png"
                         format="PNG" srccredit="Bengt Thuree" />
            </imageobject>

            <textobject>
              <phrase>Price Editor window</phrase>
            </textobject>

            <caption><para>Price Editor Window after we obtained online
            quotes. </para></caption>
          </mediaobject>
        </screenshot></para>

      <para>You noticed that GnuCash will download exchange rates for all
      currencies you are using in your various accounts. This will happend
      everytime you click on <guibutton>Get Quotes</guibutton> or have GnuCash
      downloading quotes/exchange rates automatically as per <xref
      linkend="invest-stockprice-auto2" /></para>

      <para>And if you check the main Chart of Accounts you now see that
      GnuCash has automatically converted the HKD amount to USD amount on the
      parent accounts that are in USD, as well as on the Total (USD) column.
      Also the Euro accounts have been been updated with the latest exchange
      rate.</para>

      <screenshot id="currency_main3.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_main3.png" format="PNG"
                       srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Price Editor window</phrase>
          </textobject>

          <caption><para> Chart of Accounts after we obtain online quotes.
          </para></caption>
        </mediaobject>
      </screenshot>
    </sect2>
    <sect2 id="currency_howto_disable">
      <title>How to disable currency retrieval</title>
      <para>Currency Quote retrieval will start from the time you create an account 
      with a non-default currency. However, it will not stop when you delete these accounts 
      from GnuCash.</para>
      <para>
        When you have deleted the last account for one particular currency, 
        and you do not wish to get currency updates for this currency anymore. Do the following;
      </para>
      <itemizedlist>
        <listitem>
          <para><guimenu>Tools</guimenu> -&gt; <guimenu>Price Editor</guimenu></para>
        </listitem>
        <listitem>
          <para>Expand the CURRENCY row</para>
        </listitem>
        <listitem>
          <para>Double click on the Currency you want to disable Exchange Rate retrieval for.</para>
        </listitem>
        <listitem>
          <para>Unselect the <guilabel>Get Online Quotes</guilabel></para>
        </listitem>
      </itemizedlist>
    </sect2>

  </sect1>

  <sect1 id="currency_purchase1">
    <title>Recording Purchases in a Foreign Currency (How-To)</title>

    <para>You can do it in two different ways.</para>

    <para>1) Use GnuCash build in currency exchange between accounts when you
    do your transactions. This is mainly used for one time transactions, and
    nothing which happens regurarly.</para>

    <para>2) Use separate accounts for this Purchase, where all involved
    accounts use the same currency. This is the recommended method, since it
    allows much better tracking and follow up. In this way, you do one
    currency exchange transaction, and after that you do normal
    transactions.</para>

    <para>The rest of this section will explain more based upon option
    2)</para>

    <sect2 id="currency_purchase2">
      <title>Purchase of an asset with foreign currency</title>

      <para>Your normal place of residence is in Florida, therefore you are
      using USD as your default currency. But, you do like to travel to
      Bahamas and go fishing. You like it so much so you decided to purchase a
      boat there. To do this, you opened a bank account in Jamaica, moved some
      money from US, and then purchased your dream boat (smallest
      version)</para>

      <para>To record this in GnuCash we use the following basic account
      structure</para>

      <literallayout>
-Assets                          (USD)
   -Current Assets           (USD)
      -US Bank                 (USD)
      -Jamaican Bank       (JMD)
   -Fixed Assets           (USD)
      -Boat                (JMD)
-Equity                          (USD)
   -Opening Balances
      -USD            (USD)

Note: the currency of each account is shown in parenthesis.
 </literallayout>

      <para>First you need to transfere some money ($10,000) to Jamaica, and
      you use your normal US bank account (whith balance of $100,000) for
      that. The bank give you an exchange rate of USD 1 = JMD 64, but charges
      you USD 150 to do transfer the money.</para>

      <screenshot id="currency_purchase_MoveMoney.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_MoveMoney.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Currency transfer</phrase>
          </textobject>

          <caption><para>Transfer money to Jamaica</para></caption>
        </mediaobject>
      </screenshot>

      <para>Select the Jamaica transaction line ($9,850.00), right click and
      select <guilabel>Edit Exchange Rate</guilabel></para>

      <screenshot id="currency_purchase_SetExchangeRate.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_SetExchangeRate.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Edit Exchange rate</phrase>
          </textobject>

          <caption><para>A dialog window where the exchange rate in a currency
          transaction is specified</para></caption>
        </mediaobject>
      </screenshot>

      <para>As Exchange Rate you enter 1 USD = 64 JMD, since this is the rate
      your bank gave. Press ok in the Transfer Funds (Edit Exchange Rate)
      window, and then save this split transaction. Below is how it now looks
      in the main Chart of Accounts.</para>

      <screenshot id="currency_purchase_BeforeBoat.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_BeforeBoat.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart of Accounts before purchasing the boat</phrase>
          </textobject>

          <caption><para>Chart of Accounts before purchasing the
          boat</para></caption>
        </mediaobject>
      </screenshot>

      <para>You find the boat, and since it's a bargain at JMD 509,000 you
      decide to buy it. To record this transaction in GnuCash, you will need
      to enter a simple transaction in Assets:Current Assets:Jamaican Bank
      withdrawing 509,000 and transfering it to Assets:Fixed
      Assets:Boat</para>

      <screenshot id="currency_purchase_AfterBoat.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_AfterBoat.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart of Accounts after purchasing the boat</phrase>
          </textobject>

          <caption><para>Chart of Accounts after purchasing the
          boat</para></caption>
        </mediaobject>
      </screenshot>
      <para>The Chart of Accounts now reflects that your bank account has been 
      reduced with the value of the boat (JMD 509,000), and that your Fixed Assets
      boat account has been increased with the same amount. If you also have turned
      on the CoA (Column Choice) "Total (USD)" you will see the corresponding
      value in USD. The USD value will always reflect the latest currency exchange
      rate you have either automatically or manually updated GnuCash with.
      </para>
    </sect2>

    <sect2 id="currency_purchase3">
      <title>Purchasing foreign stocks</title>

      <para>A more complicated example</para>

      <para>This example will show how to deal with having stocks in a
      different currency than your normal currency.</para>

      <para>In this example you live in America and therefore you have set the
      default Currency to USD. You decide to purchase some stocks in Hong Kong.
      </para>

      <para>You would also like to be able to track the various income and
      expenses per stock and broker.</para>

      <para>The stock you want to purchase are Beijing Airport (Hong Kong)
      (Afterall the 2008 Olympics in Beijing should bring in a lot of business
      to the airport)</para>

      <note><para>
         The above stock (Beijing Airport) are just choosen
         for this particular example, and should not be taken as any kind of 
         stock purchase advice 
      </para></note>

      <para>You need to find out what the stock ticker is for this 
      stock. To do this, you do a bit of investigation on the Internet, and
      in particular on <ulink
      url="http://finance.yahoo.com/lookup"><citetitle>Yahoo! Finance - Ticker
      Symbol Lookup</citetitle></ulink> (http://finance.yahoo.com/lookup).
      This gives you the following:</para>

      <itemizedlist>
        <listitem>
          <para><emphasis>Beijing Airport</emphasis> has the Stock Symbol
          0694.HK at Yahoo</para>
        </listitem>
      </itemizedlist>
      
      <para>Since we wanted to be able to track all various incomes and expenses,
      we come up with the following Account structure</para>

      <literallayout>
Assets:Investments:Brokerage Accounts:Boom:0694.HK     (Beijing Airport)
Assets:Investments:Brokerage Accounts:Boom:Bank        (HKD)
Equity:Opening Balances:HKD                            (HKD)
Expenses:Commissions:Boom.0694.HK                      (HKD)
Income:Investments:Dividend:Boom:0694.HK               (HKD)
      </literallayout>
      
      <para>The Chart of Accounts looks like this after creating all the
      needed accounts</para>

      <screenshot id="currency_purchase_BeforeStocks.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_BeforeStocks.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart of Accounts for international stocks</phrase>
          </textobject>

          <caption><para>Chart of Accounts for international
          stocks</para></caption>
        </mediaobject>
      </screenshot>

      <para>The various commodities (<guimenu>Tools</guimenu> -&gt; 
      <guimenu>Security Editor</guimenu>) looks like this</para>

      <screenshot id="currency_purchase_Commodities.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_Commodities.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>International commodities</phrase>
          </textobject>

          <caption><para>International commodities</para></caption>
        </mediaobject>
      </screenshot>

      <note><para>
         There is currently a small bug ( 

        <ulink 
          url="http://bugzilla.gnome.org/show_bug.cgi?id=335101"><citetitle>335101</citetitle>
        </ulink>

         ) in GnuCash, that makes it impossible to buy a stock in a different currency than the default directly from the commodity account. The simple workaround is to open the associated bank account and enter the transaction from here. 
      </para></note>

      <para>If you have not moved some cash (HKD50,000) to the corresponding stocks bank
      account, do so now. Either using the Equity (HKD) account, or by transfering
      money from an existing bank account (Currency Transfer).</para>

      <para>To record this stock purchase, you have to open the stocks associated
      bank account (Assets:Investments:Brokerage Account:Boom:Bank), and there enter
      the following information</para>
<literallayout>
Buy Stocks 
	Assets:Investments:Brokerage Account:Boom:Bank  Withdrawal 50,000
	Expenses:Investments:Commission:Boom_HKD	Deposit 500
	Assets:Investments:Brokerage Account:Boom:0694  Deposit 49,500 (16,500 shares)
    </literallayout>

      <para>If the "Exchange Data" dialog popup do not appear, open it
      manually by right click on the last row, and select <guilabel>Edit
      Exchange Rate</guilabel> In the following pop up window, enter the
      actual number of stocks (16,500) as the <guilabel>To Amount:</guilabel> 
      </para>
      
      <screenshot id="currency_purchase_ToAmount.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_ToAmount.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Transfer Funds</phrase>
          </textobject>

          <caption><para>Setting To Amount in the Transfer Funds dialog</para></caption>
        </mediaobject>
      </screenshot>

      <para>When you exit the exchange dialog, and Enter this transaction GnuCash will 
      update the stock purchase transaction with all relevant data.</para>
    
      <para>If you now go back to the main Chart of Accounts, you will see something like
      this</para>
      
      <screenshot id="currency_purchase_AfterStocks.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_purchase_AfterStocks.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Purchased international stocks</phrase>
          </textobject>
          <caption><para>
            Chart of Accounts with some international stocks
          </para></caption>
        </mediaobject>
      </screenshot>

      <para>As you can see, everything is in its own Currency, and this is because GnuCash
      do not have any exchange rates between USD and HKD. To remedy this go to
      <guimenu>Tools</guimenu> -&gt; <guimenu>Price Editor</guimenu>
      and click on the <guibutton>Get Quotes</guibutton> button to
      automatically load the various exchange rates you need.</para>

    </sect2>
    
  </sect1>

  <sect1 id="currency_invest1">
    <title>Tracking Currency Investments (How-To)</title>

    <para>Currency investment is when you decide to invest in different
    countries currency, and hope that their currency will raise in value
    relative your own currency.</para>

    <para>When you enter these transactions into GnuCash, you will have to
    decide on how much details you would like to have.</para>

    <para>If you are not interested in details at all, a very simple account
    structure would be enough. Something like this;</para>

    <literallayout>
    Assets:Investments:Currency:Bank (USD)
    Assets:Investments:Currency:XXX (XXX)</literallayout>

    <para>But, if you do want to be able to track the Capital Gains or Losses,
    as well as the various fees, you do need a bit more complexed layout.
    Something like this;</para>

    <literallayout>
    Assets:Investments:Currency:Bank                    (USD)
    Assets:Investments:Currency:Currency Bank:XXX       (XXX)
    Expenses:Investments:Currency:Currency Bank:XXX     (XXX)
    Income:Investments:Currency Bank:Capital Gains:XXX  (XXX)</literallayout>

    <para>Where XXX is the currency you are investing in.</para>

    <note><para>
       There is currently (30 April 2006) a small bug ( 
       <ulink url="http://bugzilla.gnome.org/show_bug.cgi?id=340041"><citetitle>340041</citetitle>
       </ulink>) in GnuCash, that makes it impossible to track currency investments 
       capital gains. 
    </para></note>

    <sect2 id="currency_invest12">
      <title>Purchasing a currency investment</title>

      <para>A typical purchase order might be something like this, seen from
      the Assets:Investments:Currency:Bank.</para>

      <para><table>
          <title>Buying a currency with a Split Transaction Scheme</title>

          <tgroup cols="3">
            <tbody>
              <row>
                <entry><emphasis>Account</emphasis></entry>

                <entry><emphasis>Deposit</emphasis></entry>

                <entry><emphasis>Withdrawal</emphasis></entry>
              </row>

              <row>
                <entry>Assets:Investments:Currency:Bank</entry>

                <entry></entry>

                <entry>Invested Amount</entry>
              </row>

              <row>
                <entry>Expenses:Investments:Currency:Currency Bank:XXX</entry>

                <entry>Exchange Fee</entry>

                <entry></entry>
              </row>

              <row>
                <entry>Assets:Investments:Currency:XXX</entry>

                <entry>Invested Amount - Exchange Fee</entry>

                <entry></entry>
              </row>
            </tbody>
          </tgroup>
        </table>You should get an Exchange Rate window popping up when you
      leave the last row in the split above (Currency Transaction). If this
      window do not pop up, right click on the row, and select <guilabel>Edit
      Exchange Rate</guilabel>. In the Exchange Rate window you specify the
      exchange rate you got from the bank.</para>
    </sect2>

    <sect2 id="currency_invest13">
      <title>Selling a currency investment</title>

      <para>Entering an currency you are selling is done in the same way as
      buying one except the you are now transfering money from the Currency
      account to your Savings account (very much similar to (<xref
      linkend="invest-sell1" />).</para>

      <para>The proper recording of the currency sale *must* be done using a
      split transaction. In the split transaction, you must account for the
      profit (or loss) as coming from an Income:Capital Gains account (or
      Expense:Capital Loss). To balance this income, you will need to enter
      the Currency asset twice in the split. Once to record the actual sale
      (using the correct amount and correct exchange rate) and once to balance
      the income profit (setting the amount to 0).</para>

      <para>In short, a selling Currency transaction should look something
      like below, seen again from the Assets:Investments:Currency:Bank.</para>

      <table>
        <title>Selling a currency with a Split Transaction Scheme</title>

        <tgroup cols="3">
          <tbody>
            <row>
              <entry><emphasis>Account</emphasis></entry>

              <entry><emphasis>Deposit</emphasis></entry>

              <entry><emphasis>Withdrawal</emphasis></entry>
            </row>

            <row>
              <entry>Assets:Investments:Currency:Bank</entry>

              <entry>Sold Amount - Exchange Fee</entry>

              <entry></entry>
            </row>

            <row>
              <entry>Expenses:Investments:Currency:Currency Bank:XXX</entry>

              <entry>Exchange Fee</entry>

              <entry></entry>
            </row>

            <row>
              <entry>Assets:Investments:Currency:XXX</entry>

              <entry></entry>

              <entry>Sold Amount</entry>
            </row>

            <row>
              <entry>Income:Investments:Currency Bank:Capital
              Gains:XXX</entry>

              <entry>[LOSS]</entry>

              <entry>PROFIT</entry>
            </row>

            <row>
              <entry>Assets:Investments:Currency:XXX</entry>

              <entry>PROFIT (with To Amount = 0)</entry>

              <entry>[LOSS (with To Amount = 0) ]</entry>
            </row>
          </tbody>
        </tgroup>
      </table>

      <note><para>
           There is currently (30 April 2006) a small bug ( 

          <ulink url="http://bugzilla.gnome.org/show_bug.cgi?id=340041"><citetitle>340041</citetitle>
          </ulink>

           ) in GnuCash, that makes it impossible to track currency investments capital gains. 
      </para></note>
    </sect2>
  </sect1>

  <sect1 id="currency_reconcile1">
    <title>Reconciling Statements in a Foreign Currency (How-To)</title>

    <para>Reconciling foreigh statement are done in the same manner as when
    you reconcile your local bank statement. If you have created a Chart of
    Accounts structure which allows you to have the same Currency per account
    as your Reconcile Statement, it is actually exactly the same as
    reconciling your local bank statement, apart from the fact you might need
    a dictionary</para>

    <para>If you have different currencies you might have to manually convert
    the amounts from one currency to another while you reconcile the
    accounts.</para>
  </sect1>

  <sect1 id="currency_examples1">
    <title>Putting It All Together (Examples)</title>

    <para>In this Putting It All Together you will use quite a bit of what you
    have learned so far in this guide with a bit of a twist. The twist beeing
    a lot of different currencies.</para>

    <sect2>
      <title>Basic scenario</title>

      <para>The following are the basic scenarios.</para>

      <itemizedlist>
        <listitem>
          <para>You live in Australia and use AUD as our default
          currency</para>
        </listitem>

        <listitem>
          <para>You win the lottery as well as inherit some money</para>
        </listitem>

        <listitem>
          <para>You pay of your existing house loan</para>
        </listitem>

        <listitem>
          <para>You purchase some stocks in Sweden using SEK (Ericsson
          B-Fria)</para>
        </listitem>

        <listitem>
          <para>You purchase some stocks in HK using HKD (Beijing
          Airport)</para>
        </listitem>

        <listitem>
          <para>You purchase some stocks in US using USD (Amazon)</para>
        </listitem>

        <!--
      <listitem>
        <para>You invest in Chinese Reminbi</para>
      </listitem>
-->

        <listitem>
          <para>You lend some EURO to a friend (Peter)</para>
        </listitem>

        <listitem>
          <para>You borrow some money from a Japanese bank</para>
        </listitem>

        <listitem>
          <para>You buy a house in New Zealand</para>
        </listitem>

        <listitem>
          <para>You use a credit card in Australia</para>
        </listitem>

        <listitem>
          <para>You would like to have maximum control of your expenses</para>
        </listitem>

      </itemizedlist>
      <note>
        <para>Again these samples are not to be consider a valid and
          accurate advice. They are only to be considered as an sample for
          the techniques used in GnuCash, and not as a Invenstment Advice.
          Please consult a proper financial advisor for more information
          regarding international investments/loans.</para>
        </note>


    </sect2>

    <sect2>
      <title>Configure Accounts</title>

      <para>This time lets start with a fresh and new GnuCash data file, so
      <guimenu>File</guimenu> -&gt; <guimenuitem>New</guimenuitem>, and edit
      preferences (<guimenu>Edit</guimenu> -&gt; <guimenuitem>Preferences</guimenuitem>) 
      to set Default Currency as AUD. Since you have
      decided to be able to track as much of your various expenses and incomes
      as possile, the following account hierarchy could be used;</para>

      <literallayout>
Assets:Current Assets:Savings Account         (AUD)
      </literallayout>

      <para></para>
    </sect2>


    <sect2>
      <title>Opening Balance</title>

      <para>You open the mail one morning, and to your enormous surprise find
      that you are the last living relative of a very distant relative who
      happend to be very rich. And also $500,000 AUD richer. That was not the
      last though, another mail states you won the lottery, and got $250,000
      AUD for that. </para>
      
      <para>To record these transaction we need the following accounts</para>
      <literallayout>
Equity:Lottery         (AUD)
Equity:Inheritance     (AUD)      
      </literallayout>


      <para>The transactions you enter into your <guilabel>Income:Current
      Assets:Savings Account</guilabel> should look like this.</para>

      <table>
          <title>You come into some extra money</title>

          <tgroup cols="3">
            <tbody>
              <row>
                <entry>Account</entry>

                <entry>Increase</entry>

                <entry>Decrease</entry>
              </row>

              <row>
                <entry>Income:Lottery</entry>

                <entry>$250,000</entry>

                <entry></entry>
              </row>

              <row>
                <entry>Income:Inheritance</entry>

                <entry>$500,000</entry>

                <entry></entry>
              </row>
            </tbody>
          </tgroup>
        </table>

      <para>And the Chart of Accounts looks like this after above transactions have been entered.</para>
      <screenshot id="currency_PutTogether_AfterMoney.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_PutTogether_AfterMoney.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart Of Accounts</phrase>
          </textobject>
          <caption><para>
            Chart Of Accounts after receiving some money
          </para></caption>
        </mediaobject>
      </screenshot>


    </sect2>
    
    <sect2>
      <title>Purchase a house</title>

      <para>Atlast you can afford to pay of that house loan you had to take some years ago 
      (with a $50,000 deposit).</para>

      <literallayout>
Assets:Fixed Assest:House                  (AUD) $300,000
Liabilities:Loans:Mortgage                 (AUD) $250,000
Expenses:Interest:Mortgage Interest        (AUD)
Equity:Opening Balance                     (AUD) $50,000
      </literallayout>

      <para>After you have had a small chat with your Mortgage bank, they
      agree to let you pay it all of in one go, plus some interest (AUD
      30,000). You should enter the following split transaction into
      <guilabel>Assets:Fixed Assest:House</guilabel> account.</para>

      <table>
          <title>Paying of the house mortgage</title>

          <tgroup cols="3">
            <tbody>
              <row>
                <entry>Account</entry>

                <entry>Increase</entry>

                <entry>Decrease</entry>
              </row>

              <row>
                <entry>Assets:Current Assets:Savings Account</entry>

                <entry></entry>

                <entry>280000</entry>
              </row>

              <row>
                <entry>Expenses:Interest:Mortgage Interest</entry>

                <entry>30000</entry>

                <entry></entry>
              </row>
              <row>
                <entry>Libilities:Loans:Mortgage</entry>

                <entry>250000</entry>

                <entry></entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        
      <para>The <guilabel>Liabilities:Loans:Mortgage</guilabel> Transaction Ledger looks like 
      this after the transacations have been entered</para>
      
      <screenshot id="currency_PutTogether_AussieHouse.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_PutTogether_AussieHouse.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>House Mortgage</phrase>
          </textobject>
          <caption><para>
            Transaction Ledger of the House Loan
          </para></caption>
        </mediaobject>
      </screenshot>
    </sect2>

    <sect2>
      <title>Stock Purchasing</title>

      <para>Since you quite suddenly have a lot of money in your bank account,
      you decide to visit a Financial Advisor, and after his recommendation
      (remember, this is fictional - Not a genuine stock purchase advice) you
      decide to purchase Telecommunication (Ericsson in Sweden), Beijing
      Airport (Hong Kong), and Amazon (USA).</para>

      <para>The needed accounts to track these investments looks like
      this.</para>

      <literallayout>
Assets:Investments:Swedish Broker:ERIC.ST                 (STOCK ERIC.ST Yahoo)
Assets:Investments:Swedish Broker:Bank                    (SEK)
Assets:Investments:HK Broker:0694.HK                      (STOCK 0694.HK Yahoo)
Assets:Investments:HK Broker:Bank                         (HKD)
Assets:Investments:US Broker:AMZN                         (STOCK AMZN Nasdaq)
Assets:Investments:US Broker:Bank                         (USD)
Expenses:Investments:Commissions:Swedish Broker:ERIC.ST   (SEK)
Expenses:Investments:Commissions:HK Broker:0694.HK        (HKD)
Expenses:Investments:Commissions:US Broker:AMZN           (USD)
Expenses:Investments:Currency Transfer                    (AUD)
</literallayout>

      <para>You decide to invest $100,000 into each stock, and to do this
      we first do a currency transaction to the various bank accounts
      associated with the stock. </para>

      <para>The transaction you enter into your <guilabel>Income:Current
      Assets:Savings Account</guilabel> should look like this.</para>

      <table>
        <title>Transfer money to overseas with a multiple currency transaction
        split.</title>

        <tgroup cols="5">
          <tbody>
            <row>
              <entry>Account</entry>

              <entry>Deposit</entry>

              <entry>Withdrawal</entry>

              <entry>Exchange Rate</entry>

              <entry>Transaction Fee</entry>
            </row>

            <row>
              <entry>Assets:Investments:Swedish Broker:Bank</entry>

              <entry>100000</entry>

              <entry></entry>

              <entry>5.5869</entry>

              <entry>35</entry>
            </row>

            <row>
              <entry>Assets:Investments:HK Broker:Bank</entry>

              <entry>100000</entry>

              <entry></entry>

              <entry>5.8869</entry>

              <entry>30</entry>
            </row>

            <row>
              <entry>Assets:Investments:USD Broker:Bank</entry>

              <entry>100000</entry>

              <entry></entry>

              <entry>0.7593</entry>    

              <entry>25</entry>
            </row>
          </tbody>
        </tgroup>
      </table>

      <para>Now when there is some money in the various stock brokerage
      accounts, you ask each broker to buy stocks for the certain amount.
      Remember to execute the transaction from the stocks associated bank
      account, and if the Exchange Rate window do not pop up, right click the
      row and manually start it. Enter the number of stocks you purchase in
      the last entry (To Amount:).</para>

      <para>
        <table>
          <title>Purchasing oversea stocks</title>

          <tgroup cols="4">
            <tbody>
              <row>
                <entry>Stock Symbol</entry>

                <entry>Number of shares</entry>

                <entry>Amount</entry>

                <entry>Commission</entry>
              </row>

              <row>
                <entry>ERIC.ST</entry>

                <entry>15000</entry>

                <entry>270000</entry>

                <entry>400</entry>
              </row>

              <row>
                <entry>0694.HK</entry>

                <entry>70000</entry>

                <entry>280000</entry>

                <entry>300</entry>
              </row>

              <row>
                <entry>AMZN</entry>

                <entry>1000</entry>

                <entry>32000</entry>

                <entry>25</entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </para>
        
      <para>As you can see in the Chart of Accounts, you have now purchased stocks in three
      different currencise (HK, USD, as well as in SEK), but the Chart of Account (as seen below)
      do not indicate how much it is valued in your home currency, AUD.</para>
      <screenshot id="currency_PutTogether_AfterStocks.png">
        <mediaobject>
          <imageobject>
            <imagedata fileref="figures/currency_PutTogether_AfterStocks.png"
                       format="PNG" srccredit="Bengt Thuree" />
          </imageobject>

          <textobject>
            <phrase>Chart of Account after Stocks</phrase>
          </textobject>
          <caption><para>
            Some of the accounts in Chart of Accounts after the stock purchase
          </para></caption>
        </mediaobject>
      </screenshot>

      <para>Next section will ensure you get the various exchange rates so GnuCash can show your
      total worth in the local currency (AUD in this case)</para>
    </sect2>

    <sect2>
      <title>Get the online quotes</title>

      <para>To get the current exchange rates and stock quotes, go to
      <guimenu>Tools</guimenu> -&gt; <guimenu>Price Editor</guimenu> and then
      click on <guibutton>Get Quotes</guibutton>. </para>

      <para></para>
    </sect2>


    <sect2>
      <title>Lending money to a friend</title>

      <para>Peter has run into some difficulties all the way over in Europe
      Land. Since he is a very dear pal of yours, you decide to help him out
      with a personal loan of 40,000 Euro.</para>

      <para>
        <literallayout>
Assets:Money owed to me:Euro:Peter            (Euro)
Income:Interest Income:Peter                  (Euro)
Expenses:Bank Charge                          (AUD)
        </literallayout>
      </para>
      <para>This is a
        simpe currency transaction from your Savings Account (AUD), to your
        Assets:Money owed to me:Peter (EURO) account. You got the exchange rate
        of 0.606161, which means you need to withdraw AUD 65,989.10, as well as
        pay the service fee of 35 AUD.</para>
    </sect2>

    <sect2>
      <title>Buying property in New Zealand with a loan from Japan</title>

      <para>Your long time Japanese friend offers you a Japanese house loan if
      you purchase a property overseas, with only AUD 50,000 as deposit. After
      having discussed this with your Financial Advisor in Australia and gone
      through the various risks and benefits related to your situation, you
      decide to accept his offer. </para>

      <note>
        <para>Again, this should not be taken as a financial advice. Please
        consult with a registered financial advisor before undertaking
        investing (or spekulating) in overseas markets, or local markets for
        that matter.</para>

        <para>A word of warning might be of interest here, taking a loan
        overseas for a very low interest rate might seem like a very good
        deal. Do keep in mind though that the exchange rate might change and
        can change drastically. If you take a loan in your local currency, you
        only have to worry about the interest rate. Taking a loan overseas,
        then you have to worry about the interest rate and the exchange rate.
        </para>
      </note>

      <para>You found a nice small cottage in a small coastal town near
      Auckland which would be a perfect summer house, and you decide to use
      the money from Japan for this purpose.</para>

      <para>We need the following accounts for this example;</para>

      <literallayout>
Liabilities:Loans:Japan Loan                  (JPY)
Expenses:Interest:Japan Loan                  (JPY)
Expenses:Mortgage Adm Fees:Japan Loan         (JPY)
Assets:Current Assets:Japan Bank              (JPY)
Assets:Fixed Assest:NZ House                  (NZ)
</literallayout>

      <table>
          <title>Buying a NZ House Split Transaction</title>

          <tgroup cols="3">
            <tbody>
              <row>
                <entry>Account</entry>

                <entry>Increase</entry>

                <entry>Decrease</entry>
              </row>

              <row>
                <entry>Assets:Fixed Assets:NZ House</entry>

                <entry>300000 (NZD)</entry>

                <entry></entry>
              </row>

              <row>
                <entry>Assets:Current Assets:Savings Account</entry>

                <entry></entry>

                <entry>50000 (AUD) (1.18926)</entry>
              </row>

              <row>
                <entry>Liabilities:Loans:Japan Loan</entry>

                <entry></entry>

                <entry>28000000 (JPY) (0.0137609)</entry>
              </row>

              <row>
                <entry>Expenses:Mortgage Adm Fees:Japan Loan</entry>

                <entry>300000 (JPY) (0.0137609)</entry>

                <entry></entry>
              </row>
            </tbody>
          </tgroup>
      </table>
      
      
    </sect2>
 
    <sect2>
      <title>Whats next?</title>
      <para>As you have seen in the above examples you have only done the initial purchases. 
      The rest, that is various selling, and unrealized gains tracking is left for you to 
      ponder upon.</para>
    </sect2>
   
    
  </sect1>
  
</chapter>
