From 1feebd0813763790c235abf9a89765cfed7d1cd0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 9 Jan 2026 16:15:02 -1000 Subject: [PATCH] ;examples: debconf: more reports, all.ledger --- examples/debconf/Makefile | 30 ++++++++++--------------- examples/debconf/README.md | 44 +++++++++++++++++++++++++------------ examples/debconf/all.ledger | 5 +++++ 3 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 examples/debconf/all.ledger diff --git a/examples/debconf/Makefile b/examples/debconf/Makefile index c135357c0..f31df5e42 100644 --- a/examples/debconf/Makefile +++ b/examples/debconf/Makefile @@ -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 diff --git a/examples/debconf/README.md b/examples/debconf/README.md index d93987303..7774b23e2 100644 --- a/examples/debconf/README.md +++ b/examples/debconf/README.md @@ -1,25 +1,41 @@ # DebConf ledgers -DebConf does their accounting with Ledger. -Eg: +DebConf has done their accounting with Ledger since 2017.\ +Eg: \ +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` diff --git a/examples/debconf/all.ledger b/examples/debconf/all.ledger new file mode 100644 index 000000000..05d0a1f53 --- /dev/null +++ b/examples/debconf/all.ledger @@ -0,0 +1,5 @@ +alias Expenses=expenses +alias incomes=income +alias Incomes=income + +include 2*.ledger