I wrote ledgerplot.py (and Karen, sorry if it has bitrotted, I haven't touched it in a while), and when feasible I hope to generate nicer reports from hledger, but currently I generate such reports in plaintext format using ledger or hledger, and when necessary prettify them by hand, eg pasting into an invoice or spreadsheet or email to my tax accountant.

I save the command lines as shell scripts or aliases or in makefiles, since getting them right takes some work. Here are most of mine. Adapting the hledger commands for ledger should be straightforward. These may be old or inaccurate but hopefully they give some ideas. Questions/comments/alternatives welcome.


.bashrc
-------

alias 2006='hledger -f ~/personal/2006.ledger -B'
alias 2007='hledger -f ~/personal/2007.ledger -B'
alias 2008='hledger -f ~/personal/2008.ledger -B'
alias 2009='hledger -f ~/personal/current.ledger -B'
alias household='hledger -f ~/personal/household.ledger'
alias simon='hledger -f ~/personal/household.ledger print simon | hledger -f-'

alias today='hours -p today'
alias thisweek='hours -p thisweek'
alias lastweek='hours -p lastweek'
alias thismonth='hours -p thismonth'
alias lastmonth='hours -p lastmonth'
alias thisyear='hours -p thisyear'
alias lastyear='hours -p lastyear'


Makefile
--------

YEAR:=${shell date +%Y}
MONTHS=01 02 03 04 05 06 07 08 #09 10 11 12
LEDGER2=ledger2.6
LEDGER3=ledger -y %Y/%m/%d

convert-csv: # convert latest bank csv downloads to ledger files
        -...@mv ~/Desktop/{Checking,Savings,CreditCard}*.csv . 2>/dev/null
        hledger convert Checking1.csv "assets:bank:wells fargo:checking" 
wellsfargo.rules >Checking1.ledger
        hledger convert Savings2.csv "assets:bank:wells fargo:savings" 
wellsfargo.rules >Savings2.ledger
        hledger convert Savings3.csv "assets:bank:wells fargo:tax savings" 
wellsfargo.rules >Savings3.ledger
        hledger convert CreditCard4.csv "liabilities:credit cards:wells fargo" 
wellsfargo.rules >CreditCard4.ledger
        hledger -f wellsfargo.ledger print -blastmonth

daily-checking-balance: # show wells fargo checking balance by day, for reconciling
        hledger register --effective --period 'daily to today' --display 
'd>[last month]' 'wells fargo:checking'

monthly-balance-sheet: # show quick monthly balance sheets for this year @for m in $(MONTHS); do \ printf "end of $(YEAR)/$$m:\n\n"; \ hledger bal assets not:foreign liabilities -BE --depth 2 -e $(YEAR)/`expr $$m + 1`; \ echo; \
        done

ar-deposits: # show actual dates of bank deposits for accounts receivable
        @$(LEDGER3) reg receivable -B -l 'a<0' --effective


SCRIPTS
-------

#!/bin/sh # balancesheet [extraoptions]
echo "Balance sheet as of `date`"
echo "totals include sub-accounts"
echo
ledger2.6 -n --balance-format '%10T  %2_%-a\n' --display "l<=3" --basis 
--subtotal $* balance assets
echo
ledger2.6 -n --balance-format '%10T  %2_%-a\n' --display "l<=3" --basis 
--subtotal $* balance liabilities
echo
ledger2.6 -nE --balance-format '%10T  %2_%-a\n' --display "l<=4" --basis 
--subtotal $* balance equity
echo
echo "`ledger2.6 --balance-format '%10T  %2_%-a\n' --basis $* balance liabilities 
equity | tail -1`liabilities + equity"
echo
ledger2.6 --balance-format '%10T  %2_%-a\n' --basis $* balance assets 
liabilities | tail -2


#!/bin/sh # cashflowstatement [extraoptions] # cashflowstatement -p oct
echo "Cashflow statement"
echo "------------------"
ledger2.6 --balance-format '%10T  %2_%-a\n' --basis --subtotal $* balance 
assets liabilities


#!/bin/sh # profitandloss [extraoptions]
echo "Profit & Loss statement for `date +%Y` as of `date`"
echo "totals include sub-accounts"
echo
ledger2.6 -n --balance-format '%10(-T)  %2_%-a\n' --display "l<=3" --basis 
--subtotal $* balance income
echo
ledger2.6 -n --balance-format '%10(-T)  %2_%-a\n' --display "l<=2" --basis 
--subtotal $* balance expenses -equity
echo
ledger2.6 --balance-format '%10(-T)  %2_%-a\n' --basis $* balance income 
expenses -equity | tail -2

Reply via email to