Schema

David Merrill dmerrill@lupercalia.net
Tue, 12 Dec 2000 16:53:51 -0500


On Tue, Dec 12, 2000 at 03:02:15PM -0600, Bill Gribble wrote:
> On Wed, Dec 13, 2000 at 06:42:04AM +1000, Phillip J Shelton wrote:
> > It is the smallest amount that this account can change by.  GnuCash is
> > now using a variation on rational numbers which have a numerator, the
> > value, and a denominator, the damont.
> 
> This isn't right.  Each of 'value' and 'damount' is a rational number
> (the data type is gnc_numeric).  The 'value' is the 'amount of the
> account's Currency', and the damount is the 'amount of the split's
> Security'.  If your stock account has a currency of USD and a security
> of IBM, and you buy 100 shares for 1000 dollars, the value is 1000 and
> the damount is 100 (both expressed in suitable rational
> representations).

Thanks for the explanation.

So, valid values would include 2/3? And how would this be stored, by
the approximation 0.6666666? Or as the actual text value "2/3"? You
said that *each* of damount and value is a rational number, right?
iow, what is a "suitable rational representation"?

Why "d"amount?

> > > cleared_balance                 money           "
> > > reconciled_balance              money           "
> > > share_balance                   money           "
> > > share_cleared_balance           money           "
> > > share_reconciled_balance        money           "
> > 
> > Are not these balance's more correctly part of the account?
> 
> No.  I seem to recall there's a discussion about balance caching going
> on elsewhere.  It's already being done, and this is where the running
> balance is cached.  See xaccAccountBeginEdit and xaccAccountCommitEdit
> to see how/when cached balances are refreshed. 

Then I will remove these fields from my schema. Storing the running
balance this way just won't work for very large data sets.

This does bring up an issue, though. Will I need to keep three running
balances, like here?

What is the difference between a cleared balance and a reconciled
balance? You typically don't know whether a transaction has cleared
until you reconcile. Or, is that changing now that we have such
creatures as downloadable updates from your bank?

> > A transaction is the unit that is entered in the ledger, and the splits
> > are for which accounts are affected by the transaction.  Others will
> > have a better explanation I am sure.
> 
> Transactions aren't entered in the ledger.  In fact, there's no global
> way to get a list of transactions at all.  Splits are the fundamental
> unit of financial information.  Each account has a list of splits
> which are debits and credits to that account.  Each split has a
> pointer to a transaction, which has a list of all the splits that
> point to it.  The transaction must have splits whose debits and
> credits are equal in order to be balanced.

Am I correct, then, in visualizing a transaction as essentially a set
of splits, within which the sum of debits must equal the sum of
credits?

> The Gnucash engine source code is in src/engine ; check in particular
> Transaction.c, Account.c, Group.c.  The gnc-numeric structure and API
> are in gnc-numeric.{c,h}. The gnucash.org web page has instructions
> for how to get the Gnucash source code from CVS.

Thanks, I have the source and am using it. I just don't always know
where to look, and I can miss things.

-- 
Dr. David C. Merrill                     http://www.lupercalia.net
Linux Documentation Project                dmerrill@lupercalia.net
Collection Editor & Coordinator            http://www.linuxdoc.org
                                       Finger me for my public key

No, I'm not interested in developing a powerful brain.  All I'm after is
just a mediocre brain, something like the president of American Telephone
and Telegraph Company.
		-- Alan Turing on the possibilities of a thinking
		   machine, 1943.