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 0cc7d597b3..f9be07c191 100644 --- a/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp +++ b/gnucash/import-export/csv-imp/gnc-imp-props-tx.cpp @@ -720,9 +720,9 @@ void GncPreSplit::create_split (std::shared_ptr draft_trans) auto trans_curr = xaccTransGetCurrency(draft_trans->trans); auto acct_comm = xaccAccountGetCommodity(taccount); if (gnc_commodity_equiv(trans_curr, acct_comm)) - tamount = -amount; + tamount = tvalue; else if (m_price) - tamount = -amount * *m_price; + tamount = tvalue * m_price->inv(); else { QofBook* book = xaccTransGetBook (draft_trans->trans); @@ -733,14 +733,13 @@ void GncPreSplit::create_split (std::shared_ptr draft_trans) acct_comm, trans_curr, time); if (nprice) { - /* Found a usable price. Let's check if the conversion direction is right */ - GncNumeric rate; + /* Found a usable price. Let's check if the conversion direction is right + * Reminder: value = amount * price, or amount = value / price */ + GncNumeric rate = gnc_price_get_value(nprice); if (gnc_commodity_equiv(gnc_price_get_currency(nprice), trans_curr)) - rate = gnc_price_get_value(nprice); + tamount = tvalue * rate.inv(); else - rate = static_cast(gnc_price_get_value(nprice)).inv(); - - tamount = -amount * rate; + tamount = tvalue * rate; } else PWARN("No price found, defer creation of second split to generic import matcher."); diff --git a/gnucash/import-export/import-backend.cpp b/gnucash/import-export/import-backend.cpp index 3455ed61ae..af2ae6a96e 100644 --- a/gnucash/import-export/import-backend.cpp +++ b/gnucash/import-export/import-backend.cpp @@ -1117,9 +1117,11 @@ static void trans_info_calculate_dest_amount (GNCImportTransInfo *info) } else if (gnc_numeric_check(info->lsplit_price) == 0) { - /* We are in a multi currency situation and have a valid price */ + /* We are in a multi currency situation and have a valid price + * Reminder: value = amount * price => amount = value / price */ + gnc_numeric inv_price = gnc_numeric_invert (info->lsplit_price); info->lsplit_amount = gnc_numeric_mul (info->lsplit_value, - info->lsplit_price, + inv_price, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP); }