GNOME Bugzilla – Bug 515163
QIF Import: Eliminate pointless mappings
Last modified: 2018-06-29 22:01:01 UTC
Sometimes the QIF importer asks for unnecessary account, category and memo/payee mappings. These extra mappings don't harm the import, but asking for them is both pointless and confusing. The importer should stop requesting irrelevant mappings. I have identified several different situations in which this occurs. ========== = Case 1 = ========== Consider the following QIF file: !Option:AutoSwitch !Account NMy Investments TInvst ^ !Type:Invst D1/17' 8 NBuy YCitibank I0.50 Q4 Cc U2.00 T2.00 MBuy Memo ^ This transaction represents a purchase of stock, and is one of a variety of investment transactions that does not require an account or category to be specified. The brokerage and stock accounts are always used implicitly, so only the two account mappings are needed. However, the druid also asks for a blank category mapping (default: "Unspecified") and a memo/payee mapping (for "Buy Memo"), even though they will not be used. Investment transactions known to be affected by this behavior are those using the following actions on the "N" line: buy, cglong, cgmid, cgshort, div, intinc, margint, reinvdiv, reinvint, reinvlg, reinvmd, reinvsg, reinvsh, reminder, rtrncap, sell, shrsin, shrsout, and stksplit. ========== = Case 2 = ========== Consider the following QIF file: !Option:AutoSwitch !Account NMy Savings TBank ^ !Type:Bank D01/30/2008 T-10.00 PMy Payee ^ This transaction is missing an account or a category. The druid asks for a blank category mapping (default: "Unspecified") and for a memo/payee mapping for "My Payee". Although a mapping is needed to provide the missing information, it is not necessary to ask for more than one. Only the memo/payee mapping will be used. The category mapping has no effect or purpose, so there is no reason to ask for it. ========== = Case 3 = ========== Those investment transactions not covered in case 1 require an account or category to be explicitly specified and so mapping is needed. But the druid requests three for the missing piece of information: a blank account mapping (default: "Unspecified"), a blank category mapping (default: "Unspecified"), and a another for the memo/payee (for "Sell Memo"). An example QIF file for this would be: !Option:AutoSwitch !Account NMy Investments TInvst ^ !Type:Invst D1/19' 8 NSellX YCitibank I0.50 Q4 Cc U2.00 T2.00 MSell Memo
Created attachment 104699 [details] Sample QIF file This QIF file contains the three transactions shown in the bug description.
Created attachment 104702 [details] [review] Proposed patch This patch fixes all three cases discussed above. Tested on the sample QIF file and a very large file of personal transactions. NOTE: the patch includes a lot of whitespace changes, so I will also attach an easier-to-read diff that ignores them.
Created attachment 104703 [details] [review] Easier-to-read patch (svn diff -x -w) This is the same as the attached patch, but is easier to read because whitespace changes are ignored.
Is there some other way I should attach the easier-to-read patch so that it can be viewed as a diff instead of plain text?
(In reply to comment #4) > Is there some other way I should attach the easier-to-read patch so that it can > be viewed as a diff instead of plain text? I think just clicking the 'patch' checkbox is all one can do; then the "diff"-view becomes available. I've updated the "Easier-to-read patch" attachment as such. FWIW, though, I like the improved whitespace of your original patch. I guess it'd be ideal to have the functionality patch (ignoring whitespace) and a separate whitespace-correcting patch. But whatever. :)
I'm not suggesting that the easier-to-read patch to be applied - it's only for human eyes, just to make reviewing the patch a bit less time consuming. If you try to compare before and after with all the whitespace changes included, then the diff shows big blocks of changed code and it is hard to tell what really changed. In future, I guess I'll attach the easier-to-read patch first, as a patch, then attach the real patch second, and have the first patch marked as obsolete. I thought that plain text would work, because when you follow the "Edit" link there is a button that says "View as diff" (or similar). But it seems to have no effect.
Created attachment 105118 [details] [review] Revised patch (ignoring whitespace) This is the easy-to-read version of the revised patch. Do not apply to SVN.
Created attachment 105119 [details] [review] Revised patch This revised patch adds checks for non-existent payees and memos.
Brought the patch up to date and committed as r17186. Requesting backport for 2.2.
Applied to branches/2.2 as r17361 for inclusion in GnuCash 2.2.6. Thanks!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=515163. Please update any external references or bookmarks.