mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/register/ledger-core/split-register-model.c -- Always
display amounts in the currency of the current account. Use the pricedb to lookup converstion values if the transaction currency is not the same as the current account commodity. * src/gnome/dialog-transfer.c -- Make sure the exchange rate stays a decimal number instead of converting to a fraction. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7550 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1081387a8d
commit
4f1aba056e
@ -19,6 +19,13 @@
|
|||||||
* src/register/ledger-core/split-register-load.c -- set the txn
|
* src/register/ledger-core/split-register-load.c -- set the txn
|
||||||
currency based on the currency of the "default account"
|
currency based on the currency of the "default account"
|
||||||
|
|
||||||
|
* src/register/ledger-core/split-register-model.c -- Always
|
||||||
|
display amounts in the currency of the current account. Use the
|
||||||
|
pricedb to lookup converstion values if the transaction currency
|
||||||
|
is not the same as the current account commodity.
|
||||||
|
* src/gnome/dialog-transfer.c -- Make sure the exchange rate stays
|
||||||
|
a decimal number instead of converting to a fraction.
|
||||||
|
|
||||||
2002-11-24 David Hampton <hampton@employees.org>
|
2002-11-24 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
* src/app-file/gncmod-app-file.c:
|
* src/app-file/gncmod-app-file.c:
|
||||||
|
@ -1351,6 +1351,7 @@ gnc_xfer_dialog_create(GtkWidget * parent, XferDialog *xferData)
|
|||||||
edit = gnc_amount_edit_new();
|
edit = gnc_amount_edit_new();
|
||||||
gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(edit),
|
gnc_amount_edit_set_print_info(GNC_AMOUNT_EDIT(edit),
|
||||||
gnc_default_price_print_info ());
|
gnc_default_price_print_info ());
|
||||||
|
gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(edit), 100000);
|
||||||
hbox = glade_xml_get_widget (xml, "price_hbox");
|
hbox = glade_xml_get_widget (xml, "price_hbox");
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0);
|
||||||
xferData->price_edit = edit;
|
xferData->price_edit = edit;
|
||||||
|
@ -1259,6 +1259,57 @@ gnc_split_register_get_tdebcred_entry (VirtualLocation virt_loc,
|
|||||||
return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
|
return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gnc_numeric
|
||||||
|
gnc_split_register_convert_amount (Split *split, Account * account,
|
||||||
|
gnc_commodity * to_commodity)
|
||||||
|
{
|
||||||
|
GNCPrice *price;
|
||||||
|
GNCPriceDB *pricedb;
|
||||||
|
gnc_commodity *currency;
|
||||||
|
Transaction *txn;
|
||||||
|
Timespec date;
|
||||||
|
gnc_numeric amount, convrate;
|
||||||
|
gboolean div = FALSE;
|
||||||
|
|
||||||
|
amount = xaccSplitGetAmount (split);
|
||||||
|
|
||||||
|
/* If this split is attached to this account, then grab the amount
|
||||||
|
* because we know what it is
|
||||||
|
*/
|
||||||
|
if (xaccSplitGetAccount (split) == account)
|
||||||
|
return amount;
|
||||||
|
|
||||||
|
/* otherwise, we need to compute the amount from the conversion
|
||||||
|
* rate from the pricedb
|
||||||
|
*/
|
||||||
|
pricedb = gnc_book_get_pricedb (xaccSplitGetBook (split));
|
||||||
|
txn = xaccSplitGetParent (split);
|
||||||
|
currency = xaccTransGetCurrency (txn);
|
||||||
|
xaccTransGetDatePostedTS (txn, &date);
|
||||||
|
|
||||||
|
price = gnc_pricedb_lookup_nearest_in_time (pricedb, to_commodity,
|
||||||
|
currency, date);
|
||||||
|
if (price)
|
||||||
|
div = TRUE;
|
||||||
|
else
|
||||||
|
price = gnc_pricedb_lookup_nearest_in_time (pricedb, currency, to_commodity,
|
||||||
|
date);
|
||||||
|
if (!price)
|
||||||
|
return amount;
|
||||||
|
|
||||||
|
convrate = gnc_price_get_value (price);
|
||||||
|
gnc_price_unref (price);
|
||||||
|
|
||||||
|
if (div)
|
||||||
|
return gnc_numeric_div (amount, convrate,
|
||||||
|
gnc_commodity_get_fraction (to_commodity),
|
||||||
|
GNC_RND_ROUND);
|
||||||
|
else
|
||||||
|
return gnc_numeric_mul (amount, convrate,
|
||||||
|
gnc_commodity_get_fraction (to_commodity),
|
||||||
|
GNC_RND_ROUND);
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
||||||
gboolean translate,
|
gboolean translate,
|
||||||
@ -1268,19 +1319,23 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
SplitRegister *reg = user_data;
|
SplitRegister *reg = user_data;
|
||||||
gboolean is_debit;
|
gboolean is_debit;
|
||||||
Split *split;
|
Split *split;
|
||||||
|
Transaction *trans;
|
||||||
|
gnc_commodity *currency;
|
||||||
|
|
||||||
is_debit = gnc_cell_name_equal
|
is_debit = gnc_cell_name_equal
|
||||||
(gnc_table_get_cell_name (reg->table, virt_loc), DEBT_CELL);
|
(gnc_table_get_cell_name (reg->table, virt_loc), DEBT_CELL);
|
||||||
|
|
||||||
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
||||||
|
trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
|
||||||
|
|
||||||
|
currency = xaccTransGetCurrency (trans);
|
||||||
|
if (!currency)
|
||||||
|
currency = gnc_default_currency ();
|
||||||
|
|
||||||
if (!split)
|
if (!split)
|
||||||
{
|
{
|
||||||
Transaction *trans;
|
|
||||||
gnc_numeric imbalance;
|
gnc_numeric imbalance;
|
||||||
gnc_commodity *currency;
|
|
||||||
|
|
||||||
trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
|
|
||||||
imbalance = xaccTransGetImbalance (trans);
|
imbalance = xaccTransGetImbalance (trans);
|
||||||
|
|
||||||
if (gnc_numeric_zero_p (imbalance))
|
if (gnc_numeric_zero_p (imbalance))
|
||||||
@ -1298,11 +1353,6 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
*conditionally_changed = TRUE;
|
*conditionally_changed = TRUE;
|
||||||
|
|
||||||
imbalance = gnc_numeric_abs (imbalance);
|
imbalance = gnc_numeric_abs (imbalance);
|
||||||
|
|
||||||
currency = xaccTransGetCurrency (trans);
|
|
||||||
if (!currency)
|
|
||||||
currency = gnc_default_currency ();
|
|
||||||
|
|
||||||
imbalance = gnc_numeric_convert (imbalance,
|
imbalance = gnc_numeric_convert (imbalance,
|
||||||
gnc_commodity_get_fraction (currency),
|
gnc_commodity_get_fraction (currency),
|
||||||
GNC_RND_ROUND);
|
GNC_RND_ROUND);
|
||||||
@ -1314,7 +1364,31 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
|||||||
{
|
{
|
||||||
gnc_numeric amount;
|
gnc_numeric amount;
|
||||||
|
|
||||||
|
/* If this account is not a stock/mutual/currency account, and currency !=
|
||||||
|
* the account commodity, then use the SplitAmount instead of the SplitValue.
|
||||||
|
*/
|
||||||
|
switch (reg->type) {
|
||||||
|
case STOCK_REGISTER:
|
||||||
|
case CURRENCY_REGISTER:
|
||||||
amount = xaccSplitGetValue (split);
|
amount = xaccSplitGetValue (split);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
Account *account;
|
||||||
|
gnc_commodity * commodity;
|
||||||
|
|
||||||
|
account = gnc_split_register_get_default_account (reg);
|
||||||
|
commodity = xaccAccountGetCommodity (account);
|
||||||
|
|
||||||
|
if (commodity && !gnc_commodity_equal (commodity, currency))
|
||||||
|
/* Convert this to the "local" value */
|
||||||
|
amount = gnc_split_register_convert_amount (split, account, commodity);
|
||||||
|
else
|
||||||
|
amount = xaccSplitGetValue (split);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gnc_numeric_zero_p (amount))
|
if (gnc_numeric_zero_p (amount))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user