[GNC] Order of accounts when closing the book
Stephen M. Butler
kg7je at arrl.net
Tue Jun 10 12:16:09 EDT 2025
On 6/10/25 08:41, Michael or Penny Novack via gnucash-user wrote:
> On 6/10/2025 12:36 AM, Stan Brown (using GC 4.14) wrote:
>> The Close the Book tool generates two transactions, one for all income
>> accounts and the other for all expense accounts. The accounts are not in
>> alphabetical order in either transaction, nor are they in Account Code
>> order, nor arranged by the values of the splits.
>>
>> They _seem_ random, but I can't imagine they really are. Can anyone tell
>> me (a) how they're actually sorted, and (b) how I can get them in
>> Account Code order?
>
> If you are really doing a "close the books" << close the "temporary*
> accounts of types income and expense" into equity it could be done
> three ways:
>
> a) In a single transaction.
>
> b) In two transactions, one for the income accounts and one for the
> expense accounts.
>
> c) Separate transactions for each income and expense account.
>
> These are logical equivalents. So you appear to be asking, "were I
> using method "c" am I forced to do them in some specified work flow
> order?" You are of course asking about "b" but what meaning are you
> attaching to order?
>
> Michael D Novack
The GnuCash book closing module uses method b.
One of the things about data storage that I learned early on (retired
Oracle DBA) is never to assume a particular order within the data
store. The order could vary depending on the internal representation.
Does the store use a B-Tree index or a hashing algorithm. Does it use
the raw value or substitute an internal ID that is then associated with
the raw value. Or is it stored in the order in which it was
encountered. This could change from one release of the software to the
next (Oracle did that a couple of times during my career).
So, if you need to impose some order then the best method is to extract
the data into an external tool where you can sort it as desired.
More information about the gnucash-user
mailing list