singapore_cpf_calculator 1.3.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +37 -0
  3. data/.rubocop.yml +81 -0
  4. data/.rubocop_todo.yml +326 -0
  5. data/README.md +2 -0
  6. data/lib/singapore_cpf_calculator/age_group.rb +27 -5
  7. data/lib/singapore_cpf_calculator/base_calculator.rb +14 -2
  8. data/lib/singapore_cpf_calculator/requirements/group_above_65_to_70_years.rb +13 -0
  9. data/lib/singapore_cpf_calculator/requirements/group_above_70_years.rb +13 -0
  10. data/lib/singapore_cpf_calculator/requirements.rb +3 -0
  11. data/lib/singapore_cpf_calculator/residency_module_common.rb +5 -1
  12. data/lib/singapore_cpf_calculator/version.rb +1 -1
  13. data/lib/singapore_cpf_calculator/year_2016.rb +2 -2
  14. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_55_below_contribution_calculator.rb +8 -0
  15. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
  16. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
  17. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_65_to_70_contribution_calculator.rb +32 -0
  18. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_70_up_contribution_calculator.rb +32 -0
  19. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3/citizen_or_spr3_base.rb +9 -0
  20. data/lib/singapore_cpf_calculator/year_2022/citizen_or_spr_3.rb +40 -0
  21. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg/age_55_below_contribution_calculator.rb +11 -0
  22. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
  23. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
  24. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg/age_65_to_70_contribution_calculator.rb +32 -0
  25. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg/age_70_up_contribution_calculator.rb +32 -0
  26. data/lib/singapore_cpf_calculator/year_2022/spr_1_fg.rb +40 -0
  27. data/lib/singapore_cpf_calculator/year_2022/spr_1_gg/age_55_below_contribution_calculator.rb +11 -0
  28. data/lib/singapore_cpf_calculator/year_2022/spr_1_gg/age_55_to_60_contribution_calculator.rb +12 -0
  29. data/lib/singapore_cpf_calculator/year_2022/spr_1_gg/age_60_to_65_contribution_calculator.rb +11 -0
  30. data/lib/singapore_cpf_calculator/year_2022/spr_1_gg/age_65_up_contribution_calculator.rb +14 -0
  31. data/lib/singapore_cpf_calculator/year_2022/spr_1_gg.rb +34 -0
  32. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg/age_55_below_contribution_calculator.rb +11 -0
  33. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
  34. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
  35. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg/age_65_to_70_contribution_calculator.rb +32 -0
  36. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg/age_70_up_contribution_calculator.rb +32 -0
  37. data/lib/singapore_cpf_calculator/year_2022/spr_2_fg.rb +40 -0
  38. data/lib/singapore_cpf_calculator/year_2022/spr_2_gg/age_55_below_contribution_calculator.rb +11 -0
  39. data/lib/singapore_cpf_calculator/year_2022/spr_2_gg/age_55_to_60_contribution_calculator.rb +11 -0
  40. data/lib/singapore_cpf_calculator/year_2022/spr_2_gg/age_60_to_65_contribution_calculator.rb +11 -0
  41. data/lib/singapore_cpf_calculator/year_2022/spr_2_gg/age_65_up_contribution_calculator.rb +11 -0
  42. data/lib/singapore_cpf_calculator/year_2022/spr_2_gg.rb +34 -0
  43. data/lib/singapore_cpf_calculator/year_2022.rb +35 -0
  44. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_below_contribution_calculator.rb +8 -0
  45. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
  46. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
  47. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_65_to_70_contribution_calculator.rb +32 -0
  48. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_70_up_contribution_calculator.rb +9 -0
  49. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/citizen_or_spr3_base.rb +8 -0
  50. data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3.rb +40 -0
  51. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_below_contribution_calculator.rb +11 -0
  52. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
  53. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
  54. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_65_to_70_contribution_calculator.rb +32 -0
  55. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_70_up_contribution_calculator.rb +8 -0
  56. data/lib/singapore_cpf_calculator/year_2023/spr_1_fg.rb +40 -0
  57. data/lib/singapore_cpf_calculator/year_2023/spr_1_gg.rb +29 -0
  58. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_below_contribution_calculator.rb +11 -0
  59. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
  60. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
  61. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_65_to_70_contribution_calculator.rb +32 -0
  62. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_70_up_contribution_calculator.rb +8 -0
  63. data/lib/singapore_cpf_calculator/year_2023/spr_2_fg.rb +40 -0
  64. data/lib/singapore_cpf_calculator/year_2023/spr_2_gg.rb +29 -0
  65. data/lib/singapore_cpf_calculator/year_2023/year_2023.rb +35 -0
  66. data/lib/singapore_cpf_calculator/year_2023.rb +35 -0
  67. data/lib/singapore_cpf_calculator.rb +10 -1
  68. data/singapore_cpf_calculator.gemspec +5 -3
  69. data/spec/singapore_cpf_calculator/age_group_spec.rb +15 -3
  70. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +1 -1
  71. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +2 -2
  72. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3_spec.rb +3 -3
  73. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +1 -1
  74. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +1 -1
  75. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +1 -1
  76. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_55_below_contribution_calculator_spec.rb +63 -0
  77. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
  78. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
  79. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_65_to_70_contribution_calculator_spec.rb +63 -0
  80. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3/age_70_up_contribution_spec.rb +63 -0
  81. data/spec/singapore_cpf_calculator/year_2022/citizen_or_spr_3_spec.rb +242 -0
  82. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  83. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  84. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  85. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
  86. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg/age_70_up_contribution_calculator_spec.rb +63 -0
  87. data/spec/singapore_cpf_calculator/year_2022/spr_1_fg_spec.rb +176 -0
  88. data/spec/singapore_cpf_calculator/year_2022/spr_1_gg/age_55_below_contribution_calculator_spec.rb +63 -0
  89. data/spec/singapore_cpf_calculator/year_2022/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  90. data/spec/singapore_cpf_calculator/year_2022/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  91. data/spec/singapore_cpf_calculator/year_2022/spr_1_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  92. data/spec/singapore_cpf_calculator/year_2022/spr_1_gg_spec.rb +158 -0
  93. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  94. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  95. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  96. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
  97. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg/age_70_up_contribution_calculator_spec.rb +63 -0
  98. data/spec/singapore_cpf_calculator/year_2022/spr_2_fg_spec.rb +176 -0
  99. data/spec/singapore_cpf_calculator/year_2022/spr_2_gg/age_55_below_contribution_calculator_spec.rb +63 -0
  100. data/spec/singapore_cpf_calculator/year_2022/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  101. data/spec/singapore_cpf_calculator/year_2022/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  102. data/spec/singapore_cpf_calculator/year_2022/spr_2_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  103. data/spec/singapore_cpf_calculator/year_2022/spr_2_gg_spec.rb +158 -0
  104. data/spec/singapore_cpf_calculator/year_2022_spec.rb +192 -0
  105. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_below_contribution_calculator_spec.rb +63 -0
  106. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
  107. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
  108. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_65_to_70_contribution_calculator_spec.rb +63 -0
  109. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_70_up_contribution_spec.rb +63 -0
  110. data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3_spec.rb +242 -0
  111. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  112. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  113. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  114. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
  115. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_70_up_contribution_calculator_spec.rb +63 -0
  116. data/spec/singapore_cpf_calculator/year_2023/spr_1_fg_spec.rb +176 -0
  117. data/spec/singapore_cpf_calculator/year_2023/spr_1_gg_spec.rb +158 -0
  118. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  119. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  120. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  121. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
  122. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_70_up_contribution_calculator_spec.rb +63 -0
  123. data/spec/singapore_cpf_calculator/year_2023/spr_2_fg_spec.rb +176 -0
  124. data/spec/singapore_cpf_calculator/year_2023/spr_2_gg_spec.rb +158 -0
  125. data/spec/singapore_cpf_calculator/year_2023_spec.rb +193 -0
  126. data/spec/singapore_cpf_calculator_spec.rb +58 -20
  127. data/spec/spec_helper.rb +6 -1
  128. metadata +148 -104
  129. data/.travis.yml +0 -15
