mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #585784: Fix wrong fractional precision in stock/mutual fund registers Bug 585784 - Wrong fractional precision displayed in stock/mutual fund registers
The original patch attempted to fix bug #529494 by replacing the gnc_split_value_print_info function with gnc_split_register_print_info, which instead of using the print info of the transaction's commodity, used the print info of the commodity of the register's account. However, this was not the correct behavior in all cases either. This patch eliminates the gnc_split_register_print_info and instead puts the logic for selecting the appropriate print info into the functions which previously called it. * In gnc_split_register_get_balance_entry, the print info of the account of the split is used (xaccSplitGetAccount); if the split doesn't have an account, the print info of the register's default account (gnc_split_register_get_default_account) is used * In gnc_split_register_get_debcred_entry, if there is no split, the account info of the register's default account (gnc_split_register_get_default_account) is used. Otherwise, if the register is a Stock/Mutual Fund register or an (obsolete) Currency register, the print info of the transaction's currency is used (xaccTransGetCurrency). Finally in all other cases, the print info of the register's default account (gnc_split_register_get_default_account) is used. * In gnc_template_register_get_debcred_entry, there is no account to reference, so the default print info (gnc_default_print_info) is used. Patch by Daniel Harding. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18320 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c5077e259f
commit
03585ce69e
@ -1061,12 +1061,6 @@ gnc_split_register_get_memo_help (VirtualLocation virt_loc,
|
|||||||
return g_strdup (help);
|
return g_strdup (help);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GNCPrintAmountInfo gnc_split_register_print_info (SplitRegister *reg)
|
|
||||||
{
|
|
||||||
return gnc_account_print_info (gnc_split_register_get_default_account (reg),
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
|
gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
|
||||||
gboolean translate,
|
gboolean translate,
|
||||||
@ -1078,6 +1072,7 @@ gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
|
|||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
gboolean is_trans;
|
gboolean is_trans;
|
||||||
Split *split;
|
Split *split;
|
||||||
|
Account *account;
|
||||||
|
|
||||||
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
||||||
|
|
||||||
@ -1093,18 +1088,14 @@ gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
|
|||||||
else
|
else
|
||||||
balance = xaccSplitGetBalance (split);
|
balance = xaccSplitGetBalance (split);
|
||||||
|
|
||||||
{
|
|
||||||
Account *account;
|
|
||||||
|
|
||||||
account = xaccSplitGetAccount (split);
|
account = xaccSplitGetAccount (split);
|
||||||
if (!account)
|
if (!account)
|
||||||
account = gnc_split_register_get_default_account (reg);
|
account = gnc_split_register_get_default_account (reg);
|
||||||
|
|
||||||
if (gnc_reverse_balance (account))
|
if (gnc_reverse_balance (account))
|
||||||
balance = gnc_numeric_neg (balance);
|
balance = gnc_numeric_neg (balance);
|
||||||
}
|
|
||||||
|
|
||||||
return xaccPrintAmount (balance, gnc_split_register_print_info (reg));
|
return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@ -1458,11 +1449,12 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
GNC_RND_ROUND);
|
GNC_RND_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return xaccPrintAmount (imbalance, gnc_split_register_print_info (reg));
|
return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
gnc_numeric amount;
|
gnc_numeric amount;
|
||||||
|
GNCPrintAmountInfo print_info;
|
||||||
|
|
||||||
/* If this account is not a stock/mutual/currency account, and
|
/* If this account is not a stock/mutual/currency account, and
|
||||||
* currency != the account commodity, then use the SplitAmount
|
* currency != the account commodity, then use the SplitAmount
|
||||||
@ -1472,6 +1464,7 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
case STOCK_REGISTER:
|
case STOCK_REGISTER:
|
||||||
case CURRENCY_REGISTER:
|
case CURRENCY_REGISTER:
|
||||||
amount = xaccSplitGetValue (split);
|
amount = xaccSplitGetValue (split);
|
||||||
|
print_info = gnc_commodity_print_info (currency, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1487,6 +1480,7 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
amount = xaccSplitConvertAmount(split, account);
|
amount = xaccSplitConvertAmount(split, account);
|
||||||
else
|
else
|
||||||
amount = xaccSplitGetValue (split);
|
amount = xaccSplitGetValue (split);
|
||||||
|
print_info = gnc_account_print_info (account, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1501,7 +1495,7 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
|
|
||||||
amount = gnc_numeric_abs (amount);
|
amount = gnc_numeric_abs (amount);
|
||||||
|
|
||||||
return xaccPrintAmount (amount, gnc_split_register_print_info (reg));
|
return xaccPrintAmount (amount, print_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1867,7 +1861,7 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
amount = gnc_numeric_abs (amount);
|
amount = gnc_numeric_abs (amount);
|
||||||
|
|
||||||
/* FIXME: This should be fixed to be correct for the "fake" account. */
|
/* FIXME: This should be fixed to be correct for the "fake" account. */
|
||||||
return xaccPrintAmount (amount, gnc_split_register_print_info (reg));
|
return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user