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 -- compute the
implicit exchange rates for ALL transactions when necessary. No longer requires the pricedb for printing split values. This will display all transactions in the currency of the current account, regardless of the number of splits in the transaction. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7579 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
0e145bb03f
commit
bd83bc2a2f
@ -3,6 +3,12 @@
|
||||
implicit exchange rates for balanced, two-split transactions.
|
||||
Fixes bug #99083 (for real)
|
||||
|
||||
* src/register/ledger-core/split-register-model.c -- compute the
|
||||
implicit exchange rates for ALL transactions when necessary. No
|
||||
longer requires the pricedb for printing split values. This will
|
||||
display all transactions in the currency of the current account,
|
||||
regardless of the number of splits in the transaction.
|
||||
|
||||
2002-11-30 Herbert Thoma <herbie@hthoma.de>
|
||||
|
||||
* src/report/standard-reports/cash-flow.scm: Added new option
|
||||
|
@ -1267,14 +1267,14 @@ static gnc_numeric
|
||||
gnc_split_register_convert_amount (Split *split, Account * account,
|
||||
gnc_commodity * to_commodity)
|
||||
{
|
||||
GNCPriceDB *pricedb;
|
||||
gnc_commodity *currency, *acc_com;
|
||||
Transaction *txn;
|
||||
Timespec date;
|
||||
gnc_numeric amount, convrate;
|
||||
GList * price_list;
|
||||
gnc_numeric amount, value, convrate;
|
||||
GList * price_list, *splits;
|
||||
Account * split_acc;
|
||||
gboolean div = FALSE;
|
||||
Split *s;
|
||||
|
||||
amount = xaccSplitGetAmount (split);
|
||||
|
||||
@ -1304,30 +1304,29 @@ gnc_split_register_convert_amount (Split *split, Account * account,
|
||||
}
|
||||
|
||||
/* ... otherwise, we need to compute the amount from the conversion
|
||||
* rate from the pricedb
|
||||
* rate into _this account_. So, find the split into this account,
|
||||
* compute the conversion rate (based on amount/value), and then multiply
|
||||
* this times the split value.
|
||||
*/
|
||||
pricedb = gnc_book_get_pricedb (xaccSplitGetBook (split));
|
||||
currency = xaccTransGetCurrency (txn);
|
||||
xaccTransGetDatePostedTS (txn, &date);
|
||||
splits = xaccTransGetSplitList(txn);
|
||||
for (; splits; splits = splits->next) {
|
||||
s = splits->data;
|
||||
|
||||
if (xaccSplitGetAccount (s) != account)
|
||||
continue;
|
||||
|
||||
price_list = gnc_pricedb_lookup_at_time (pricedb, to_commodity, currency, date);
|
||||
if (price_list)
|
||||
div = TRUE;
|
||||
else
|
||||
price_list = gnc_pricedb_lookup_at_time (pricedb, currency, to_commodity, date);
|
||||
if (!price_list)
|
||||
return amount;
|
||||
amount = xaccSplitGetAmount (s);
|
||||
value = xaccSplitGetValue (s);
|
||||
convrate = gnc_numeric_div (amount, value, GNC_DENOM_AUTO, GNC_DENOM_LCD);
|
||||
|
||||
convrate = gnc_price_get_value (price_list->data);
|
||||
|
||||
if (div)
|
||||
return gnc_numeric_div (amount, convrate,
|
||||
value = xaccSplitGetValue (split);
|
||||
return gnc_numeric_mul (value, 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);
|
||||
}
|
||||
|
||||
/* If we reach here, do what we USED to do */
|
||||
return xaccSplitGetValue (split);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
Loading…
Reference in New Issue
Block a user