Advertisement
Guest User

Untitled

a guest
Apr 17th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. module PensionsCalculator
  2. class RioCalc
  3.  
  4. def initialize(potsize)
  5. @potsize = potsize
  6. end
  7.  
  8. def run_calc()
  9. person = PensionsCalculator::Person.new;
  10. person.salary = 50000;
  11.  
  12. contributions = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
  13. terms = [1,3,5,10,15,20,30]
  14.  
  15. contributions.each { |cont|
  16.  
  17. print "#{@potsize}, #{cont},"
  18.  
  19. terms.each { |term|
  20. 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));
  21. potvalue = pot.value_at(Date.new((2015+term), 02, 12))
  22. print " #{potvalue},"
  23. }
  24.  
  25. print "\n"
  26.  
  27. }
  28.  
  29. end
  30.  
  31. def get_slicing_numbers()
  32. person = PensionsCalculator::Person.new;
  33. person.salary = 50000;
  34. contribution = 0
  35.  
  36. lump_sum_percentages = [0, 0.05, 0.1, 0.2, 0.25, 0.5]
  37.  
  38. lump_sum_percentages.each { |percent|
  39. withdrawal = @potsize * percent
  40. tax_free_withdrawal = withdrawal * 0.25
  41. taxed_withdrawal = withdrawal * 0.75
  42.  
  43. remainder = @potsize - withdrawal
  44. 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));
  45. pot_in_ten_value = pot_in_ten.value_at(Date.new((2025), 02, 12)) # assuming looking for value in 10 years time
  46.  
  47. print "#{@potsize}, "
  48. print "#{percent*100}%, "
  49. print "#{withdrawal}, #{withdrawal*0.25}, #{withdrawal*0.75}, "
  50. print "#{pot_in_ten_value.round(2)}, "
  51. print "#{(pot_in_ten_value*0.25).round(2)}, "
  52. print "<<needs working out>>\n"
  53.  
  54. }
  55.  
  56. end
  57.  
  58. end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement