class FortuneTeller::SocialSecurity
Represents a persons social security strategy
Attributes
pia[R]
Public Class Methods
new(fra_pia: nil, **base)
click to toggle source
Calls superclass method
# File lib/fortuneteller/social_security.rb, line 5 def initialize(fra_pia: nil, **base) @fra_pia = fra_pia super(**base) end
Private Instance Methods
gen_transform(date, benefit)
click to toggle source
# File lib/fortuneteller/social_security.rb, line 24 def gen_transform(date, benefit) self.class::Transform.new(date: date, holder: holder, benefit: benefit) end
gen_transforms(from:, to:, plan:)
click to toggle source
# File lib/fortuneteller/social_security.rb, line 12 def gen_transforms(from:, to:, plan:) benefit = get_benefit_amount(plan: plan).on(from) transforms = [] transforms.push gen_transform(from, benefit) if from.day == 1 current = from.next_month.at_beginning_of_month while current < to transforms.push gen_transform(current, benefit) current = current.next_month.at_beginning_of_month end transforms end
get_benefit_amount(plan:)
click to toggle source
# File lib/fortuneteller/social_security.rb, line 28 def get_benefit_amount(plan:) return @benefit unless @benefit.nil? if @start_date.day == 1 start_month = @start_date else start_month = @start_date.next_month.at_beginning_of_month end calc = FortuneTeller::Utils::SocialSecurity.new( dob: plan.send(@holder).birthday, start_month: start_month ) if not @fra_pia.nil? calc.fra_pia = @fra_pia else current_salary = plan.jobs.values.keep_if { |j| j.holder==@holder }.map(&:salary).sum puts "CURRENT SAL #{@holder} #{current_salary}" calc.estimate_pia(current_salary: current_salary, annual_raise: 0.98) end benefit = calc.calculate_benefit puts "BENEFIT #{benefit}" @benefit = plan.inflating_int(benefit, start_month) end