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 770364 - Sign of Value in Lots in Account window seems inconsistent
Sign of Value in Lots in Account window seems inconsistent
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: General
2.6.13
Other All
: Normal normal
: ---
Assigned To: gnucash-general-maint
gnucash-general-maint
Depends on:
Blocks:
 
 
Reported: 2016-08-25 01:57 UTC by Chris Good
Modified: 2018-06-29 23:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screendump (58.28 KB, image/png)
2016-08-25 01:57 UTC, Chris Good
Details
STOCK1 Register (117.97 KB, image/png)
2016-08-25 04:32 UTC, Chris Good
Details

Description Chris Good 2016-08-25 01:57:32 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.
Comment 1 Chris Good 2016-08-25 02:02:33 UTC
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
Comment 2 John Ralls 2016-08-25 02:43:19 UTC
Please attach a screenshot of the STOCK1 register as well.
Comment 3 Chris Good 2016-08-25 04:32:50 UTC
Created attachment 334113 [details]
STOCK1 Register
Comment 4 John Ralls 2016-08-25 16:25:26 UTC
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.
Comment 5 Geert Janssens 2016-11-12 10:07:59 UTC
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.
Comment 6 Chris Good 2016-11-15 01:06:17 UTC
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.
Comment 7 Geert Janssens 2016-11-16 13:59:58 UTC
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.
Comment 8 John Ralls 2018-06-29 23:50:47 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=770364. Please update any external references or bookmarks.