<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>419975</bug_id>
          
          <creation_ts>2020-04-12 02:19:47 +0000</creation_ts>
          <short_desc>When importing transactions, we&apos;re matching against the other transactions also being imported</short_desc>
          <delta_ts>2020-06-05 04:07:25 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kmymoney</product>
          <component>importer</component>
          <version>git (master)</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Dawid Wróbel">me</reporter>
          <assigned_to name="KMyMoney Devel Mailing List">kmymoney-devel</assigned_to>
          
          
          <cf_commitlink>https://commits.kde.org/kmymoney/84d204b26fd449f501d4f7cb360adad7def73627</cf_commitlink>
          <cf_versionfixedin>5.1.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1921664</commentid>
    <comment_count>0</comment_count>
      <attachid>127457</attachid>
    <who name="Dawid Wróbel">me</who>
    <bug_when>2020-04-12 02:19:47 +0000</bug_when>
    <thetext>Created attachment 127457
Sample CSV file

SUMMARY
While importing investment transactions from CSV file today, I noticed that one of the transactions was missing. Specifically, two of the transactions were similar enough for the TransactionMatcher to drop one of them and reconcile the other. Despite having same quantities, prices and date, the transactions have different memo, so it&apos;s understandable that it considers them a loose match.

However, those two shouldn&apos;t even be matched against each other, since both are being imported from external source. I can see in the mymoneystatementreader.cpp that this is indeed aimed to be handled properly by checking if a transaction isImported():

    if (result == TransactionMatchFinder::MatchDuplicate
      || !matchedTransaction.isImported()
      || result == TransactionMatchFinder::MatchPrecise) { // don&apos;t match with just imported transaction

However, the CSV importer doesn&apos;t set it for its transactions, unlike the QIF importer. Note that the latter is the *only* importer that has any usage of setImported() in its code, so I presume other importers may be affected as well.

STEPS TO REPRODUCE
1. Import the CSV file attached


OBSERVED RESULT
Only one of the two transactions was imported.


EXPECTED RESULT
Both should be.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921667</commentid>
    <comment_count>1</comment_count>
    <who name="Dawid Wróbel">me</who>
    <bug_when>2020-04-12 03:42:00 +0000</bug_when>
    <thetext>Actually, after reading the code further I stand corrected - isImported() is a member of MyMoneyTransaction, while CSV importer uses the MyMoneyStatement::Transaction.

The MyMoneyStatementReader::processTransactionEntry() actually correctly sets the transactionUnderImport.setImported(). The actual issue is with the conditional expression I previously referred to – the !isImported() condition should not be optional. Proposed resolution:

-      if (result == TransactionMatchFinder::MatchDuplicate
-      || !matchedTransaction.isImported()
-      || result == TransactionMatchFinder::MatchPrecise) { // don&apos;t match with just imported transaction
+      if (!matchedTransaction.isImported() &amp;&amp;
+      (result == TransactionMatchFinder::MatchDuplicate || result == TransactionMatchFinder::MatchPrecise)) { // don&apos;t match with just imported transaction

Let</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921668</commentid>
    <comment_count>2</comment_count>
    <who name="Dawid Wróbel">me</who>
    <bug_when>2020-04-12 03:54:18 +0000</bug_when>
    <thetext>Git commit 295d003c977ee67e2af7d76a14a39869c599ac9e by Dawid Wróbel.
Committed on 12/04/2020 at 03:53.
Pushed by wrobelda into branch &apos;master&apos;.

When importing transactions, make sure not to match against the transactions already imported during the same session.

M  +2    -3    kmymoney/converter/mymoneystatementreader.cpp

https://commits.kde.org/kmymoney/295d003c977ee67e2af7d76a14a39869c599ac9e</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921675</commentid>
    <comment_count>3</comment_count>
    <who name="Dawid Wróbel">me</who>
    <bug_when>2020-04-12 06:04:21 +0000</bug_when>
    <thetext>Git commit 5bcf3cf9db2f689aefc7d9c3459ac0a496075c85 by Dawid Wróbel.
Committed on 12/04/2020 at 06:00.
Pushed by wrobelda into branch &apos;master&apos;.

Revert the fix which broke duplicate transaction detection between imports.

This reverts commit 295d003c977ee67e2af7d76a14a39869c599ac9e.

M  +3    -2    kmymoney/converter/mymoneystatementreader.cpp

https://commits.kde.org/kmymoney/5bcf3cf9db2f689aefc7d9c3459ac0a496075c85</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921685</commentid>
    <comment_count>4</comment_count>
    <who name="Thomas Baumgart">thb</who>
    <bug_when>2020-04-12 07:57:05 +0000</bug_when>
    <thetext>Git commit 1655f78fd9bcbb3c23f2a5c8d8d4cf05a61823a0 by Thomas Baumgart.
Committed on 12/04/2020 at 07:55.
Pushed by tbaumgart into branch &apos;5.0&apos;.

Make sure bankID is assigned when importing transactions

The bankID member of a split is the ultimate identifier to detect
duplicate transactions. Yet if empty it is not used and transactions of
the same import session are falsely detected as duplicates.

This change assigns a bankID in case it is empty based on the account
id, the post date, the payee name, the memo text, and the amount which
makes the bankID unique for the import session.
FIXED-IN: 5.0.9

M  +26   -17   kmymoney/converter/mymoneystatementreader.cpp

https://commits.kde.org/kmymoney/1655f78fd9bcbb3c23f2a5c8d8d4cf05a61823a0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922883</commentid>
    <comment_count>5</comment_count>
    <who name="Dawid Wróbel">me</who>
    <bug_when>2020-04-15 22:51:22 +0000</bug_when>
    <thetext>Git commit 84d204b26fd449f501d4f7cb360adad7def73627 by Dawid Wróbel.
Committed on 15/04/2020 at 22:49.
Pushed by wrobelda into branch &apos;bug-420056&apos;.

Add option to enable fixing of the buy/sell signs

Some providers do not follow the OFX spec and do not assign the correct
positive/negative signage to amount (TOTALs) and quantity (UNITs)
values assosciated with BUY/SELL investment transactions (see OFX2.2,
section 13.3.3). This change adds option to OFX import dialog and
account&apos;s online settings to force the signage to follow the the spec.
GUI:

M  +1    -0    kmymoney/plugins/ofx/import/dialogs/konlinebankingstatus.cpp
M  +19   -2    kmymoney/plugins/ofx/import/dialogs/konlinebankingstatusdecl.ui
M  +18   -1    kmymoney/plugins/ofx/import/importoption.ui
M  +96   -74   kmymoney/plugins/ofx/import/ofximporter.cpp

https://commits.kde.org/kmymoney/84d204b26fd449f501d4f7cb360adad7def73627</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>127457</attachid>
            <date>2020-04-12 02:19:47 +0000</date>
            <delta_ts>2020-04-12 02:19:47 +0000</delta_ts>
            <desc>Sample CSV file</desc>
            <filename>sample2.csv</filename>
            <type>text/csv</type>
            <size>213</size>
            <attacher name="Dawid Wróbel">me</attacher>
            
              <data encoding="base64">RGF0ZSxEZXNjLEZlZSxBbW91bnQsUHJpY2UsUXVhbnRpdHksT3BlcmF0aW9uDQozMC0wMS0yMDE0
LENvbnRyaWJ1dGlvbiBmb3IgZGF0ZSAgMDEvMDMvMjAxMSB0byAzMS8wMy8yMDExLDAsMC4wMywz
Ny4zNSwwLjAwMDgsQlVZDQozMC0wMS0yMDE0LENvbnRyaWJ1dGlvbiBmb3IgZGF0ZSAgMDEvMDEv
MjAxMSB0byAzMS8wMS8yMDExLDAsMC4wMywzNy4zNSwwLjAwMDgsQlVZ
</data>

          </attachment>
      

    </bug>

</bugzilla>