Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * approximation
- | age | * |
- |-----+----|
- | 30 | 1 |
- | 35 | 2 |
- | 40 | 3 |
- | 45 | 4 |
- | 50 | 6 |
- | 55 | 7 |
- | 60 | 8 |
- | 67 | 10 |
- * yearly salary
- #+name:yearly-salary
- #+BEGIN_SRC sh :colnames '("year" "salary, $")
- for year in `seq 2018 $(date +%Y)` ; do
- hledger bal --forecast --invert -D income:salary -N -T -b $year -e $(($year + 1)) --value='end,$' -O csv --transpose \
- | sed -n "s/\\\$//;s/Total/$year/p"
- done
- #+END_SRC
- * yearly savings
- #+name:yearly-savings-levels
- #+BEGIN_SRC sh :exports results :var A1=savings-cash[,0] A2=savings-stocks[,0] A3=savings-bonds[,0] :colnames '("year" "savings, $")
- for year in `seq 2018 $(date +%Y)` ; do
- hledger bal $A1 $A2 $A3 -H -b $year -e $(($year + 1)) --value='end,$' -O csv \
- | sed -n "s/\\\$//;s/total/$year/p"
- done
- #+END_SRC
- * saving targets
- #+BEGIN_SRC elisp :var T1=yearly-salary T2=yearly-savings-levels :colnames '("year" "salary" "savings target" "actual savings" "percentage")
- (defun age-to-mul (age)
- (cond
- ((> 20 age) 0)
- ((> 45 age) (/ (- age 25) 5.0))
- ((> 50 age) (+ 4 (/ (- age 45) 2.5)))
- ((> 60 age) (+ 6 (/ (- age 50) 5.0)))
- ((> 67 age) (+ 8 (/ (- age 60) 3.5)))
- (t 10.0)))
- (join-tables T1 T2 (lambda (year salary savings)
- (let* ((age (- year 1983))
- (mul (age-to-mul age))
- (target (* salary mul))
- (percent (/ savings target .01)))
- (list
- year
- (format "$%.2f" salary)
- (format "$%.2f" target)
- (format "$%.2f" savings)
- (format "%.2f%%" percent)))))
- #+END_SRC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement