GNOME Bugzilla – Bug 770364
Sign of Value in Lots in Account window seems inconsistent
Last modified: 2018-06-29 23:50:47 UTC
Created attachment 334111 [details] Screendump From: Chris Good [mailto:chris.good@ozemail.com.au] Sent: Thursday, 18 August 2016 10:32 AM To: 'gnucash-devel@gnucash.org' <gnucash-devel@gnucash.org> Subject: Lots in Account screen : Value sign Hi, I’m documenting using lots to calculate investments capital gains. Please see the attached screenshot. The sign of the Value in the ‘Splits free’ panel seems inconsistent. Why is the sign of the initial acquisition +ve, but –ve for the following 2 reinvested dividends? The program contains the following: gnucash/src/gnome/dialog-lot-viewer.c line 523: /* Value. Invert the sign on the first, opening entry. */ currency = xaccTransGetCurrency (trans); valu = xaccSplitGetValue (split); if (node != split_list) { valu = gnc_numeric_neg (valu); } I’d like to explain why this is done? Perhaps something to do with the Business scrubbing? Regards, Chris Good I think this is a bug. From my reading of the program (but I'm no expert), the value is just displayed and not used anywhere.
Geert replied: Message: 2 Date: Tue, 23 Aug 2016 17:51:30 +0200 From: Geert Janssens <geert.gnucash@kobaltwit.be> To: gnucash-devel@gnucash.org Subject: Re: Lots in Account screen : Value sign Message-ID: <1514591.tX5QRpNh51@legolas.kobaltwit.lan> Content-Type: text/plain; charset="us-ascii" Hi Chris, I can only speak about the business features. I have 0 experience with investments capital gains. >From that business perspective, I believe you have found a bug in the code. It seemed to have slipped by when I merged a patch in 2011 which introduces the pane with unassigned splits. The code that inverts the first split was originally introduced by Linas in 2003 (in commit https://github.com/Gnucash/gnucash/commit/1a997993 ) for the other pane, the one displaying the splits *in* a selected lot. I don't know why he introduced this behavior. There is no additional explanation with the commit. It was later reused for displaying splits in the free splits pane. However I don't think it makes sense there to revert the first free split. That's just some arbitrary split. So I believe that's wrong. And to be honest, I don't understand the motivation either to revert the sign on the first split in the lots either. For the current (business) code the result is rather arbitrary. Sometimes the first split is a payment, sometimes it's an invoice. Whichever is first gets its value reversed. So sometimes all values are negative, sometimes they're all positive. And the amounts alter negative/positive to properly balance the lot. So from a business perspective, this implementation doesn't make sense at all. I don't know whether it does for capital gains in lots. Perhaps someone else knows ? Geert
Please attach a screenshot of the STOCK1 register as well.
Created attachment 334113 [details] STOCK1 Register
I think that Linas explained this in his letter to gnucash-devel today: He thought that it made sense to have a positive amount for both the initial debit which created the lot and the following credits that reduced it. That's a bit counter-intuitive once one is used to the debit-credit process and it's made worse by using that paradigm to display splits that haven't yet been assigned to lots, as is the case in your first screenshot.
The amounts keep their sign. So the amounts nicely show 100 shares bought as 100 and 20 shares sold as -20. Only the sign of values is manipulated so these always show as positive (for trading, not for business lots). For trading this is only mildly confusing, because in most cases amounts and values are different numbers anyway. For business lots amount and value are always the same (since we don't support inventory and hence have no handling profit processing between a purchase and a sale in the business code). So I have chosen to change the lot viewer code as follows: - splits in the free list will never have a sign reversal while displaying the value. It doesn't make sense there as we don't know whether this was a stock purchase or sale. - in the list of split that are in a lot the sign of the first split's value will still be reversed if the lot is not from a business account. That keeps the current behaviour for trading lots and removes the confusion for business lots.
Hi Geert, Thanks for working on this. I'd like to remove the code which changes the value sign totally and do some testing to confirm capital gains still works and that there are no changes to the values on the stored transaction splits. Would that be enough to get a pull request accepted or would I just be wasting my time? I see that there is a gnucash/test-templates directory. Is this the sort of thing there may already be a test for or there perhaps should be? I'm not familiar with these type of tests at all.
Chris, The code that reverses the value sign is only affecting the display of these values in the lot viewer. So removing it would be rather safe. Do you want to remove this code from both the free splits and the splits in lot panel ? Question is, is that what the users want ? I couldn't infer that from the short discussion on the mailing list. I personally don't have an opinion about it from a user point of view as I don't manage investments in gnucash. I may lean towards removing the code completely as that would simplify it. Before you send in a PR, I would suggest you discuss this on the user or at least devel mailing lists.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=770364. Please update any external references or bookmarks.