问题
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