GitHub
New transactions

New transactions

The New Transactions tab imports one statement file into your journal. Ledgeline writes nothing until you have seen exactly what hledger proposes and pressed Write changes.

Drop a statement

Drag a file onto the dashed panel, or press Choose file… to pick one. Ledgeline takes one file at a time, because one import is one statement going into one journal. If the file is in a format it can’t read, such as a PDF, Ledgeline refuses it and says why.

The New Transactions tab before a drop: the dashed drop panel with its Choose file button

Ledgeline converts the file to a CSV and shows a short preview of the rows it read. It also reports anything it had to guess, such as the delimiter, the text encoding, or which sheet of a workbook it read. If the statement’s own totals don’t match its rows, it says so, which usually means a column was misread.

If the file is a QuickBooks Online Journal export, Ledgeline opens a different panel. See Importing from QuickBooks.

A file with several accounts

Some banks put every account in one download, especially QuickBooks Web Connect (.qbo) files. Ledgeline lists the accounts above the preview, each with the last four digits of its number, its type, how many transactions it holds and its balance. It reads one account at a time. Import the first, then choose the next and import that. Each account gets its own rules file and its own CSV, and the CSV name includes the last four digits (download-7592.csv). That keeps each account’s .latest record separate.

Choose a rules file

Under Read it with, Ledgeline lists the *.rules files beside your journal that fit this data, best match first. Each card shows a score, the signals behind it (for example, whether the columns and dates line up), and a sample of the transactions that file would produce. Pick the one whose sample looks right.

The last option, Don’t import, just save the CSV, writes the converted file and leaves your journal alone.

If no rules file fits, the list says so and offers Create rules file…. That drafts a new one from your data. See Creating a rules file. The same button appears under the list when files do fit, as Create a new rules file…. Use it when a file fits the columns but belongs to a different account. Every QBO file has the same columns, so a rules file written for one bank’s QBO fits every other bank’s too.

When files score the same percentage, the one whose name or account1 shares a word with the statement’s file name, or the account’s last four digits, is listed first. With amex-activity.qbo, amex.csv.rules comes before chase.csv.rules.

Where it goes

The Where it goes box has two fields.

Ledgeline always checks balances against the whole journal you opened, not only the file you are writing to. Two journals explains why that matters for split journals.

Check the statement balance

The Statement balance box is optional. Type the closing balance from your statement and the account it belongs to. OFX files often include the balance, and then Ledgeline fills it in for you.

Ledgeline checks the balance against your journal plus the new transactions. It reports “The balance reconciles” or says how far off it is. Tick Write it into the journal as a balance assertion if you want hledger to re-check that balance every time it reads the file.

Preview before writing

Press Test Import to run a dry run. It writes nothing: hledger works out what it would add, and Ledgeline shows the result under “Nothing has been written yet”. The panel shows:

If hledger rejects the import, the panel shows hledger’s error output unedited. It usually names the row it failed on.

Review before writing

Once the dry run is ready, two buttons appear between the proposed transactions and Write changes. They open the same card-by-card review the Journal uses, over the transactions this import would add.

The dry-run panel’s review strip, boxed: Review Unknowns 1 and Review All 5, a note that review is optional, and the Write changes button below it

Press u or r to open them from the keyboard.

Review here is optional, and nothing you do in it is written until you press Write changes. Categorizing, renaming, tagging, Reviewed and Ignore all become edits that Write changes applies along with the import. When you close the review after saving a card, the dry run runs again, and the proposed transactions show your edits exactly as they will be written. Reviewed writes the transaction with reviewed: and today’s date. Transactions you don’t review are written without the tag.

Write changes is always available. You can close the review halfway, or never open it, and the import writes whatever is left as hledger proposed it. Uncategorized rows stay in your fallback account, as they would without review.

A line under Write changes counts what the write will apply, for example “2 reviewed edits · 3 existing transactions edited”. If the import changed under an edit, for example because the rules file was edited in another tab, the line adds “K need another look”. Open it to see each such edit with what it does, and discard it or keep it.

The ledgeline import … command below doesn’t carry review edits. When you have some, a note under it says how many, and that the command line imports without them.

Similar transactions in two places

On an import card, Similar has two groups, each with its own count and its own check-all box.

Ledgeline holds edits to transactions already in the journal until you press Write changes, then applies them in the same write as the import. If you leave without writing, the journal is untouched. If the write fails, Ledgeline puts every file it changed back the way it was.

