After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 598618 - does not calculate account balances correctly
does not calculate account balances correctly
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Backend - SQL
2.3.x
Other Linux
: Normal major
: ---
Assigned To: Phil Longstaff
Chris Shoemaker
Depends on:
Blocks:
 
 
Reported: 2009-10-15 21:34 UTC by Michael Tenenbaum
Modified: 2018-06-29 22:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Accounts showing $650 Invoice (153.13 KB, image/jpeg)
2009-10-15 21:34 UTC, Michael Tenenbaum
Details
Balances mysteriously get changed to $1300 (151.18 KB, image/jpeg)
2009-10-15 21:37 UTC, Michael Tenenbaum
Details
Transaction show $650 but balance is $1300 (247.54 KB, image/jpeg)
2009-10-15 21:41 UTC, Michael Tenenbaum
Details
Your humble reporter on the beach at Waikiki (332.49 KB, image/jpeg)
2009-10-15 21:43 UTC, Michael Tenenbaum
Details

Description Michael Tenenbaum 2009-10-15 21:34:49 UTC
Created attachment 145556 [details]
Accounts showing $650 Invoice 

-- Running Postgresql 8.3.8

-- Entered customer "Allstate Insurance Co."

-- Entered invoice for $650

-- File -->Save As -->Postgresql (entered db name, db user and db password)

See screen shot "Accounts showing $650 Invoice"

-- File -->Quit
Comment 1 Michael Tenenbaum 2009-10-15 21:37:03 UTC
Created attachment 145557 [details]
Balances mysteriously get changed to $1300
Comment 2 Michael Tenenbaum 2009-10-15 21:38:47 UTC
Re-entering Gnucash, balances mysteriously get changed to $1300.
Comment 3 Michael Tenenbaum 2009-10-15 21:41:20 UTC
Created attachment 145559 [details]
Transaction show $650 but balance is $1300

See third screenshot showing one $650 transaction but the balance is $1300
Comment 4 Michael Tenenbaum 2009-10-15 21:43:49 UTC
Created attachment 145560 [details]
Your humble reporter on the beach at Waikiki
Comment 5 Phil Longstaff 2009-11-10 02:20:39 UTC
I like the picture.

The only thing I can think of is that the initial balance query is not working correctly.  With an XML file is opened, all of the transactions are read into memory.  The accounts start with start balance of 0 and the end balance is the sum of the amounts of all splits for the account.

With the sql backend, all transactions are *not* loaded at start time.  Instead, there's a query for the sum of all split amounts for each account, and this is set as the account balance shown on the accounts page.  As splits are loaded for an account, the start balance is adjusted by the amount of new splits so that the end balance stays constant.  As an example, if there is 1 split worth $650 in the db for an account, it sets the start balance on startup to $650.  Since there are no splits, the end balance is also $650.  Then, when the splits for that account are loaded, the end balance changes to $1300, and the start balance is offset by $1300-$650 (new end balance - old end balance) to bring the end balance back to the correct value.

Perhaps this is going wrong somehow.  Can you package the db and e-mail it to me?
Comment 6 Michael Tenenbaum 2009-11-10 14:01:52 UTC
I emailed a pg_dump to the return address of your email.  If there is a different email address, kindly forward that to me.

Good luck!
Comment 7 Phil Longstaff 2009-11-10 14:03:50 UTC
I got the file and see the issue.  Now to track down the cause.
Comment 8 Phil Longstaff 2009-11-10 18:12:34 UTC
Found the cause.  Not sure of the solution.  It's another issue related to not loading all splits on startup.
Comment 9 Michael Tenenbaum 2009-11-10 20:41:48 UTC
Phil, just remember what I tell my Linux students at University of Phoenix:

"There is ALWAYS time to do it right."

Just take your time and think it through.
Comment 10 Phil Longstaff 2009-11-21 04:33:14 UTC
r18431 - Reverted back to loading all splits/transactions on startup.
Comment 11 John Ralls 2018-06-29 22:29:53 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=598618. Please update any external references or bookmarks.