blob: 55db3e3b419ec80fcdc16846cd30a0574e01059d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/sh
file="2025-lmcu-checking-statements.csv"
if test "$1"; then
file="$1"
fi
rules="lmcu-checking.csv.rules"
if test "$2"; then
rules="$2"
fi
output="$(hledger -f"$file" --rules "$rules" balance --begin "$(date "+%Y-%m-01")")"
category() {
category="$1"
budget="$2"
amount="$(printf "%s" "$output" | grep "$category" | tr -d ',' | grep -o '[0-9.]*')"
if test -n "$amount"; then
monthlyprogress="$(python3 -c 'print('$(date +%d)' / '$(daysthismonth)')')"
overunder="$(python3 -c 'print(('$budget' * '$monthlyprogress') - '$amount')')"
printf "%s\t%.2f\t%f\t%.2f\n" "$category" "$amount" "$(python3 -c 'print('$amount' / '$budget')')" "$overunder"
else
printf "%s not found.\n" "$category" >/dev/stderr
fi
}
daysthismonth() {
python3 -c 'from datetime import date; print([0,31,28,31,30,31,30,31,31,30,31,30,31][date.today().month])'
}
category dining 250
category groceries 600
category gas 200
category shopping 450
category special 400
category health 610 #460 + 150
category mortgage 2934
category utilities 625
category charity 450
category fees 0.01
output="$(date +%d) date"
category date $(daysthismonth)
|