QHacc File Formats

## File Formats

This section of the manual is not particularly relevant for end-users, but I thought it could be useful for programmers trying to write Perl scripts, or Python scripts, or anything else, against the save files for QHacc. All these files are plain text files, readable only by the QHacc user account owner. In most of the files, the order of the fields is not important.

QHacc writes three files per account, plus a config file.

### The config File

Here is an example of a QHacc config file:

    MAINCOLOR=255 255 255
    ALTCOLOR=173 216 230
    LINESPERTRANS=2
    NUMACCTS=3
    SHOWINDEX=0
    ACCTFILES=acct0 acct1 acct2
    LOCATION=327 261 600 300
    FONT=-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1
    DATEFORMAT=AMERICAN
    DATESEPARATOR=/
    CSYMBOL=$
    DECORATION=1
    GRAPHTYPE=1
    TRANSTYPES=ATM DEP WD

This file is self-explanatory, I think. The colors are specified as "RED GREEN BLUE" and the location box is "LEFT TOP RIGHT BOTTOM."

### The acct.info File

Here is an example of an acct.info file.

    ACCTID=1
    PARENTID=0
    TYPE=0
    NAME=Account #1
    INSTITUTION=
    INSTADDR1=
    INSTADDR2=
    INSTCITY=
    INSTSTATE=
    INSTZIP=
    INSTCONTACT=
    INSTPHONE=
    INSTFAX=
    INSTEMAIL=
    ID=
    TAXABLE=Y
    BAL=0
    DEFAULTTRANSTYPE=DEP

This file is also very obvious, I think. The TYPE field specifies which type of account this file represents. The different types are:

TYPE number | Account Type
--- | ---
0 | Asset
1 | Liability
2 | Equity
3 | Expense
4 | Income

Each account must have a unique ACCTID number, but every other field is optional and doesn't have to be unique.

### The acct.trans/acct.mem Files

The acct.trans file holds all the transactions for an account. The acct.mem file holds the memorized transactions. Both files use the same format:

    NUMTRANS=3
    94||1||93||23||1431||Credit Card||||-100||Y||01/03/2000
    95||1||96||19||||gas station||||25.22||Y||01/06/2000
    97||1||98||18||||grocery store||||40.01||Y||01/06/2000

The NUMTRANS line must be the first line in the file. And it's a pretty rudimentary format, I admit, but it gets the job done reasonably well. And lest you think I just made it up when I started writing QHacc, this is actually the third revision of this file format. I'm proud to report that after going through three revisions of this format in three consecutive releases, it hasn't changed since. Here's a quick rundown of the previous versions, and the current version:

    VERSION 0.2
            A C E F G H I J

    VERSION 0.2.1
            A C D E F G H I J

    VERSION 0.2.5 and above
            A B C D E F G H I J (C and D repeat based on B)

    where
    A: transaction id (unique)
    B: number of splits
    C: transaction pair's id (double entry transactions only)
    D: transaction pair's owner account (double entry transactions only)
    E: number
    F: payee
    G: memo
    H: amount
    I: reconciled? (Y or N)
    J: date (MM/DD/YYYY)

The acct.mem file is the same as the acct.trans file. In fact, to make a transaction memorized without using QHacc, you can copy the line you want from the acct.trans file into the acct.mem file. Upon starting QHacc again, the transaction will be memorized!

### The Schedule File

PAYEE=ryan
MEMO=added with cron!
NUM=3517
RECO=N
ACCTS=4
SPLIT job
105.5 Checking
20 Savings
52.87 auto

The only thing that really has to be in there is the PAYEE tag, and the ACCTS tag. Order doesn't really matter, but the ACCTS section has to be at the end of the file. The account names are prefixed with the amount of the transaction in them, followed by some amount of whitespace. If you would prefer to use a percentage of the account balance as the amount, just put a percent sign (%) immediately following the number. This form might be handy if your bank gives you interest on account balances, or if your credit card charges a predictable fee based on the current balance. The percentage can be positive or negative. This format does not allow for comments. All transactions added in --cron mode will have that day's date as the transaction date. The account names specified must match available account names exactly. If you have two accounts with the same name, I guarantee one of the accounts will get the transaction. Finally, if you want a double-entry transaction inserted, you need to include two accounts, but if you give them different amounts, the first amount will be used for both transactions, and an error will be printed to the screen. You can avoid this error message by specifying "SPLIT" as one of the amounts. This is also a good idea if you want to schedule a transaction with percentages, but only for one account.