How can I map my transactions to accounts in a QIF file?

三世轮回 提交于 2020-02-24 11:06:51

问题


Scenario

I have two accounts at a bank, and would like to import transactions into GnuCash. My bank only gives me CSV files, but it can at least put transactions for both accounts into a single CSV file.

These CSV files are, as is, un-parseable by GnuCash, so I decided I'd convert them to QIF files, as I can also add account information to each transaction — or so I've heard.

The trouble is, QIF is badly defined. I'm picking through various fragments of documentation, but I still can't figure out how to format my account information. Whatever I seem to do, GnuCash tells me that the file has account details for only one account, and pre-fills the account name with the name of the file.

What I've tried

Account with name for each transaction

!Account
NNameOfAccount
!Type:Bank
D01/01/16
T100.00
MSometext
PSomePayee
^

Account with name for each set of transactions in that account

!Account
NNameOfAccount

...transactions...

!Account
NNameOfOtherAccount

...transactions...

Account before each transaction

This one actually gets me through most of the import steps, and correctly maps both accounts. Trouble is, I'm then given a cryptic error message: 'A bug was detected while converting the QIF data.'

!Account
NNameOfAccount
^

!Type:Bank
D01/01/16
T100.00
MSometext
PSomePayee
^

!Account
NNameOfOtherAccount
^

!Type:Bank
D01/01/16
T100.00
MSometext
PSomePayee
^

Sources of interest

  • Introduction to the QIF file
  • GnuCash's idea of a QIF file
  • QIF on Wikipedia

tl;dr

How should I format a QIF file so that I can specify the name of the account for each transaction?


回答1:


I ran into the same issue. It was frustrating to find multiple explicit claims online that GnuCash supported multi-account QIF files with no explanation of what they should look like.

I ended up going through GnuCash source code and found that GnuCash has an internal switch to ignore account info in QIF files, and apparently that switch is on by default. Fortunately, it can be turned off with the !Clear:AutoSwitch directive. With that I was able to generate and import multi-account QIF files. Example:

!Clear:AutoSwitch

!Account
NAssets:Bank:Bank 1
^
!Type:Bank
D2016-12-10
T0.01
PPayday!
LIncome:Salary
^
D2016-11-10
T0.01
PPayday!
LIncome:Salary
^

!Account
NAssets:Bank:Bank 2
^
!Type:Bank
D2016-12-15
T-999.00
PRent
LExpenses:Rent
^


来源:https://stackoverflow.com/questions/35385935/how-can-i-map-my-transactions-to-accounts-in-a-qif-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!