I submitted the following ledger-cli
feature request:
opened 07:26PM - 03 Nov 24 UTC
# Introduction
I'm using `ledger-cli` to model what happens to treasury, fede… ral reserve, and bank balance sheets given certain economic actions.
Here's a small 4 transaction example:
```
2020-01-01 bank borrows 1000 from fed
bank:assets:reserves:fed 1000
bank:liabilities:loan:fed -1000
;
fed:assets:loans:bank 1000
fed:liabilities:deposits:odhbdi -1000
2020-02-01 bank buys bonds from treasury
bank:assets:bonds 1000
bank:assets:reserves -1000
;
treasury:liabilities:treasury_debt -1000
treasury:assets:reserves 1000
;
fed:liabilities:deposits:odhbdi 1000 ; other deposits held by depository institutions
fed:liabilities:deposits:tga -1000 ; treasury general account
2020-03-01 treasury pays person for road using bank
treasury:assets:reserves -1000
treasury:expenses:road 1000
;
bank:assets:reserves:fed 1000
bank:liabilities:deposits:person -1000
;
person:equity:earnings:road -1000
person:assets:deposits:bank 1000
2020-04-01 bank repays fed loan
bank:liabilities:loan:fed 1000
bank:assets:reserves:fed -1000
;
fed:assets:loans:bank -1000
fed:liabilities:deposits:odhbdi 1000
```
# Displaying the balance sheets over time
I then display the balance sheet after each transaction, with a description of what led to that state.
This requires that I run something like the following (in PowerShell):
```
Write-Output 'bank borrows 1000 from fed'
ledger -f tmp.ledger balance --end 2020-01-02
Write-Output 'bank buys bonds from treasury'
ledger -f tmp.ledger balance --end 2020-02-02
Write-Output 'treasury pays person for road using bank'
ledger -f tmp.ledger balance --end 2020-03-02
```
The output looks like this:
![image](https://github.com/user-attachments/assets/1c059c94-0589-4127-864f-e6fea2faf2dd)
# Feature request
Instead of doing the above, it would be nice to be able to specify that I want to see the balance sheets at various points in time:
ledger -f tmp.ledger balance-sheets 2020-01-02, 2020-02-02, 2020-03-02
Then `ledger` could take care of showing a description taken from the transaction as well as the resulting balance sheet.
Maybe also support date ranges:
ledger -f tmp.ledger balance-sheets --start 2020-01-02 --end 2020-03-02
And if no dates are specified, the state after each transaction is shown:
ledger -f tmp.ledger balance-sheets
# Potential other uses
Even if folks aren't using ledger-cli in the above (admittedly probably unusual) way, it might be helpful for when folks are debugging transactions.
If this already exists in other PTA systems, feel free to mention them below!
hledger has it: https://hledger.org/hledger.html#report-intervals
hledger balancesheet --monthly
hledger bs -MATS
2 Likes
Thank you for pointing this out, @simonmic !
2 Likes
Here's a workaround that uses the ledger Python API:
opened 07:26PM - 03 Nov 24 UTC
# Introduction
I'm using `ledger-cli` to model what happens to treasury, fede… ral reserve, and bank balance sheets given certain economic actions.
Here's a small 4 transaction example:
```
2020-01-01 bank borrows 1000 from fed
bank:assets:reserves:fed 1000
bank:liabilities:loan:fed -1000
;
fed:assets:loans:bank 1000
fed:liabilities:deposits:odhbdi -1000
2020-02-01 bank buys bonds from treasury
bank:assets:bonds 1000
bank:assets:reserves -1000
;
treasury:liabilities:treasury_debt -1000
treasury:assets:reserves 1000
;
fed:liabilities:deposits:odhbdi 1000 ; other deposits held by depository institutions
fed:liabilities:deposits:tga -1000 ; treasury general account
2020-03-01 treasury pays person for road using bank
treasury:assets:reserves -1000
treasury:expenses:road 1000
;
bank:assets:reserves:fed 1000
bank:liabilities:deposits:person -1000
;
person:equity:earnings:road -1000
person:assets:deposits:bank 1000
2020-04-01 bank repays fed loan
bank:liabilities:loan:fed 1000
bank:assets:reserves:fed -1000
;
fed:assets:loans:bank -1000
fed:liabilities:deposits:odhbdi 1000
```
# Displaying the balance sheets over time
I then display the balance sheet after each transaction, with a description of what led to that state.
This requires that I run something like the following (in PowerShell):
```
Write-Output 'bank borrows 1000 from fed'
ledger -f tmp.ledger balance --end 2020-01-02
Write-Output 'bank buys bonds from treasury'
ledger -f tmp.ledger balance --end 2020-02-02
Write-Output 'treasury pays person for road using bank'
ledger -f tmp.ledger balance --end 2020-03-02
```
The output looks like this:
![image](https://github.com/user-attachments/assets/1c059c94-0589-4127-864f-e6fea2faf2dd)
# Feature request
Instead of doing the above, it would be nice to be able to specify that I want to see the balance sheets at various points in time:
ledger -f tmp.ledger balance-sheets 2020-01-02, 2020-02-02, 2020-03-02
Then `ledger` could take care of showing a description taken from the transaction as well as the resulting balance sheet.
Maybe also support date ranges:
ledger -f tmp.ledger balance-sheets --start 2020-01-02 --end 2020-03-02
And if no dates are specified, the state after each transaction is shown:
ledger -f tmp.ledger balance-sheets
# Potential other uses
Even if folks aren't using ledger-cli in the above (admittedly probably unusual) way, it might be helpful for when folks are debugging transactions.
Script is concise since it uses minimal_ledger.py :
import ledger
from core import *
from history_of_balances import *
ls = [xact for xact in ledger.read_journal('tmp.ledger').xacts()]
ledger_ = Ledger()
for transaction in ls:
ledger_.transactions.append(
Transaction(
transaction.date,
transaction.payee,
[Entry(str(post.account), float(post.amount)) for post in transaction.posts()]))
history_of_balances(ledger_)
Example output:
1 Like