Merging
Last updated on Jan 06, 2021
The output of matching is a simple ledger-CLI
compatible text file. It’s perfectly fine to open and edit the file using your favorite text editor. Depending on whether every transaction is properly balanced, you may end up needing to.
To merge a ledger-cli compatible listing of transactions (e.g. transactions.ledger
below) in to your master.ledger
, use the ledger-scripts/merge.sh
as follows:
cd ~/Development/ledger-scripts
bash merge.sh ~/Downloads/transactions.ledger
If there are any problems with the merge, ledger will print them and the merge will fail. For example:
While balancing transaction from "/tmp/tmp.6lhsdICjqC", lines 24148-24149
> 2020-01-30 * NORDSTROM #0010 LYNNWOOD WA
> Liabilities:Credit Card:Chase 1234 $-80.97
Unbalanced remainder is:
$-80.97
Amount to balance against:
0
Error: Transaction does not balance
A few common reasons you’d have to make manual fixes:
- You want to split a transaction with an account not already in your
master.accounts
file. Editmaster.accounts
and add the account. - The transaction doesn’t balance. This happens if you skipped the transaction during matching or you tried to multi-split and made a mistake. Either run the matcher again or edit the ledger snippet and properly balance the transaction, adding new accounts as necessary in
master.accounts
.
If no errors were printed, you can assume the merge was successful. Next, I diff and make a commit.