Leveraging fzf, dateseq, and ledger CLI to create an easy to navigate balance sheet simulation. In this example, it compares the impact on assets of buying a car vs renting a car. But you could use it for any kind of financial decision.
Using the arrow keys, you navigate from month to month. It gives you an idea of what your balance sheet would look like for any alternative that you’re considering.
Shell:
dateseq 2020-07 2025-01 --format %Y-%m | \
fzf --reverse --preview-window 90% --preview \
'ledger -f auto_simulatie.ldg bal --forecast "d<[2025]" buy rent --no-total --end {}'
Journal file:
commodity R$
note Brazilian Real
format R$ 1.000,00
nomarket
alias BRL
default
define car_price=R$ 60.300,00
define dealership_commission=0.03
define depreciation_yearly=0.06
define insurance_yearly=R$ 3.184,54
define maintenance_yearly=R$ 2.000
define opening_balance=R$ 100.000
define rental_price=R$ 2.000
define taxes_yearly=R$ 2.490
define transfer_fee=R$ 1.350
2020-06-30 Opening Balances
Buy:Assets:Cash (opening_balance)
Rent:Assets:Cash (opening_balance)
Equity:Opening Balances
2020-07-01 Dealership
Buy:Assets:Cash (-car_price - transfer_fee)
Buy:Assets:Car (car_price * (1 - dealership_commission))
Buy:Expenses:One-off:Transfer Fee (transfer_fee)
Buy:Expenses:One-off:Dealership Commission (car_price * dealership_commission)
;; Buy
~ Monthly
Buy:Assets:Car (-car_price * (depreciation_yearly / 12))
Buy:Expenses:Depreciation (car_price * (depreciation_yearly / 12))
Buy:Expenses:Taxes (taxes_yearly / 12)
Buy:Expenses:Insurance (insurance_yearly / 12)
Buy:Expenses:Maintenance (maintenance_yearly / 12)
Buy:Assets:Cash
;; Rent
~ Monthly
Rent:Expenses:Car Rental (rental_price)
Rent:Assets:Cash (-rental_price)
- fzf: https://github.com/junegunn/fzf
- dateseq: http://www.fresse.org/dateutils/
- ledger cli: https://www.ledger-cli.org/
- ledger tutorial: https://p.epij.nl/ledger-cli/accounting/2018/08/23/real-world-ledger-part-1/
- my Twitter: https://twitter.com/ppnlo
Share this recording
Link
Append ?t=30
to start the playback at 30s, ?t=3:20
to start the playback at 3m 20s.
Embed image link
Use snippets below to display a screenshot linking to this recording.
Useful in places where scripts are not allowed (e.g. in a project's README file).
HTML:
Markdown:
Embed the player
If you're embedding on your own page or on a site which permits script tags, you can use the full player widget:
Paste the above script tag where you want the player to be displayed on your page.
See embedding docs for additional options.
Download this recording
You can download this recording in asciicast v2 format, as a .cast file.
DownloadReplay in terminal
You can replay the downloaded recording in your terminal using the
asciinema play
command:
asciinema play 343330.cast
If you don't have asciinema CLI installed then see installation instructions.
Use with stand-alone player on your website
Download asciinema player from
the releases page
(you only need .js
and .css
file), then use it like this:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="asciinema-player.css" />
</head>
<body>
<div id="player"></div>
<script src="asciinema-player.min.js"></script>
<script>
AsciinemaPlayer.create(
'/assets/343330.cast',
document.getElementById('player'),
{ cols: 83, rows: 22 }
);
</script>
</body>
</html>
See asciinema player quick-start guide for full usage instructions.
Generate GIF from this recording
While this site doesn't provide GIF conversion at the moment, you can still do it yourself with the help of asciinema GIF generator utility - agg.
Once you have it installed, generate a GIF with the following command:
agg https://asciinema.org/a/343330 demo.gif
Or, if you already downloaded the recording file:
agg demo.cast demo.gif
Check agg --help
for all available options. You can change font
family and size, select color theme, adjust speed and more.
See agg manual for full usage instructions.