Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 2.66 KB

0700_fava.md

File metadata and controls

68 lines (46 loc) · 2.66 KB

Visualizing Reports in Fava {#sec:fava}

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.

Converting to Beancount {#sec:use_ledger2beancount}

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

Running Fava

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:

  1. Income Statement -> Net Profit. This is a cashflow analysis, Income minus Expenses.
  2. 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.

Integrating Beancount & Fava in your Makefile

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) $< > $@