;examples: debconf: more reports, all.ledger

This commit is contained in:
Simon Michael 2026-01-09 16:15:02 -10:00
parent 343f957cad
commit 1feebd0813
3 changed files with 46 additions and 33 deletions

View File

@ -1,7 +1,4 @@
recent: \
dc24 \
dc25 \
# download ledgers for all years
all: \
dc17 \
dc18 \
@ -12,12 +9,19 @@ all: \
dc23 \
dc24 \
dc25 \
# dc26 \
# make dc-YY - clone the budget directory for this year and make it hledger-readable
recent: \
dc24 \
dc25 \
# dc26 \
# make dc-YY - clone the budget directory for this year, make it hledger-readable, add a top-level file
dc%:
git clone --filter=blob:none --sparse http://salsa.debian.org/debconf-team/public/data/$@
git -C $@ sparse-checkout set --no-cone budget '!budget/invoices'
git -C $@ apply --allow-empty ../patches/$@.patch
printf 'include $@/budget/journal.ledger\ninclude $@/budget/forex.db\n' > 20$*.ledger
# make check-ledger, check-hledger - check readability of all years (main journal)
check-%:
@ -27,29 +31,17 @@ check-%:
hledger-%:
@for d in dc*; do printf "\n$$d:\n"; hledger -f $$d/budget/journal.ledger $*; done
stats:
@make -s hledger-stats
accounts:
@make -s hledger-accounts
is:
@make -s hledger-'is -2'
bs:
@make -s hledger-'bs -2'
# maintenance
clean:
rm -rf dc*
rm -rf dc* 2*.ledger
# make rg-PAT - ripgrep for PAT in ledger,inc,db files in all years
rg-%:
rg -g '*.{ledger,inc,db}' '$*'
# apply hledger readability fixes to all years
# make all years hledger-readable
fixups:
# ensure at least two whitespace chars before amounts:
sed -i -E 's/(\w)\t(\w)/ \t/' dc*/budget/*.ledger

View File

@ -1,25 +1,41 @@
# DebConf ledgers
DebConf does their accounting with Ledger.
Eg: <https://salsa.debian.org/debconf-team/public/data/dc25/-/tree/main/budget>
DebConf has done their accounting with Ledger since 2017.\
Eg: <https://salsa.debian.org/debconf-team/public/data/dc25/-/tree/main/budget>\
Here are some scripts and notes to help view them with hledger.
Each year has its own repo, and the repos are big.
To clone just the accounting data for a few recent years: `make`\
Or to clone all years, starting 2017: `make all`
Each year has its own repo, and the repos are big.\
To clone just the accounting data for all years: `make`\
Or to clone just a few recent years: `make recent`
Some patches for hledger readability will be applied; those might need updating from time to time.\
To check hledger readability: `make check-hledger`\
To check ledger readability: `make check-ledger`
To run some basic reports in all years:
For convenient reporting, a top-level journal file is created for each year's repo.\
These also include the forex.db files, allowing currency conversion (when rates exist; you might need to fetch more).\
- `make is`
- `make bs`
- `make accounts`
- `make stats | grep 'Txns '`
The `hledger.conf` file sets a few non-essential defaults when you are in this directory.\
Here are hledger's
[manual](https://hledger.org/hledger.html)
and [other docs](https://hledger.org/doc.html).
To run an any hledger report in all years: `make hledger-'ARGS'`\
Eg:
## Report examples
- `make hledger-'activity -W'`
- `make hledger-'is -tYT --layout=bare'`
Single year reports:
- `hledger -f 2025.ledger is`
- `hledger -f 2025.ledger is -V`
- `hledger -f 2025.ledger is -VQSTt --drop 1`
The `all.ledger` file reads all the downloaded repos at once:
- `hledger -f all.ledger is -1 -YTN`
- `hledger -f all.ledger is -1 -YT -X USD`
`make hledger-'ARGS'` runs a hledger command in each downloaded repo:
- `make hledger-accounts`
- `make hledger-stats | grep 'Txns '`
- `make hledger-'bs -2'`
- `make hledger-'is -2`

View File

@ -0,0 +1,5 @@
alias Expenses=expenses
alias incomes=income
alias Incomes=income
include 2*.ledger