mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use Account smallest currency units in printing amounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3111 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -282,31 +282,87 @@ gnc_commodity_print_info (const gnc_commodity *commodity,
|
||||
}
|
||||
|
||||
GNCPrintAmountInfo
|
||||
gnc_account_print_info (Account *account, gboolean use_symbol)
|
||||
gnc_account_quantity_print_info (Account *account, gboolean use_symbol)
|
||||
{
|
||||
const gnc_commodity *currency;
|
||||
GNCPrintAmountInfo info;
|
||||
gboolean is_iso;
|
||||
int scu;
|
||||
|
||||
currency = xaccAccountGetCurrency (account);
|
||||
if (currency == NULL)
|
||||
if (account == NULL)
|
||||
return gnc_default_print_info (use_symbol);
|
||||
|
||||
return gnc_commodity_print_info (currency, use_symbol);
|
||||
info.commodity = xaccAccountGetSecurity (account);
|
||||
|
||||
is_iso = (safe_strcmp (gnc_commodity_get_namespace (info.commodity),
|
||||
GNC_COMMODITY_NS_ISO) == 0);
|
||||
|
||||
scu = xaccAccountGetSecuritySCU (account);
|
||||
|
||||
if (is_decimal_fraction (scu, &info.max_decimal_places))
|
||||
{
|
||||
if (is_iso)
|
||||
info.min_decimal_places = info.max_decimal_places;
|
||||
else
|
||||
info.min_decimal_places = 0;
|
||||
}
|
||||
else
|
||||
info.max_decimal_places = info.min_decimal_places = 0;
|
||||
|
||||
info.use_separators = 1;
|
||||
info.use_symbol = use_symbol ? 1 : 0;
|
||||
info.use_locale = is_iso ? 1 : 0;
|
||||
info.monetary = 1;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
GNCPrintAmountInfo
|
||||
gnc_account_value_print_info (Account *account, gboolean use_symbol)
|
||||
{
|
||||
GNCPrintAmountInfo info;
|
||||
gboolean is_iso;
|
||||
int scu;
|
||||
|
||||
if (account == NULL)
|
||||
return gnc_default_print_info (use_symbol);
|
||||
|
||||
info.commodity = xaccAccountGetCurrency (account);
|
||||
|
||||
is_iso = (safe_strcmp (gnc_commodity_get_namespace (info.commodity),
|
||||
GNC_COMMODITY_NS_ISO) == 0);
|
||||
|
||||
scu = xaccAccountGetCurrencySCU (account);
|
||||
|
||||
if (is_decimal_fraction (scu, &info.max_decimal_places))
|
||||
{
|
||||
if (is_iso)
|
||||
info.min_decimal_places = info.max_decimal_places;
|
||||
else
|
||||
info.min_decimal_places = 0;
|
||||
}
|
||||
else
|
||||
info.max_decimal_places = info.min_decimal_places = 0;
|
||||
|
||||
info.use_separators = 1;
|
||||
info.use_symbol = use_symbol ? 1 : 0;
|
||||
info.use_locale = is_iso ? 1 : 0;
|
||||
info.monetary = 1;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
GNCPrintAmountInfo
|
||||
gnc_split_quantity_print_info (Split *split, gboolean use_symbol)
|
||||
{
|
||||
return gnc_account_print_info (xaccSplitGetAccount (split), use_symbol);
|
||||
return gnc_account_quantity_print_info (xaccSplitGetAccount (split),
|
||||
use_symbol);
|
||||
}
|
||||
|
||||
GNCPrintAmountInfo
|
||||
gnc_split_value_print_info (Split *split, gboolean use_symbol)
|
||||
{
|
||||
const gnc_commodity *security;
|
||||
|
||||
security = xaccAccountGetSecurity (xaccSplitGetAccount (split));
|
||||
|
||||
return gnc_commodity_print_info (security, use_symbol);
|
||||
return gnc_account_value_print_info (xaccSplitGetAccount (split),
|
||||
use_symbol);
|
||||
}
|
||||
|
||||
GNCPrintAmountInfo
|
||||
|
||||
@@ -81,8 +81,10 @@ GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol);
|
||||
GNCPrintAmountInfo gnc_commodity_print_info (const gnc_commodity *commodity,
|
||||
gboolean use_symbol);
|
||||
|
||||
GNCPrintAmountInfo gnc_account_print_info (Account *account,
|
||||
gboolean use_symbol);
|
||||
GNCPrintAmountInfo gnc_account_quantity_print_info (Account *account,
|
||||
gboolean use_symbol);
|
||||
GNCPrintAmountInfo gnc_account_value_print_info (Account *account,
|
||||
gboolean use_symbol);
|
||||
|
||||
GNCPrintAmountInfo gnc_split_quantity_print_info (Split *split,
|
||||
gboolean use_symbol);
|
||||
|
||||
@@ -277,7 +277,7 @@ gnc_ui_get_account_field_value_string(Account *account, int field)
|
||||
double balance = gnc_ui_account_get_balance(account, FALSE);
|
||||
|
||||
return DxaccPrintAmount(balance,
|
||||
gnc_account_print_info (account, TRUE));
|
||||
gnc_account_value_print_info (account, TRUE));
|
||||
}
|
||||
break;
|
||||
case ACCOUNT_BALANCE_EURO :
|
||||
@@ -297,7 +297,7 @@ gnc_ui_get_account_field_value_string(Account *account, int field)
|
||||
double balance = gnc_ui_account_get_balance(account, TRUE);
|
||||
|
||||
return DxaccPrintAmount(balance,
|
||||
gnc_account_print_info (account, TRUE));
|
||||
gnc_account_value_print_info (account, TRUE));
|
||||
}
|
||||
break;
|
||||
case ACCOUNT_TOTAL_EURO :
|
||||
|
||||
@@ -641,7 +641,11 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||
account_type = xaccAccountGetType(list->account);
|
||||
strings[5] = NULL;
|
||||
|
||||
print_info = gnc_account_print_info (list->account, FALSE);
|
||||
if ((account_type == STOCK) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
print_info = gnc_account_quantity_print_info (list->account, FALSE);
|
||||
else
|
||||
print_info = gnc_account_value_print_info (list->account, FALSE);
|
||||
|
||||
for (splits = xaccQueryGetSplits(list->query); *splits != NULL; splits++)
|
||||
{
|
||||
|
||||
@@ -182,13 +182,18 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
|
||||
reverse_balance = gnc_reverse_balance(recnData->account);
|
||||
|
||||
print_info = gnc_account_print_info (recnData->account, TRUE);
|
||||
|
||||
/* update the starting balance */
|
||||
if (recnData->use_shares)
|
||||
{
|
||||
starting = DxaccAccountGetShareReconciledBalance(recnData->account);
|
||||
print_info = gnc_account_quantity_print_info (recnData->account, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
starting = DxaccAccountGetReconciledBalance(recnData->account);
|
||||
print_info = gnc_account_value_print_info (recnData->account, TRUE);
|
||||
}
|
||||
|
||||
if (reverse_balance)
|
||||
starting = -starting;
|
||||
|
||||
@@ -263,7 +268,8 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
value = 0.0;
|
||||
DxaccParseAmount(string, TRUE, &value, NULL);
|
||||
|
||||
print_info = gnc_account_print_info (account, FALSE);
|
||||
/* FIXME */
|
||||
print_info = gnc_account_value_print_info (account, FALSE);
|
||||
|
||||
new_string = DxaccPrintAmount(value, print_info);
|
||||
|
||||
@@ -301,15 +307,19 @@ startRecnWindow(GtkWidget *parent, Account *account,
|
||||
char *title;
|
||||
int result;
|
||||
|
||||
print_info = gnc_account_print_info (account, TRUE);
|
||||
|
||||
account_type = xaccAccountGetType(account);
|
||||
|
||||
if ((account_type == STOCK) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
{
|
||||
dendBalance = DxaccAccountGetShareReconciledBalance(account);
|
||||
print_info = gnc_account_quantity_print_info (account, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
dendBalance = DxaccAccountGetReconciledBalance(account);
|
||||
print_info = gnc_account_value_print_info (account, TRUE);
|
||||
}
|
||||
|
||||
if (gnc_reverse_balance(account))
|
||||
{
|
||||
|
||||
@@ -1827,7 +1827,7 @@ regRefresh(xaccLedgerDisplay *ledger)
|
||||
|
||||
xaccSRLoadXferCells(ledger->ledger, ledger->leader);
|
||||
|
||||
print_info = gnc_account_print_info (ledger->leader, TRUE);
|
||||
print_info = gnc_account_value_print_info (ledger->leader, TRUE);
|
||||
|
||||
if (regData->window != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user