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.
This commit is contained in:
Geert Janssens 2023-02-14 10:40:42 +01:00
parent 3f3460fec9
commit 9e1268d934

View File

@ -758,15 +758,15 @@ void GncPreSplit::create_split (std::shared_ptr<DraftTransaction> 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)