-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathmaternity_benefits_calculator.rb
59 lines (51 loc) · 1.2 KB
/
maternity_benefits_calculator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module SmartAnswer::Calculators
class MaternityBenefitsCalculator < BirthCalculator
def test_period
period_start = qualifying_week.first - 51.weeks
period_end = expected_week.first - 1.day
period_start..period_end
end
def sunday_before_eleven_weeks(due_date)
result = Date.parse(due_date) - 11.weeks
result -= 1 while (result.cwday != 7)
result
end
def smp_rate
if due_date_before_7th_april_2013?
135.45
elsif due_date_before_6th_april_2014?
136.78
else
138.18
end
end
def ma_rate
if due_date_before_7th_april_2013?
135.45
elsif due_date_before_6th_april_2014?
136.78
else
138.18
end
end
def smp_lel
if due_date_before_14th_july_2013?
107
elsif due_date_before_6th_april_2014?
109
else
111
end
end
private
def due_date_before_7th_april_2013?
@due_date < Date.parse("7th April 2013")
end
def due_date_before_14th_july_2013?
@due_date < Date.parse("14th July 2013")
end
def due_date_before_6th_april_2014?
@due_date < Date.parse("6th April 2014")
end
end
end