From ecb43e7d72941c32bc7bee3d3698029bfd643080 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 12 Nov 2016 10:30:31 +0100 Subject: [PATCH] Bug 770364 - Sign of Value in Lots in Account window seems inconsistent Two parts to this bug: 1. never reverse signs in the free splits list. Sign reversals don't make sense there. 2. Sign reversal only makes sense for capital gains, not for business transactions. So only to the sign dance for non-business lots in the list of splits in the selected lot. --- src/gnome/dialog-lot-viewer.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gnome/dialog-lot-viewer.c b/src/gnome/dialog-lot-viewer.c index a4c64e4506..2d6e2b5551 100644 --- a/src/gnome/dialog-lot-viewer.c +++ b/src/gnome/dialog-lot-viewer.c @@ -485,8 +485,12 @@ gnc_split_viewer_fill (GNCLotViewer *lv, GtkListStore *store, SplitList *split_l { SplitList *node; GtkTreeIter iter; - + gboolean is_business_lot = FALSE; gnc_numeric baln = gnc_numeric_zero(); + + if (lv->selected_lot) + is_business_lot = xaccAccountIsAPARType (xaccAccountGetType (gnc_lot_get_account (lv->selected_lot))); + gtk_list_store_clear (lv->split_in_lot_store); for (node = split_list; node; node = node->next) { @@ -501,8 +505,7 @@ gnc_split_viewer_fill (GNCLotViewer *lv, GtkListStore *store, SplitList *split_l gnc_numeric amnt, valu, gains; /* Do not show gains splits, however do show empty business splits */ - if (!xaccAccountIsAPARType (xaccAccountGetType (xaccSplitGetAccount (split))) - && gnc_numeric_zero_p (xaccSplitGetAmount(split))) continue; + if (!is_business_lot && gnc_numeric_zero_p (xaccSplitGetAmount(split))) continue; gtk_list_store_append(store, &iter); @@ -522,13 +525,13 @@ gnc_split_viewer_fill (GNCLotViewer *lv, GtkListStore *store, SplitList *split_l gnc_account_print_info (lv->account, TRUE)); gtk_list_store_set (store, &iter, SPLIT_COL_AMOUNT, amtbuff, -1); - /* Value. Invert the sign on the first, opening entry. */ + /* Value. + * For non-business accounts which are part of a lot, + * invert the sign on the first. */ currency = xaccTransGetCurrency (trans); valu = xaccSplitGetValue (split); - if (node != split_list) - { - valu = gnc_numeric_neg (valu); - } + if (lv->selected_lot && !is_business_lot && (node != split_list)) + valu = gnc_numeric_neg (valu); xaccSPrintAmount (valbuff, valu, gnc_commodity_print_info (currency, TRUE)); gtk_list_store_set (store, &iter, SPLIT_COL_VALUE, valbuff, -1);