DB design document

Phillip J Shelton shelton11@dingoblue.net.au
Fri, 15 Dec 2000 04:52:39 +1000


David Merrill wrote:

> > > > security_scu & currency_scu: 'scu' is Smallest Convertable (I think)
> > > >   Unit, the denominator used for amounts in security/currency.
> > > >   Commodities have default scu's, but accounts can override them.
> > > >   For example, you might have stock in two different brokerages.
> > > >   One may track your shares to 4 decimal places, and another to
> > > >   5 decimal places, even if they're the same shares. This is not
> > > >   an academic example.
> > >
> > > This is closely related to the whole rational number mechanism, right?
> > > Is this the number that will appear in damount when a split is
> > > recorded against this account?
> >
> > Nope, it's the denominator of gnc_numerics put into the value/damount.
> > For example, if you use Fidelity and they report your holdings of a
> > mutual fund to 5 decimal places, the account's security_SCU is 100000.
> > (you hold a counted number of 1/100000 shares).  The currency_scu is
> > likely to be 100 if you are using USD.
>
> That's what I meant. I'm using the term rational numbers to indicate the
> value/damount structure (gnc_numeric data type).
>
> Okay. The _scu values are then the default values for damount for that
> account. A split recorded against the account would have damount set
> to the _scu value.

I am very sorry.   I seem to have managed to badly mis-represent the data
structures to every one.  It appears that there are two ideas of what each name
means.

Could someone who knows please help me to understand how the data structures
work?

This is my present understanding.

value/damount is not a structure.  It is two `numbers` both of which are of type
gnc_numeric.

value is the curency field and contains the cash value of the split.  Its
numerator is the number of cash units that this thing is worth, in the smallest
unit of cash that you can own, and the _scu is the demoniator and is how many of
the smallest units make up the standard measure.

damount is the security field and contains the number of things when you are
trying to count things that are not the same as the stuff that is being counted
in the currency field.

> Although default, it could be modified later. Does it originally come from the
> commodity's definition, because each commodity has some default value
> associated with it? Certainly for currency commodities this would be
> the case.
>
> A related issue... Suppose you have an account with a _scu of 100, and
> the user enters a transaction with an amount that requires it to be
> bumped up to 1000. (They enter 1.001). We would then bump the damount
> to 1000 and record the value as 1001? Other records would be
> unaffected?

Depends where you srored the _scu.  If it is stored with every split then no, no
other records need to be changed. If, however you only store the _scu once with
the account then you will need to change every record if you change the _scu

Phill