The ⋯ menu on an import card has no Open in full editor, because the transaction isn’t in a file yet, and no Settings, because the review always covers the whole import.

Remember as a rule

A card whose description or account you changed can save that change as a rule in the import’s rules file, so the next statement arrives already categorized. The toggle reads Remember as a rule. Press Shift+R or click it. It starts off on every card, so rules are only written when you ask.

An import card for HARDWARE STORE recategorized to expenses:home:supplies, with Remember as a rule on: Match description against hardware.*store, Then set account2 to expenses:home:supplies, Matches 1 of 5 rows in checking.csv, and the changed row expanded

Match says which column the rule tests and the pattern it looks for.

Then set lists what the rule assigns, one line per change on the card.

The values come from the card. To change one, change the card.

Under that, a live check runs the import again with the rule added to a temporary copy of the rules file: “Matches 1 of 5 rows in checking.csv · 0 already categorised”. The count covers the rows this import would add. “Already categorised” counts the matching rows another rule already handles. Expand “N would change” to see each affected row’s lines before and after. A pattern that matches nothing gets a warning.

The rule is saved when you save the card. Ledgeline adds it at the end of the rules file, because in hledger the last matching rule wins:

if %description hardware.*store
    account2 expenses:home:supplies

A whole record match has no field name: if hardware.*store. A ticked description adds a description Hardware Store line.

After saving, the dry run runs again with the new rule. Ledgeline drops the review edits the rule now covers, because the import produces them by itself. If the import can’t be regenerated with the new rule, the review shows hledger’s message above the cards. The rule is saved either way, and you can fix it under Edit Rules. If the rule can’t be saved, the card keeps your edits and the reason shows under the rule.

hledger reads % followed by a letter, digit, _ or - in a rule’s value as a CSV field reference. %description puts the row’s description there, and an unknown name such as %off puts nothing there. hledger has no way to write a literal % before a letter, so a description such as “50%off” can’t be set by a rule. The builder warns when a ticked line contains one. A % before a space, such as “50% off”, is written as it is.

Write the changes

Press Write changes. Ledgeline appends the text you just saw, unaltered, to the journal you chose. It applies any review edits to transactions already in the journal in the same write. It then tells hledger to record the import so the same rows aren’t proposed again. If that last step fails, Ledgeline restores the journal to how it was and reports the whole import as failed.

The result panel lists every file it wrote.

Re-sorting by date

hledger appends at the end of the file. If that leaves the journal out of date order, the result panel lists the transactions that would move and offers to re-sort the file. Re-sorting moves only transactions. Directives, include lines and comments stay where they are.

Re-downloading a statement

hledger de-duplicates imports by date. It remembers the newest date it imported from a CSV and skips every row on or before it. That works for statements that only ever grow, but not when you download the same period twice. A card charge that first appeared as a pending hold and later settled would never be updated.

Ledgeline can match rows by the bank’s own transaction id instead. Add this line to the rules file:

comment id:%fitid

OFX, QFX and QBO files carry a FITID for every transaction, and Ledgeline exposes it as the fitid column. A rules file Ledgeline drafts from one of those files already has the line. Commas are removed from the id on the way in (561,516 becomes 561516), because hledger ends a tag’s value at the first comma. Without that, two transactions whose ids differ only after a comma would look like the same transaction. With that line in place, every imported transaction carries an id: tag, and the dry run sorts each incoming row into one of four outcomes.

OutcomeWhat happens
NewNo transaction in the journal has this id. It is imported as usual.
UnchangedThe journal already has it, identically. It is skipped.
Status changedOnly the cleared status differs, such as a pending hold that has since cleared. Ledgeline updates the * or ! mark on the existing transaction.
ConflictingSomething else differs, such as the amount. The row is reported with the differences and never imported or edited.

The dry run lists the status changes and conflicts before you write anything. A conflict usually means you edited the transaction yourself, so Ledgeline leaves your version alone. Notes you add to a transaction’s comment don’t count as a difference.

Status changes only apply when the rules file sets a status field, and only to transactions in the file you are importing into. Rules files without an id: line keep hledger’s date-based behaviour exactly. Matching a re-download by row id has the details.

Doing it from a terminal

The dry-run panel shows a ledgeline import command for the import on screen. Run it from the folder that holds your journal to repeat the same import later with a new statement. For a file with several accounts, the command includes --statement N, which picks the Nth account, counting from 1. ledgeline import --help lists the options.