#!/bin/bash
this_year=$(date +%Y)
last_year=$((this_year-1))
tax_year="$last_year-$this_year"
mkdir -p ~/work/tax/"$tax_year"
cd ~/work/tax/"$tax_year" || exit 1
cat ~/work/bux/commbank/transactions/{"$last_year"-{05..12},"$this_year"-{01..09}}-*.csv > income.csv
sed -i 's_\([^/]*\)/\([^/]*\)/\(20[^,]*\),_\3-\2-\1,_' income.csv
sort income.csv | sponge income.csv
grep -E "^($last_year-(0[7-9]|1[0-2])|$this_year-0[1-6])-" income.csv | sponge income.csv
grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2},"[^-]' income.csv | sponge income.csv
grep -v 'Credit Interest' income.csv | sponge income.csv
grep -v 'Return Woolworths Online' income.csv | sponge income.csv
$EDITOR income.csv
csvtool col 2 income.csv | sed '1s/^/0/' | tr -d \\n | sed '/$/s/$/\n/' | bc
