Files
ledgerpy/tools/report.sh

49 lines
864 B
Bash

#!/bin/sh
CSV_FILE="data.csv"
REPORT_MD="report.md"
REPORT_PDF="/home/felixm/report.pdf"
YEAR="2018-04"
HLEDGER="hledger balance -M -V -b $YEAR --depth 1 --transpose -o $CSV_FILE"
# Networth
$HLEDGER -H '^assets'
sed -i 's/\$//g' $CSV_FILE
python tofig.py $CSV_FILE "figure_1.png"
$HLEDGER '^assets'
sed -i 's/\$//g' $CSV_FILE
sed -i 's/assets/cashflow/g' $CSV_FILE
python tofig.py $CSV_FILE "figure_2.png" --type bar
$HLEDGER '^expenses'
sed -i 's/\$//g' $CSV_FILE
python tofig.py $CSV_FILE "figure_3.png" --type bar
$HLEDGER '^income'
sed -i 's/\$-//g' $CSV_FILE
python tofig.py $CSV_FILE "figure_4.png" --type bar
rm $CSV_FILE
cat > $REPORT_MD <<- EOM
# Financial Report
# Networth
![](figure_1.png)
# Cashflow
![](figure_2.png)
# Expenses
![](figure_3.png)
# Income
![](figure_4.png)
EOM
pandoc $REPORT_MD -o $REPORT_PDF
rm figure_*
rm $REPORT_MD