@ -250,7 +250,7 @@ I move to brazil, and take my RHAT stock (purchased in dollars)
to my brazilian broker (who will sell them for cruzeiros).
Is the correct answer to just 'punt' in these cases?
How is te h closing of books to be handled in such a case?
How is the closing of books to be handled in such a case?
GUI Elements:
-- The user should be able to specify a default 'realized-gain'
@ -259,6 +259,14 @@ GUI Elements:
account that is associated witha a stock account.
FIFO's
======
What is a FIFO ? A FIFO is a type of accounting policy where
income from selling inventory is accounted by selling the oldest
inventory first. Thus, the profit/loss of the sale corresponds
to the difference in price between when it was bought and sold.
FIFO's are also used in depreciation schedules, and in other places.
Implementation
==============
@ -274,13 +282,141 @@ lots so that all lots belonging to an account can be quickly retreived.
(In principle, the lots can be found by scanning every split in the
account, but this is a painful process.)
Implementing Cap Gains (Is a Pain in the Neck)
==============================================
Although Lots provide a good conceptual framework for determing
gains or losses when a lot is closed, cap-gains on half-open
lots present additional complexities. Consider the following
stock purchase and subsequent sale of half the stock:
Account A is a stock account
Account B is a bank account
Account C is an income account
Acct A Txn Acct B Acct C
Date Action Amt Prc Value Amt Amt
1/1/01 buy 100s $10 $1000 ($1000) -
2/2/02 sell (50)s $25 $1250 $1250 -
2/2/02 gain - - $750 $750
The gain, shown in the third line, is computed as a straight
sum of purchase price to sale price.
Should the above be reprsented as two transactions, or as three?
One could, in principle, combine the second and third lines into
one transaction. However, this has some drawbacks: computing
the overall balance of such a transaction is tricky, because
it has so many different splits (including, possibly, splits
for brokerage fees, tax, etc. not shown). The alternative
is to represent each line as a separate transaction. This has
other drawbacks: If the date, amount, price or value is adjusted
for the second transaction, the corresponding values must be
adjusted for the third, and vice-versa.
Both schemes pose trouble for the register display: we want
the stock register to show the gain as if it were a part of
the stock sale; but the third line is a pair of splits, and
we want to show only one of these two splits. Whichever method
is chosen, the register has to filter out some of the splits
that it shows.
The implementation that seems best is to represnet the sale
with two separate transactions: one for the sale itself, and a
separate one for the gains. This makes computing the balance
easier, although it makes the logic for setting the date
more complex. Ughh..
Conversion
==========
When Lots are finally put into production, old GnuCash datasets
will need to be converted. Conversion will be done by running
all splits in an account through an accounting FIFO. The goal
of the FIFO is to match up purchases and sales so that these can
be assigned to a Lot.
The conversion algorithm will work as follows:
for each account {
loop over splits {
// perform the 'double-balance' check
if (split commodity != transaction currency) account needs conversion
}
if account needs conversion
for each split {
If (split amount > 0) create new lot, put split in lot.
If (split amount < 0) find oldest lot, put split in that lot
}
}
See the file Scrub2.h for details.
GUI
===
A GUI for handling Lots is needed: ability to view a lot, and to cut/paste
or move a split from one lot to another. Need a GUI to create a lot,
maybe append some notes to it. Need ability to view account in lot-mode.
For automatically managing accounts, need to implement a variety of
different accounting policies (of which the FIFO policy is currently
implemented in the 'Scrub' routines).
Basic GUI:
The goal of the basic GUI is to handle most usages of
most lots in most places. There also need to be special-purpose
dialogs for specific applications, e.g. stocks, inventory, etc.
Shows three areas:
-- list of lots, one of which can be highlighted.
Lot names can be edited in-place.
-- contents of a single lot (displayed in a narrow,
mini-register view, showing only date, memo, quant,
balance)
-- list of splits not in any lot.
(not clear if screen real-estate allows side-by-side
placement, or if this must be above/below. above/below
would suck)
Shows various buttons:
-- two arrows, which move split into/out of lot.
This is a traditional way of moving something from one
list to another, but some UI designers argue against this.
Is there a better way to move splits into/out-of a lot?
-- button, labelled 'close lot', which, when pressed, will
set lot balance to zero. (by using fifo on the unassigned
splits, if possible).
-- A field showing realized gain/loss on a closed lot, and
a pull-down allowing the gain/loss to be posted to a
specific account.
(The default is stored in kvp:/lots-mgmt/gains-acct/)
-- button or menu item, 'add notes to this lot'.
Status
======
Core support for Lots in the engine is complete (April 2002).
See src/engine/gnc-lot.h for the public API.
FIFO's have not been started.
The XML backend support for lot is complete (but untested).
The Postgres backend does not yet support lots.
o Core support for Lots in the engine is complete (April 2002, ships in
version 1.8.x, used by business backend).
o See src/engine/gnc-lot.h for the public API.
o The XML backend support for lot is complete (April 2002, ships in
version 1.8.x).
o The Postgres backend does not yet support lots.
o Scrub routines to automatically take old gnucash datasets and
transition them to double-balanced lots have been implemented.
These implement a FIFO accounting policy (April 2003)
XXX need to add a lot id, have it auto-gened by the scrubber.
o No GUI yet.
XXX It is a good idea to generate a gain/loss split for ever sale, not
just the lot closure. Need to tweak the register to hide/show as appropriate.
Need to add a tag to the gain spl;it to indicate its's 'special' nature.
-------------------------- end of file ------------------------------