Class: FortuneTeller::Utils::SocialSecurity
- Inherits:
-
Object
- Object
- FortuneTeller::Utils::SocialSecurity
- Defined in:
- lib/fortuneteller/utils/social_security.rb
Overview
Calculates adjusted benefit from PIA Based on www.ssa.gov/oact/quickcalc/early_late.html 11/16/2017
Defined Under Namespace
Classes: StartDateBounds
Instance Attribute Summary collapse
-
#pia ⇒ Object
Returns the value of attribute pia.
Instance Method Summary collapse
- #calculate_benefit ⇒ Object
- #estimate_pia(current_salary:, annual_raise:) ⇒ Object
- #fra_pia=(fra_pia) ⇒ Object
-
#initialize(dob:, start_month:) ⇒ SocialSecurity
constructor
A new instance of SocialSecurity.
Constructor Details
#initialize(dob:, start_month:) ⇒ SocialSecurity
Returns a new instance of SocialSecurity.
9 10 11 12 13 |
# File 'lib/fortuneteller/utils/social_security.rb', line 9 def initialize(dob:, start_month:) @dob = dob @adjusted_dob = (dob.day == 1 ? dob.yesterday : dob) @start_month = start_month.at_beginning_of_month end |
Instance Attribute Details
#pia ⇒ Object
Returns the value of attribute pia.
7 8 9 |
# File 'lib/fortuneteller/utils/social_security.rb', line 7 def pia @pia end |
Instance Method Details
#calculate_benefit ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fortuneteller/utils/social_security.rb', line 64 def calculate_benefit frm = full_retirement_month puts "FRM: #{frm}" return @pia if @start_month == frm if(@start_month < frm) min_rm = min_retirement_month raise bounds_error(start: @start_month, min: min_rm) if @start_month < min_rm early_benefit( months: month_diff(@start_month, frm) ) else max_rm = max_retirement_month raise bounds_error(start: @start_month, max: max_rm) if @start_month > max_rm late_benefit( months: month_diff(frm, @start_month) ) end end |
#estimate_pia(current_salary:, annual_raise:) ⇒ Object
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 |
# File 'lib/fortuneteller/utils/social_security.rb', line 15 def estimate_pia(current_salary:, annual_raise:) year = Date.today.year last_year = @start_month.year salary_history = {year => current_salary} ((@dob.year+18)..(year-1)).reverse_each do |y| salary_history[y] = (salary_history[y+1]/annual_raise).floor end if(last_year > year) ((year+1)..last_year).each do |y| salary_history[y] = (salary_history[y-1]*annual_raise).floor end end salaries = salary_history.map{|y, s| s*indexing_factors[y]} aime = (salaries.sort.last(35).reduce(:+)/(35.0*12)).floor puts "AIME #{aime}" if aime > bend_points[1] pia_62 = (0.9*bend_points[0]+0.32*(bend_points[1]-bend_points[0])+0.15*(aime-bend_points[1])).floor elsif aime > bend_points[0] pia_62 = (0.9*bend_points[0]+0.32*(aime-bend_points[0])).floor else pia_62 = (0.9*aime).floor end pia_adjusted = pia_62 ((@dob.year+63)..@start_month.year).each do |y| pia_adjusted = (pia_adjusted*(100+COLA_1975_START[y-1-1975])/100.0).floor end @pia = pia_adjusted end |
#fra_pia=(fra_pia) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fortuneteller/utils/social_security.rb', line 47 def fra_pia=(fra_pia) pia_adjusted = fra_pia if @start_month.year < full_retirement_month.year (@start_month.year..(full_retirement_month.year-1)).each do |y| pia_adjusted = (pia_adjusted/((100+COLA_1975_START[y-1975])/100.0)).floor end elsif @start_month.year > full_retirement_month.year puts "START GREATER" ((full_retirement_month.year+1)..@start_month.year).each do |y| puts "START: #{@start_month.year}, YEAR: #{y}" puts "PIA ADJ = #{pia_adjusted}" pia_adjusted = (pia_adjusted*(100+COLA_1975_START[y-1-1975])/100.0).floor end end @pia = pia_adjusted end |