2002-11-19 Christian Stimming <stimming@tuhh.de>

* src/engine/Scrub.c (xaccTransScrubCurrency): Add code to deal
	correctly with currency exchange transactions from 1.6. Fixes
	reported problems with importing 1.6 data files, #91505.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7511 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2002-11-19 22:31:47 +00:00
parent 21f030b7d1
commit 381734fa16
2 changed files with 53 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2002-11-19 Christian Stimming <stimming@tuhh.de>
* src/engine/Scrub.c (xaccTransScrubCurrency): Add code to deal
correctly with currency exchange transactions from 1.6. Fixes
reported problems with importing 1.6 data files, #91505.
2002-11-18 Benoit Grégoire <bock@step.polymtl.ca>
* src/import-export/Transaction-matcher.c: Change default "RECONCILE"
action from 'y' (reconciled) to'c' (cleared)

View File

@ -397,7 +397,7 @@ xaccTransScrubCurrency (Transaction *trans, GNCBook *book)
currency = xaccTransGetCurrency (trans);
if (currency) return;
currency = xaccTransFindOldCommonCurrency (trans, book);
if (currency)
{
@ -409,6 +409,52 @@ xaccTransScrubCurrency (Transaction *trans, GNCBook *book)
{
PWARN ("no common transaction currency found");
}
{
Split *sp;
int i;
for (i=0; (sp = xaccTransGetSplit (trans, i)); i++) {
if (!gnc_numeric_equal(xaccSplitGetAmount (sp),
xaccSplitGetValue (sp))) {
Account *acc = xaccSplitGetAccount (sp);
gnc_commodity *acc_currency = xaccAccountGetCommodity (acc);
if (acc_currency == currency) {
/* This Split needs fixing: The transaction-currency equals
the account-currency/commodity, but the amount/values are
inequal i.e. they still correspond to the security
(amount) and the currency (value). In the new model, the
value is the amount in the account-commodity -- so it
needs to be set to equal the amount (since the
account-currency doesn't exist anymore).
Note: Nevertheless we lose some information here. Namely,
the information that the 'amount' in 'account-old-security'
was worth 'value' in 'account-old-currency'. Maybe it would
be better to store that information in the price database?
But then, for old currency transactions there is still the
'other' transaction, which is going to keep that
information. So I don't bother with that here. -- cstim,
2002/11/20. */
/*PWARN ("## Error likely: Split '%s' Amount %s %s, value %s",
xaccSplitGetMemo (sp),
gnc_numeric_to_string (amount),
gnc_commodity_get_mnemonic (currency),
gnc_numeric_to_string (value));*/
xaccTransBeginEdit (trans);
xaccSplitSetValue (sp, xaccSplitGetAmount (sp));
xaccTransCommitEdit (trans);
}
/*else {
PWARN ("Ok: Split '%s' Amount %s %s, value %s %s",
xaccSplitGetMemo (sp),
gnc_numeric_to_string (amount),
gnc_commodity_get_mnemonic (currency),
gnc_numeric_to_string (value),
gnc_commodity_get_mnemonic (acc_currency));
}*/
}
}
}
}
/* ================================================================ */