@@ -0,0 +1,158 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2022::SPR2GG do
4
+
5
+ subject(:mod) { described_class }
6
+
7
+ describe ".applies_to?" do
8
+ let(:current_date) { Date.new(2022, 7, 1) }
9
+ let(:spr_start_date) { nil }
10
+ let(:employee_contribution_type) { nil }
11
+ let(:employer_contribution_type) { nil }
12
+
13
+ let(:result) {
14
+ mod.applies_to? status: status,
15
+ current_date: current_date,
16
+ spr_start_date: spr_start_date,
17
+ employee_contribution_type: employee_contribution_type,
18
+ employer_contribution_type: employer_contribution_type
19
+ }
20
+
21
+ context "when the employee is a citizen" do
22
+ let(:status) { "citizen" }
23
+ it { expect( result ).to be_falsey }
24
+ end
25
+
26
+ context "when the employee is a permanent resident on their 3rd year" do
27
+ let(:status) { "permanent_resident" }
28
+ let(:spr_start_date) { Date.new(2020, 6, 20) }
29
+ it { expect( result ).to be_falsey }
30
+ end
31
+
32
+ context "when the employee is a permanent resident on their 2nd year" do
33
+ let(:status) { "permanent_resident" }
34
+ let(:spr_start_date) { Date.new(2021, 6, 20) }
35
+
36
+ context "for full employer and employee contribution type" do
37
+ let(:employee_contribution_type) { "full" }
38
+ let(:employer_contribution_type) { "full" }
39
+ it { expect( result ).to be_falsey }
40
+ end
41
+
42
+ context "for graduated employer and employee contribution type" do
43
+ let(:employee_contribution_type) { "graduated" }
44
+ let(:employer_contribution_type) { "graduated" }
45
+ it { expect( result ).to be_truthy }
46
+ end
47
+
48
+ context "for full employer and graduated employee contribution type" do
49
+ let(:employee_contribution_type) { "graduated" }
50
+ let(:employer_contribution_type) { "full" }
51
+ it { expect( result ).to be_falsey }
52
+ end
53
+ end
54
+
55
+ context "when the employee is a permanent resident on their 1st year" do
56
+ let(:status) { "permanent_resident" }
57
+ let(:spr_start_date) { Date.new(2022, 6, 20) }
58
+
59
+ context "for full employer and employee contribution type" do
60
+ let(:employee_contribution_type) { "full" }
61
+ let(:employer_contribution_type) { "full" }
62
+ it { expect( result ).to be_falsey }
63
+ end
64
+
65
+ context "for graduated employer and employee contribution type" do
66
+ let(:employee_contribution_type) { "graduated" }
67
+ let(:employer_contribution_type) { "graduated" }
68
+ it { expect( result ).to be_falsey }
69
+ end
70
+
71
+ context "for full employer and graduated employee contribution type" do
72
+ let(:employee_contribution_type) { "graduated" }
73
+ let(:employer_contribution_type) { "full" }
74
+ it { expect( result ).to be_falsey }
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ describe "calculator_for" do
81
+ let(:calculator) { mod.calculator_for(current_date, birthdate: birthdate) }
82
+ let(:current_date) { Date.new(2022, 9, 15) }
83
+
84
+ context "when the employee's age is 55 or below" do
85
+ context "lower limit" do
86
+ let(:birthdate) { Date.new(1998, 8, 15) }
87
+
88
+ it {
89
+ expect( calculator ).
90
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age55BelowContributionCalculator
91
+ }
92
+ end
93
+
94
+ context "upper limit" do
95
+ let(:birthdate) { Date.new(1967, 9, 15) }
96
+ it {
97
+ expect( calculator ).
98
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age55BelowContributionCalculator
99
+ }
100
+ end
101
+ end
102
+
103
+ context "when the employee's age is above 55 to 60" do
104
+ context "lower limit" do
105
+ let(:birthdate) { Date.new(1966, 8, 15) }
106
+ it {
107
+ expect( calculator ).
108
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age55To60ContributionCalculator
109
+ }
110
+ end
111
+
112
+ context "upper limit" do
113
+ let(:birthdate) { Date.new(1962, 9, 15) }
114
+ it {
115
+ expect( calculator ).
116
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age55To60ContributionCalculator
117
+ }
118
+ end
119
+ end
120
+
121
+ context "when the employee's age is above 60 to 65" do
122
+ context "lower limit" do
123
+ let(:birthdate) { Date.new(1961, 8, 15) }
124
+ it {
125
+ expect( calculator ).
126
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age60To65ContributionCalculator
127
+ }
128
+ end
129
+
130
+ context "upper limit" do
131
+ let(:birthdate) { Date.new(1957, 9, 15) }
132
+ it {
133
+ expect( calculator ).
134
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age60To65ContributionCalculator
135
+ }
136
+ end
137
+ end
138
+
139
+ context "when the employee's age is 65 or above" do
140
+ context "lower limit" do
141
+ let(:birthdate) { Date.new(1956, 8, 15) }
142
+ it {
143
+ expect( calculator ).
144
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age65UpContributionCalculator
145
+ }
146
+ end
147
+
148
+ context "upper limit" do
149
+ let(:birthdate) { Date.new(1916, 8, 15) }
150
+ it {
151
+ expect( calculator ).
152
+ to be SingaporeCPFCalculator::Year2022::SPR2GG::Age65UpContributionCalculator
153
+ }
154
+ end
155
+ end
156
+ end
157
+
158
+ end
@@ -0,0 +1,192 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2022 do
4
+
5
+ subject(:year_module) { described_class }
6
+
7
+ describe ".applies_to?" do
8
+ context "when the date falls into the year 2014" do
9
+ let(:date) { Date.new(2014, 11, 15) }
10
+ it { expect( year_module.applies_to? date ).to be_falsey }
11
+ end
12
+
13
+ context "when the date falls into the year 2015" do
14
+ let(:date) { Date.new(2015, 1, 1) }
15
+ it { expect( year_module.applies_to? date ).to be_falsey }
16
+ end
17
+
18
+ context "when the date falls into the year 2016" do
19
+ let(:date) { Date.new(2016, 1, 1) }
20
+ it { expect( year_module.applies_to? date ).to be_falsey }
21
+ end
22
+
23
+ context "when the date falls into the year 2022" do
24
+ let(:date) { Date.new(2022, 1, 1) }
25
+ it { expect( year_module.applies_to? date ).to be_truthy }
26
+ end
27
+ end
28
+
29
+ describe ".module_for_residency" do
30
+
31
+ let(:mod) {
32
+ year_module.module_for_residency status: status,
33
+ current_date: current_date,
34
+ spr_start_date: spr_start_date,
35
+ employee_contribution_type: employee_contribution_type,
36
+ employer_contribution_type: employer_contribution_type
37
+ }
38
+
39
+ let(:current_date) { Date.new(2022, 11, 15) }
40
+ let(:employee_contribution_type) { nil }
41
+ let(:employer_contribution_type) { nil }
42
+
43
+ context "when the employee is a citizen" do
44
+ let(:status) { "citizen" }
45
+ let(:spr_start_date) { nil }
46
+
47
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
48
+ end
49
+
50
+ context "when the employee is a permanent resident" do
51
+ let(:status) { "permanent_resident" }
52
+
53
+ context "when the employee is in their year 1 of permanent residency" do
54
+ context "on the start of the SPR1" do
55
+ let(:spr_start_date) { Date.new(2022, 6, 20) }
56
+ let(:current_date) { Date.new(2022, 6, 20) }
57
+
58
+ context "when the employer pays partial contribution" do
59
+ let(:employer_contribution_type) { "graduated" }
60
+
61
+
62
+ context "when employee pays partial" do
63
+ let(:employee_contribution_type) { "graduated" }
64
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR1GG }
65
+ end
66
+ end
67
+
68
+ context "when the employer pays full contribution" do
69
+ let(:employer_contribution_type) { "full" }
70
+
71
+ context "when employee pays partial" do
72
+ let(:employee_contribution_type) { "graduated" }
73
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR1FG }
74
+ end
75
+
76
+ context "when employee pays full" do
77
+ let(:employee_contribution_type) { "full" }
78
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
79
+ end
80
+ end
81
+ end
82
+
83
+ context "on the end of the SPR1" do
84
+ let(:spr_start_date) { Date.new(2021, 6, 20) }
85
+ let(:current_date) { Date.new(2022, 6, 30) }
86
+
87
+ context "when the employer pays partial contribution" do
88
+ let(:employer_contribution_type) { "graduated" }
89
+
90
+ context "when employee pays partial" do
91
+ let(:employee_contribution_type) { "graduated" }
92
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR1GG }
93
+ end
94
+ end
95
+
96
+ context "when the employer pays full contribution" do
97
+ let(:employer_contribution_type) { "full" }
98
+
99
+ context "when employee pays partial" do
100
+ let(:employee_contribution_type) { "graduated" }
101
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR1FG }
102
+ end
103
+
104
+ context "when employee pays full" do
105
+ let(:employee_contribution_type) { "full" }
106
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ context "when the employee is in their year 2 of permanent residency" do
113
+ context "on the start of the SPR2" do
114
+ let(:spr_start_date) { Date.new(2021, 6, 20) }
115
+ let(:current_date) { Date.new(2022, 7, 1) }
116
+
117
+ context "when the employer pays partial contribution" do
118
+ let(:employer_contribution_type) { "graduated" }
119
+
120
+
121
+ context "when employee pays partial" do
122
+ let(:employee_contribution_type) { "graduated" }
123
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR2GG }
124
+ end
125
+ end
126
+
127
+ context "when the employer pays full contribution" do
128
+ let(:employer_contribution_type) { "full" }
129
+
130
+ context "when employee pays partial" do
131
+ let(:employee_contribution_type) { "graduated" }
132
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR2FG }
133
+ end
134
+
135
+ context "when employee pays full" do
136
+ let(:employee_contribution_type) { "full" }
137
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
138
+ end
139
+ end
140
+ end
141
+
142
+ context "on the end of the SPR2" do
143
+ let(:spr_start_date) { Date.new(2020, 6, 20) }
144
+ let(:current_date) { Date.new(2022, 6, 30) }
145
+
146
+ context "when the employer pays partial contribution" do
147
+ let(:employer_contribution_type) { "graduated" }
148
+
149
+
150
+ context "when employee pays partial" do
151
+ let(:employee_contribution_type) { "graduated" }
152
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR2GG }
153
+ end
154
+ end
155
+
156
+ context "when the employer pays full contribution" do
157
+ let(:employer_contribution_type) { "full" }
158
+
159
+ context "when employee pays partial" do
160
+ let(:employee_contribution_type) { "graduated" }
161
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::SPR2FG }
162
+ end
163
+
164
+ context "when employee pays full" do
165
+ let(:employee_contribution_type) { "full" }
166
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ context "when the employee is in their year 3 of permanent residency" do
173
+ context "on the start of the SPR3" do
174
+ let(:spr_start_date) { Date.new(2020, 6, 20) }
175
+ let(:current_date) { Date.new(2022, 7, 1) }
176
+
177
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
178
+ end
179
+
180
+ context "on SPR3 period" do
181
+ let(:spr_start_date) { Date.new(2018, 6, 20) }
182
+ let(:current_date) { Date.new(2022, 6, 30) }
183
+
184
+ it { expect(mod).to be SingaporeCPFCalculator::Year2022::CitizenOrSPR3 }
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+
191
+ end
192
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55BelowContributionCalculator do
4
+
5
+ subject(:calculator) {
6
+ described_class.new ordinary_wages: ordinary_wages,
7
+ additional_wages: additional_wages
8
+ }
9
+
10
+ let(:result) { calculator.calculate }
11
+
12
+ let(:additional_wages) { 0.0 }
13
+
14
+ describe "#calculate" do
15
+
16
+ context "when the total wages amounts to 0.00" do
17
+ let(:ordinary_wages) { 0.00 }
18
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
19
+ end
20
+
21
+ context "when the total wages amounts to 50.00" do
22
+ let(:ordinary_wages) { 50.00 }
23
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
24
+ end
25
+
26
+ context "when the total wages amounts to 50.01" do
27
+ let(:ordinary_wages) { 50.01 }
28
+ it { expect(result).to equal_cpf total: 9.00, employee: 0.00, employer: 9.00 }
29
+ end
30
+
31
+ context "when the total wages amounts to 500.00" do
32
+ let(:ordinary_wages) { 500.00 }
33
+ it { expect(result).to equal_cpf total: 85.00, employee: 0.00, employer: 85.00 }
34
+ end
35
+
36
+ context "when the total wages amounts to 500.01" do
37
+ let(:ordinary_wages) { 500.01 }
38
+ it { expect(result).to equal_cpf total: 85.00, employee: 0.00, employer: 85.00 }
39
+ end
40
+
41
+ context "when the total wages amounts to 749.99" do
42
+ let(:ordinary_wages) { 749.99 }
43
+ it { expect(result).to equal_cpf total: 277.00, employee: 149.00, employer: 128.00 }
44
+ end
45
+
46
+ context "when the total wages amounts to 750.00" do
47
+ let(:ordinary_wages) { 750.00 }
48
+ it { expect(result).to equal_cpf total: 278.00, employee: 150.00, employer: 128.00 }
49
+ end
50
+
51
+ context "when the total wages amounts to 5,000.00" do
52
+ let(:ordinary_wages) { 5_000.00 }
53
+ it { expect(result).to equal_cpf total: 1_850.00, employee: 1_000.00, employer: 850.00 }
54
+ end
55
+
56
+ context "when the total wages amounts to 10,000.00" do
57
+ let(:ordinary_wages) { 10_000.00 }
58
+ it { expect(result).to equal_cpf total: 2_220.00, employee: 1_200.00, employer: 1_020.00 }
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55To60ContributionCalculator do
4
+
5
+ subject(:calculator) {
6
+ described_class.new ordinary_wages: ordinary_wages,
7
+ additional_wages: additional_wages
8
+ }
9
+
10
+ let(:result) { calculator.calculate }
11
+
12
+ let(:additional_wages) { 0.0 }
13
+
14
+ describe "#calculate" do
15
+
16
+ context "when the total wages amounts to 0.00" do
17
+ let(:ordinary_wages) { 0.00 }
18
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
19
+ end
20
+
21
+ context "when the total wages amounts to 50.00" do
22
+ let(:ordinary_wages) { 50.00 }
23
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
24
+ end
25
+
26
+ context "when the total wages amounts to 50.01" do
27
+ let(:ordinary_wages) { 50.01 }
28
+ it { expect(result).to equal_cpf total: 7.00, employee: 0.00, employer: 7.00 }
29
+ end
30
+
31
+ context "when the total wages amounts to 500.00" do
32
+ let(:ordinary_wages) { 500.00 }
33
+ it { expect(result).to equal_cpf total: 73.00, employee: 0.00, employer: 73.00 }
34
+ end
35
+
36
+ context "when the total wages amounts to 500.01" do
37
+ let(:ordinary_wages) { 500.01 }
38
+ it { expect(result).to equal_cpf total: 73.00, employee: 0.00, employer: 73.00 }
39
+ end
40
+
41
+ context "when the total wages amounts to 749.99" do
42
+ let(:ordinary_wages) { 749.99 }
43
+ it { expect(result).to equal_cpf total: 221.00, employee: 112.00, employer: 109.00 }
44
+ end
45
+
46
+ context "when the total wages amounts to 750.00" do
47
+ let(:ordinary_wages) { 750.00 }
48
+ it { expect(result).to equal_cpf total: 221.00, employee: 112.00, employer: 109.00 }
49
+ end
50
+
51
+ context "when the total wages amounts to 5,000.00" do
52
+ let(:ordinary_wages) { 5_000.00 }
53
+ it { expect(result).to equal_cpf total: 1_475.00, employee: 750.00, employer: 725.00 }
54
+ end
55
+
56
+ context "when the total wages amounts to 10,000.00" do
57
+ let(:ordinary_wages) { 10_000.00 }
58
+ it { expect(result).to equal_cpf total: 1_770.00, employee: 900.00, employer: 870.00 }
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age60To65ContributionCalculator do
4
+
5
+ subject(:calculator) {
6
+ described_class.new ordinary_wages: ordinary_wages,
7
+ additional_wages: additional_wages
8
+ }
9
+
10
+ let(:result) { calculator.calculate }
11
+
12
+ let(:additional_wages) { 0.0 }
13
+
14
+ describe "#calculate" do
15
+
16
+ context "when the total wages amounts to 0.00" do
17
+ let(:ordinary_wages) { 0.00 }
18
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
19
+ end
20
+
21
+ context "when the total wages amounts to 50.00" do
22
+ let(:ordinary_wages) { 50.00 }
23
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
24
+ end
25
+
26
+ context "when the total wages amounts to 50.01" do
27
+ let(:ordinary_wages) { 50.01 }
28
+ it { expect(result).to equal_cpf total: 6.00, employee: 0.00, employer: 6.00 }
29
+ end
30
+
31
+ context "when the total wages amounts to 500.00" do
32
+ let(:ordinary_wages) { 500.00 }
33
+ it { expect(result).to equal_cpf total: 55.00, employee: 0.00, employer: 55.00 }
34
+ end
35
+
36
+ context "when the total wages amounts to 500.01" do
37
+ let(:ordinary_wages) { 500.01 }
38
+ it { expect(result).to equal_cpf total: 55.00, employee: 0.00, employer: 55.00 }
39
+ end
40
+
41
+ context "when the total wages amounts to 749.99" do
42
+ let(:ordinary_wages) { 749.99 }
43
+ it { expect(result).to equal_cpf total: 154.00, employee: 71.00, employer: 83.00 }
44
+ end
45
+
46
+ context "when the total wages amounts to 750.00" do
47
+ let(:ordinary_wages) { 750.00 }
48
+ it { expect(result).to equal_cpf total: 154.00, employee: 71.00, employer: 83.00 }
49
+ end
50
+
51
+ context "when the total wages amounts to 5,000.00" do
52
+ let(:ordinary_wages) { 5_000.00 }
53
+ it { expect(result).to equal_cpf total: 1025.00, employee: 475.00, employer: 550.00 }
54
+ end
55
+
56
+ context "when the total wages amounts to 10,000.00" do
57
+ let(:ordinary_wages) { 10_000.00 }
58
+ it { expect(result).to equal_cpf total: 1230.00, employee: 570.00, employer: 660.00 }
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age65To70ContributionCalculator do
4
+
5
+ subject(:calculator) {
6
+ described_class.new ordinary_wages: ordinary_wages,
7
+ additional_wages: additional_wages
8
+ }
9
+
10
+ let(:result) { calculator.calculate }
11
+
12
+ let(:additional_wages) { 0.0 }
13
+
14
+ describe "#calculate" do
15
+
16
+ context "when the total wages amounts to 0.00" do
17
+ let(:ordinary_wages) { 0.00 }
18
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
19
+ end
20
+
21
+ context "when the total wages amounts to 50.00" do
22
+ let(:ordinary_wages) { 50.00 }
23
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
24
+ end
25
+
26
+ context "when the total wages amounts to 50.01" do
27
+ let(:ordinary_wages) { 50.01 }
28
+ it { expect(result).to equal_cpf total: 4.00, employee: 0.00, employer: 4.00 }
29
+ end
30
+
31
+ context "when the total wages amounts to 500.00" do
32
+ let(:ordinary_wages) { 500.00 }
33
+ it { expect(result).to equal_cpf total: 43.00, employee: 0.00, employer: 43.00 }
34
+ end
35
+
36
+ context "when the total wages amounts to 500.01" do
37
+ let(:ordinary_wages) { 500.01 }
38
+ it { expect(result).to equal_cpf total: 43.00, employee: 0.00, employer: 43.00 }
39
+ end
40
+
41
+ context "when the total wages amounts to 749.99" do
42
+ let(:ordinary_wages) { 749.99 }
43
+ it { expect(result).to equal_cpf total: 116.00, employee: 52.00, employer: 64.00 }
44
+ end
45
+
46
+ context "when the total wages amounts to 750.00" do
47
+ let(:ordinary_wages) { 750.00 }
48
+ it { expect(result).to equal_cpf total: 116.00, employee: 52.00, employer: 64.00 }
49
+ end
50
+
51
+ context "when the total wages amounts to 5,000.00" do
52
+ let(:ordinary_wages) { 5_000.00 }
53
+ it { expect(result).to equal_cpf total: 775.00, employee: 350.00, employer: 425.00 }
54
+ end
55
+
56
+ context "when the total wages amounts to 10,000.00" do
57
+ let(:ordinary_wages) { 10_000.00 }
58
+ it { expect(result).to equal_cpf total: 930.00, employee: 420.00, employer: 510.00 }
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age70UpContributionCalculator do
4
+
5
+ subject(:calculator) {
6
+ described_class.new ordinary_wages: ordinary_wages,
7
+ additional_wages: additional_wages
8
+ }
9
+
10
+ let(:result) { calculator.calculate }
11
+
12
+ let(:additional_wages) { 0.0 }
13
+
14
+ describe "#calculate" do
15
+
16
+ context "when the total wages amounts to 0.00" do
17
+ let(:ordinary_wages) { 0.00 }
18
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
19
+ end
20
+
21
+ context "when the total wages amounts to 50.00" do
22
+ let(:ordinary_wages) { 50.00 }
23
+ it { expect(result).to equal_cpf total: 0.00, employee: 0.00, employer: 0.00 }
24
+ end
25
+
26
+ context "when the total wages amounts to 50.01" do
27
+ let(:ordinary_wages) { 50.01 }
28
+ it { expect(result).to equal_cpf total: 4.00, employee: 0.00, employer: 4.00 }
29
+ end
30
+
31
+ context "when the total wages amounts to 500.00" do
32
+ let(:ordinary_wages) { 500.00 }
33
+ it { expect(result).to equal_cpf total: 38.00, employee: 0.00, employer: 38.00 }
34
+ end
35
+
36
+ context "when the total wages amounts to 500.01" do
37
+ let(:ordinary_wages) { 500.01 }
38
+ it { expect(result).to equal_cpf total: 38.00, employee: 0.00, employer: 38.00 }
39
+ end
40
+
41
+ context "when the total wages amounts to 749.99" do
42
+ let(:ordinary_wages) { 749.99 }
43
+ it { expect(result).to equal_cpf total: 94.00, employee: 37.00, employer: 57.00 }
44
+ end
45
+
46
+ context "when the total wages amounts to 750.00" do
47
+ let(:ordinary_wages) { 750.00 }
48
+ it { expect(result).to equal_cpf total: 94.00, employee: 37.00, employer: 57.00 }
49
+ end
50
+
51
+ context "when the total wages amounts to 5,000.00" do
52
+ let(:ordinary_wages) { 5_000.00 }
53
+ it { expect(result).to equal_cpf total: 625.00, employee: 250.00, employer: 375.00 }
54
+ end
55
+
56
+ context "when the total wages amounts to 10,000.00" do
57
+ let(:ordinary_wages) { 10_000.00 }
58
+ it { expect(result).to equal_cpf total: 750.00, employee: 300.00, employer: 450.00 }
59
+ end
60
+
61
+ end
62
+
63
+ end