From 9e1268d9347f9375865a5f52becb9d52f23eb3ad Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 14 Feb 2023 10:40:42 +0100 Subject: [PATCH] Bug 798600 - CSV import of multi-split security transactions fails to load capital gain - part 1 Transactions with capital gains processing can have splits in transaction currency with a zero amount and a non-zero value. To properly import those, prefer the value column even if transaction currency equals account commodity. Previous (wrong) assumption was that in case of a same-currency split, the amount would always be the value. --- gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp b/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp index 3c1496bcde2..354d2b6c891 100644 --- a/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp +++ b/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp @@ -758,15 +758,15 @@ void GncPreSplit::create_split (std::shared_ptr draft_trans) auto value = GncNumeric(); auto trans_curr = xaccTransGetCurrency(draft_trans->trans); auto acct_comm = xaccAccountGetCommodity(account); - if (gnc_commodity_equiv(trans_curr, acct_comm)) - value = amount; - else if (m_value || m_value_neg) + if (m_value || m_value_neg) { if (m_value) value += *m_value; if (m_value_neg) value -= *m_value_neg; } + else if (gnc_commodity_equiv(trans_curr, acct_comm)) + value = amount; else if (tamount) value = -*tamount; else if (m_price)