summaryrefslogtreecommitdiff
path: root/BudgetReport.sh
blob: 6db1e8c37a2dbb8d4c6f3b770cd322d12e70ec63 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
#
set -euo pipefail
tempdir=$(mktemp --tmpdir -d "budget.report.XXX")
#trap 'rm -rf "$tempdir"' EXIT
pushd "$tempdir"

# generate budget report
(cd /home/ben/fund ; \
  eval "$(direnv export bash 2>/dev/null)" ; \
  hledger @budget.args -O csv | csv2md) > budget.md

# generate analysis
today=$(date +%Y-%m-%d)
month=$(date +%Y-%m)
llm -m claude -s "Today is $today.
This is a budget report for Ben and Kate's household as CSV data.
The 'Account' column is the abbreviated account name.
The 'budget' column is how much we budgeted for this month.
The '$month' column is how much we actually spent so far this month.
Create a report that summarizes how much we have spent so far.
Make recommendations to help us stay under budget for the rest of the month.
Identify opportunities to save money or to make room in the budget.
We don't have to follow the budget strictly, but we want to keep monthly spending under \$10,000.
Be concise and to the point.
Don't offer follow-up tasks, this is a one-off report, not a conversation.

Account names are abbreviated like so:
- 'ex' means an expense account
- 'ex:us:need' are necessary operating expenses, these are consistent
  month-to-month and we don't have much room to reduce them in most cases
- 'ex:us:need:home' are mostly-fixed utilities, can't really change these
- 'ex:us:need:home:pool' is only active during the summer
= 'ex:us:need:auto' varies slightly month-to-month, but we cannot change it
- 'ex:us:want' are discretionary spending accounts, we have the most room for
  modification here
- 'ex:me' are Ben's personal expenses
- 'li' means a liability, these are mostly consistent and must be paid

" < budget.md > analysis.md


subject="Budget Report for $today"

cat analysis.md <(echo) <(echo) budget.md > email.md
pandoc --standalone --metadata title="$subject" \
  -f markdown_mmd -t html -i email.md -o email.html

email_args=(
  --to ben@bensima.com
  --to katesima21@gmail.com
  --to bsima@icloud.com
  --from ben@bensima.com
  --smtp-server bensima.com
  --subject "$subject"
  --body-text "$(realpath email.md)"
  --body-html "$(realpath email.html)"
)
popd
Biz/EmailAgent.py "${email_args[@]}" --password-file <(pass ben@bensima.com)