Commit e76470dd authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Use target account's commodity instead of base currency

When importing new transactions, use the target account's commodity
(which is set to target account's currency) since it may differ from the
base currency.

BUG: 419974
FIXED-IN: 5.0.9

(cherry picked from commit 181da28c)
parent b0c87004
......@@ -786,15 +786,14 @@ void MyMoneyStatementReader::processTransactionEntry(const MyMoneyStatement::Tra
&& statementTransactionUnderImport.m_eAction != eMyMoney::Transaction::Action::Shrsout) {
// update the price, while we're here. in the future, this should be
// an option
QString basecurrencyid = file->baseCurrency().id();
const MyMoneyPrice &price = file->price(currencyid, basecurrencyid, statementTransactionUnderImport.m_datePosted, true);
const MyMoneyPrice &price = file->price(currencyid, transactionUnderImport.commodity(), statementTransactionUnderImport.m_datePosted, true);
if (!price.isValid() && ((!statementTransactionUnderImport.m_amount.isZero() && !statementTransactionUnderImport.m_shares.isZero()) || !statementTransactionUnderImport.m_price.isZero())) {
MyMoneyPrice newprice;
if (!statementTransactionUnderImport.m_price.isZero()) {
newprice = MyMoneyPrice(currencyid, basecurrencyid, statementTransactionUnderImport.m_datePosted,
newprice = MyMoneyPrice(currencyid, transactionUnderImport.commodity(), statementTransactionUnderImport.m_datePosted,
statementTransactionUnderImport.m_price.abs(), i18n("Statement Importer"));
} else {
newprice = MyMoneyPrice(currencyid, basecurrencyid, statementTransactionUnderImport.m_datePosted,
newprice = MyMoneyPrice(currencyid, transactionUnderImport.commodity(), statementTransactionUnderImport.m_datePosted,
(statementTransactionUnderImport.m_amount / statementTransactionUnderImport.m_shares).abs(), i18n("Statement Importer"));
}
file->addPrice(newprice);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment