Advertisement
Guest User

Untitled

a guest
Aug 16th, 2020
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. * approximation
  2. | age | * |
  3. |-----+----|
  4. | 30 | 1 |
  5. | 35 | 2 |
  6. | 40 | 3 |
  7. | 45 | 4 |
  8. | 50 | 6 |
  9. | 55 | 7 |
  10. | 60 | 8 |
  11. | 67 | 10 |
  12. * yearly salary
  13. #+name:yearly-salary
  14. #+BEGIN_SRC sh :colnames '("year" "salary, $")
  15. for year in `seq 2018 $(date +%Y)` ; do
  16. hledger bal --forecast --invert -D income:salary -N -T -b $year -e $(($year + 1)) --value='end,$' -O csv --transpose \
  17. | sed -n "s/\\\$//;s/Total/$year/p"
  18. done
  19. #+END_SRC
  20. * yearly savings
  21. #+name:yearly-savings-levels
  22. #+BEGIN_SRC sh :exports results :var A1=savings-cash[,0] A2=savings-stocks[,0] A3=savings-bonds[,0] :colnames '("year" "savings, $")
  23. for year in `seq 2018 $(date +%Y)` ; do
  24. hledger bal $A1 $A2 $A3 -H -b $year -e $(($year + 1)) --value='end,$' -O csv \
  25. | sed -n "s/\\\$//;s/total/$year/p"
  26. done
  27. #+END_SRC
  28. * saving targets
  29. #+BEGIN_SRC elisp :var T1=yearly-salary T2=yearly-savings-levels :colnames '("year" "salary" "savings target" "actual savings" "percentage")
  30. (defun age-to-mul (age)
  31. (cond
  32. ((> 20 age) 0)
  33. ((> 45 age) (/ (- age 25) 5.0))
  34. ((> 50 age) (+ 4 (/ (- age 45) 2.5)))
  35. ((> 60 age) (+ 6 (/ (- age 50) 5.0)))
  36. ((> 67 age) (+ 8 (/ (- age 60) 3.5)))
  37. (t 10.0)))
  38. (join-tables T1 T2 (lambda (year salary savings)
  39. (let* ((age (- year 1983))
  40. (mul (age-to-mul age))
  41. (target (* salary mul))
  42. (percent (/ savings target .01)))
  43. (list
  44. year
  45. (format "$%.2f" salary)
  46. (format "$%.2f" target)
  47. (format "$%.2f" savings)
  48. (format "%.2f%%" percent)))))
  49. #+END_SRC
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement