Fava is the best visualization tool for the Plaintext Accounting ecosystem as of this writing. Fava requires input in a specific variant of Ledger format used by Beancount, a Ledger-like that uses a more explicit syntax. Fortunately, we can convert Ledger to Beancount and be able to use Fava fully.
Having installed ledger2beancount
using the instructions in @sec:install_ledger2beancount, you can run it after making your own configuration file.
Listing: Running ledger2beancount
{#lst:running_l2b}
cp ledger2beancount.yml myl2b.yml
# edit myl2b.yml in your text editor!
bin/ledger2beancount --config myl2b.yml 2020.ledger > 2020.beancount
This one's simple!
Listing: Running fava
{#lst:running_fava}
fava 2020.beancount
Fava will run a webserver accessible via http://localhost:5000
. You can explore around the Fava interface, notably two views:
- Income Statement -> Net Profit. This is a cashflow analysis, Income minus Expenses.
- Balance Sheet -> Net Worth. This is a net worth analysis, Assets minus Liabilities.
You may see some errors on the left sidebar. ledger2beancount
can't handle 100% of all things, so sometimes Beancount still works while silently failing.
For example, balance assertions can be ambiguous, so ledger2beancount
converts in a way that Beancount will continue to work but not enforce the assertions.
It's OK, because any assertions you've made still guard your record in your original transaction log.
Move your ledger2beancount
installation into scripts/ledger2beancount
and
its configuration file into scripts
, as well.
Then, you can append @lst:makefile_fava to your Makefile
.
With that, you'll be able to run make fava
and know that the underlying
beancount-format file will be updated if you've made changes to the ledger
file from which it is produced.
That is the magic of make
!
Listing: Additional Makefile
tasks (Makefile.09.fava.txt
) {#lst:makefile_fava}
## beancount compat & fava
L2B = scripts/ledger2beancount
L2B_BIN = $(L2B)/bin/ledger2beancount
L2B_CONFIG = scripts/ledger2beancount.yml
BEANCOUNT_FILE=reports/$(LEDGER_FILE).beancount
.PHONY: beancount
beancount: $(BEANCOUNT_FILE) ## creates a beancount version of the ledger file
fava: $(BEANCOUNT_FILE) ## runs fava on the beancount version of the ledger file
fava $(<)
$(BEANCOUNT_FILE): $(LEDGER_FILE) $(L2B_CONFIG)
$(L2B_BIN) --config $(L2B_CONFIG) $< > $@