Csvimporter for invesment transactions

I am running KMyMoney Version 5.1.3-fc8f557ef from kmymoney-5.1-348-linux-gcc-x86_64.AppImage on Kubuntu Jammy.

I am trying to automate the importing of broker transactions for buy, sell, interest, dividend, and reinvestment transactions which I have been doing manually for a while. I think I am getting pretty close to a workable solution but I am seeing some things with the csvimporter that I can’t explain, namely:

For home currency accounts, an input transaction action of “Interest” or “Dividend” seems to be always mapped to a KMM income category of “Dividend” even for fixed income securities. The KMM Activity gets set to “Interest Income” or “Dividend” to match the broker transaction activity.

Transaction Date,Settlement Date,Activity Description,Description,Symbol,...
2024-02-21,2024-02-21,Dividend,iShares CDN perferred,TSE:CPD,....
2024-02-22,2024-02-22,Interest,iShares CDN index short bonds,TSE:XSB,....
2024-02-23,2024-02-23,Dividend,iShares CDN index short bonds,TSE:XSB,....
2024-02-24,2024-02-24,Interest,iShares CDN MSCI EAFE index,TSE:XIN,...

For non home currency accounts (USD in my case), the KMM activity gets set to the broker activity and the income category gets set to “_Dividend” even if that income category did not exist before the import.

Transaction Date,Settlement Date,Activity Description,Description,Symbol,...
2024-02-21,2024-02-21,DivReInv,BMO Dividend Fund F,BMO95146:CA, ...
2024-02-22,2024-02-22,DivReInv,BMO US$ MM BMO95801,BMO95801, ...
2024-02-23,2024-02-23,Dividend,Vanguard US large value,NYSEARCA:VTV, ...
2024-02-24,2024-02-24,Interest,iShares MSCI EAFE small cap,NASDAQ:SCZ, ...

When manually entering these transactions I could set the proper activity and income category. It is possible to configure the csvinporter to do the same? I don’t see anything in the csvimporterrc config file to tweak this.

Not really a full answer, but a few points on importing, which might explain some of the behavior. Internally, the activities of Dividend, Investment Income, and Yield are treated essentially identically. The Activity of an imported transaction is set by the csv importer, based on the value in the assigned column (including mapping unkown ones to one of the known ones.) The csv importer also assigns a Category, but this may be altered when KMM itself actually imports the transaction. (The csv importer, similar to all the other importers, reads the csv file and prepares a “statement” object (I’ve forgotten the exact term.) This object is then actually imported by some core KMyMoney code. The actual Category assigned to the resulting transaction depends on a number of factors, including whether the transaction is matched to an existing transaction. I do not know why the behavior would differ depending on whether the brokerage account is in your base currency or a different currency. I do know that _Dividend is the category used by KMM when it doesn’t absolutely know which category to use for a dividend activity, and the names of categories (such as “Dividend”) are not magic or recognized by KMM. Once you have a larger collection of imported transactions which you have adjusted to use you desired categories, future imports are more likely to match that mapping. However, this is not always the case. I have years of imported transactions from my broker (all imported as OFX) and I distinguish “dividends” from “foreign dividends” (which is usually consistent within a given security) but I still hoave to manually adjust more often than I expect.

Do take this all as subject to correction in terms of exact behavior, but it should give you an idea of what’s going on. Unfortunately, I do not know of any way to configure this behavior, in the csv or any other importer. To me, this makes sense, since there are no fixed Categories, and you can create any you want, to meet your needs. I suppose a “wishlist” bug to enable a way to force use of the exact category specified in an imported csv file might be reasonable, but I don’t know how easy it would be, and what unintended consequences there might be.