Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module PensionsCalculator
- class RioCalc
- def initialize(potsize)
- @potsize = potsize
- end
- def run_calc()
- person = PensionsCalculator::Person.new;
- person.salary = 50000;
- contributions = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
- terms = [1,3,5,10,15,20,30]
- contributions.each { |cont|
- print "#{@potsize}, #{cont},"
- terms.each { |term|
- pot = PensionsCalculator::Pot.new(current_pots: PensionsCalculator::CurrentPots.new(pot_1: @potsize), employee_contribution: PensionsCalculator::Contribution.new(salary: person.salary, value: cont*12), employer_contribution: PensionsCalculator::Contribution.new(salary: person.salary, value: 0));
- potvalue = pot.value_at(Date.new((2015+term), 02, 12))
- print " #{potvalue},"
- }
- print "\n"
- }
- end
- def get_slicing_numbers()
- person = PensionsCalculator::Person.new;
- person.salary = 50000;
- contribution = 0
- lump_sum_percentages = [0, 0.05, 0.1, 0.2, 0.25, 0.5]
- lump_sum_percentages.each { |percent|
- withdrawal = @potsize * percent
- tax_free_withdrawal = withdrawal * 0.25
- taxed_withdrawal = withdrawal * 0.75
- remainder = @potsize - withdrawal
- pot_in_ten = PensionsCalculator::Pot.new(current_pots: PensionsCalculator::CurrentPots.new(pot_1: remainder), employee_contribution: PensionsCalculator::Contribution.new(salary: person.salary, value: 0), employer_contribution: PensionsCalculator::Contribution.new(salary: person.salary, value: 0));
- pot_in_ten_value = pot_in_ten.value_at(Date.new((2025), 02, 12)) # assuming looking for value in 10 years time
- print "#{@potsize}, "
- print "#{percent*100}%, "
- print "#{withdrawal}, #{withdrawal*0.25}, #{withdrawal*0.75}, "
- print "#{pot_in_ten_value.round(2)}, "
- print "#{(pot_in_ten_value*0.25).round(2)}, "
- print "<<needs working out>>\n"
- }
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement