AUDIT: r16828 - gnucash/trunk/src/import-export/qif-import - Better handling of QIF Split transaction matching (#114724)

Derek Atkins warlord at cvs.gnucash.org
Sun Jan 6 11:02:15 EST 2008


Author: warlord
Date: 2008-01-06 11:02:14 -0500 (Sun, 06 Jan 2008)
New Revision: 16828
Trac: http://svn.gnucash.org/trac/changeset/16828

Modified:
   gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm
Log:
Better handling of QIF Split transaction matching (#114724)

  If a QIF split transaction is involved in a match then it always has
  priority. The other half of the match will always be the half that
  gets discarded, even if it is from an investment account.

Patch by Charles Day
BP

Modified: gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm
===================================================================
--- gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm	2008-01-06 15:51:06 UTC (rev 16827)
+++ gnucash/trunk/src/import-export/qif-import/qif-to-gnc.scm	2008-01-06 16:02:14 UTC (rev 16828)
@@ -1001,6 +1001,24 @@
       ;; otherwise: one-to-one, a normal single split match.
       (else 
        (cond 
+        ;; If one transaction has more splits than the other, mark the
+        ;; one with less splits, regardless of all other conditions.
+        ;; Otherwise, QIF split transactions will become mangled. For
+        ;; more information, see bug 114724.
+        ((< (length (qif-xtn:splits xtn))
+            (length (qif-xtn:splits other-xtn)))
+               (qif-xtn:mark-split xtn split)
+               (qif-import:merge-xtn-info xtn other-xtn)
+               (qif-split:set-matching-cleared!
+                (car match-splits) (qif-xtn:cleared xtn)))
+             
+        ((> (length (qif-xtn:splits xtn))
+            (length (qif-xtn:splits other-xtn)))
+               (qif-xtn:mark-split other-xtn (car match-splits))
+               (qif-import:merge-xtn-info other-xtn xtn)
+               (qif-split:set-matching-cleared!
+                split (qif-xtn:cleared other-xtn)))
+
         ;; this is a transfer involving a security xtn.  Let the 
         ;; security xtn dominate the way it's handled. 
         ((and (not action) o-action o-security)
@@ -1031,25 +1049,14 @@
             (qif-xtn:mark-split other-xtn (car match-splits))
             (qif-import:merge-xtn-info other-xtn xtn)
             (qif-split:set-matching-cleared! 
-             split (qif-xtn:cleared other-xtn)))))        
+             split (qif-xtn:cleared other-xtn)))))
         
-        ;; otherwise, this is a normal no-frills split match.  if one
-        ;; transaction has more splits than the other one,
-        ;; (heuristically) mark the one with less splits.
+        ;; Otherwise, this is a normal no-frills split match.
         (#t 
-         (if (< (length (qif-xtn:splits xtn))
-                (length (qif-xtn:splits other-xtn)))
-             (begin 
-               (qif-xtn:mark-split xtn split)
-               (qif-import:merge-xtn-info xtn other-xtn)
-               (qif-split:set-matching-cleared!
-                (car match-splits) (qif-xtn:cleared xtn)))
-             
-             (begin
-               (qif-xtn:mark-split other-xtn (car match-splits))
-               (qif-import:merge-xtn-info other-xtn xtn)
-               (qif-split:set-matching-cleared!
-                split (qif-xtn:cleared other-xtn))))))))))
+          (qif-xtn:mark-split other-xtn (car match-splits))
+          (qif-import:merge-xtn-info other-xtn xtn)
+          (qif-split:set-matching-cleared!
+           split (qif-xtn:cleared other-xtn))))))))
 
 
 (define (qif-import:merge-xtn-info from-xtn to-xtn)



More information about the gnucash-changes mailing list