singapore_cpf_calculator 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +6 -2
- data/.rubocop.yml +81 -0
- data/.rubocop_todo.yml +326 -0
- data/Gemfile +0 -1
- data/README.md +1 -0
- data/lib/singapore_cpf_calculator/version.rb +1 -1
- data/lib/singapore_cpf_calculator/year_2022.rb +2 -2
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_below_contribution_calculator.rb +8 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_65_to_70_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_70_up_contribution_calculator.rb +9 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3/citizen_or_spr3_base.rb +8 -0
- data/lib/singapore_cpf_calculator/year_2023/citizen_or_spr_3.rb +40 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_below_contribution_calculator.rb +11 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_65_to_70_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg/age_70_up_contribution_calculator.rb +8 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_fg.rb +40 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_1_gg.rb +29 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_below_contribution_calculator.rb +11 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_65_to_70_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg/age_70_up_contribution_calculator.rb +8 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_fg.rb +40 -0
- data/lib/singapore_cpf_calculator/year_2023/spr_2_gg.rb +29 -0
- data/lib/singapore_cpf_calculator/year_2023/year_2023.rb +35 -0
- data/lib/singapore_cpf_calculator/year_2023.rb +35 -0
- data/lib/singapore_cpf_calculator.rb +3 -1
- data/singapore_cpf_calculator.gemspec +3 -1
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_65_to_70_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3/age_70_up_contribution_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/citizen_or_spr_3_spec.rb +242 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_70_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_1_gg_spec.rb +158 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_65_to_70_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg/age_70_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2023/spr_2_gg_spec.rb +158 -0
- data/spec/singapore_cpf_calculator/year_2023_spec.rb +193 -0
- data/spec/singapore_cpf_calculator_spec.rb +2 -1
- metadata +83 -131
@@ -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
|
@@ -0,0 +1,242 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::CitizenOrSPR3 do
|
4
|
+
|
5
|
+
subject(:mod) { described_class }
|
6
|
+
|
7
|
+
describe ".applies_to?" do
|
8
|
+
let(:current_date) { Date.new(2023, 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_truthy }
|
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(2021, 6, 20) }
|
29
|
+
it { expect(result).to be_truthy }
|
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(2022, 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_truthy }
|
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_falsey }
|
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(2023, 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_truthy }
|
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 "AW Ceiling" do
|
81
|
+
let(:calculator) { mod.calculator_for(current_date, birthdate: birthdate) }
|
82
|
+
let(:current_date) { Date.new(2023, 9, 15) }
|
83
|
+
let(:birthdate) { Date.new(1999, 8, 15) }
|
84
|
+
let(:status) { "permanent_resident" }
|
85
|
+
let(:spr_start_date) { Date.new(2023, 6, 20) }
|
86
|
+
let(:ordinary_wages) { 3_000 }
|
87
|
+
let(:additional_wages) { 2_000 }
|
88
|
+
let(:employee_contribution_type) { "full" }
|
89
|
+
let(:employer_contribution_type) { "full" }
|
90
|
+
subject(:result) {
|
91
|
+
calculator.calculate ordinary_wages: ordinary_wages,
|
92
|
+
additional_wages: additional_wages,
|
93
|
+
ytd_ow_subject_to_cpf: cumulative_ordinary
|
94
|
+
}
|
95
|
+
|
96
|
+
context "have earned far less than the AW ceiling cumulative" do
|
97
|
+
let(:cumulative_ordinary) { 2_000 }
|
98
|
+
let(:expected_result) do
|
99
|
+
SingaporeCPFCalculator::CPFContribution.new(total: 1850.0,
|
100
|
+
employee: 1000.0,
|
101
|
+
ow_subject_to_cpf: ordinary_wages,
|
102
|
+
aw_subject_to_cpf: additional_wages)
|
103
|
+
end
|
104
|
+
|
105
|
+
it { is_expected.to equal_cpf total: 1850, employee: 1000, ow: ordinary_wages, aw: 2000 }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "earned 1k under the AW ceiling cumulative" do
|
109
|
+
let(:cumulative_ordinary) { 98_000 }
|
110
|
+
it { is_expected.to equal_cpf total: 1480, employee: 800, ow: ordinary_wages, aw: 1000 }
|
111
|
+
end
|
112
|
+
|
113
|
+
context "has earned the wage ceiling" do
|
114
|
+
let(:cumulative_ordinary) { 105_000 }
|
115
|
+
it { is_expected.to equal_cpf total: 1110, employee: 600, ow: ordinary_wages, aw: 0 }
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "using estimated yearly ordinary wages" do
|
119
|
+
subject(:result) {
|
120
|
+
calculator.calculate ordinary_wages: ordinary_wages,
|
121
|
+
additional_wages: additional_wages,
|
122
|
+
ytd_ow_subject_to_cpf: cumulative_ordinary,
|
123
|
+
ytd_additional_wages: ytd_additional_wages,
|
124
|
+
estimated_yearly_ow: estimated_yearly_ow
|
125
|
+
}
|
126
|
+
let(:cumulative_ordinary) { 0 }
|
127
|
+
let(:ytd_additional_wages) { 0 }
|
128
|
+
|
129
|
+
context "estimated yearly earnings at the threshold" do
|
130
|
+
let(:estimated_yearly_ow) { 102_000 }
|
131
|
+
it { is_expected.to equal_cpf total: 1110, employee: 600, ow: ordinary_wages, aw: 0 }
|
132
|
+
end
|
133
|
+
|
134
|
+
context "estimated yearly earnings 1k below threshold" do
|
135
|
+
let(:estimated_yearly_ow) { 101_000 }
|
136
|
+
it { is_expected.to equal_cpf total: 1480, employee: 800, ow: ordinary_wages, aw: 1000 }
|
137
|
+
end
|
138
|
+
|
139
|
+
context "estimated yearly earnings 3k below threshold" do
|
140
|
+
let(:estimated_yearly_ow) { 99_000 }
|
141
|
+
it { is_expected.to equal_cpf total: 1850, employee: 1000, ow: ordinary_wages, aw: 2000 }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "calculator_for" do
|
147
|
+
let(:calculator) { mod.calculator_for(current_date, birthdate: birthdate) }
|
148
|
+
let(:current_date) { Date.new(2023, 9, 15) }
|
149
|
+
|
150
|
+
context "when the employee's age is 55 or below" do
|
151
|
+
context "lower limit" do
|
152
|
+
let(:birthdate) { Date.new(1999, 8, 15) }
|
153
|
+
|
154
|
+
it {
|
155
|
+
expect(calculator).
|
156
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55BelowContributionCalculator
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
context "upper limit" do
|
161
|
+
let(:birthdate) { Date.new(1968, 9, 15) }
|
162
|
+
it {
|
163
|
+
expect(calculator).
|
164
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55BelowContributionCalculator
|
165
|
+
}
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "when the employee's age is above 55 to 60" do
|
170
|
+
context "lower limit" do
|
171
|
+
let(:birthdate) { Date.new(1967, 8, 15) }
|
172
|
+
it {
|
173
|
+
expect(calculator).
|
174
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55To60ContributionCalculator
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
context "upper limit" do
|
179
|
+
let(:birthdate) { Date.new(1963, 9, 15) }
|
180
|
+
it {
|
181
|
+
expect(calculator).
|
182
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age55To60ContributionCalculator
|
183
|
+
}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context "when the employee's age is above 60 to 65" do
|
188
|
+
context "lower limit" do
|
189
|
+
let(:birthdate) { Date.new(1962, 8, 15) }
|
190
|
+
it {
|
191
|
+
expect(calculator).
|
192
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age60To65ContributionCalculator
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
context "upper limit" do
|
197
|
+
let(:birthdate) { Date.new(1958, 9, 15) }
|
198
|
+
it {
|
199
|
+
expect(calculator).
|
200
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age60To65ContributionCalculator
|
201
|
+
}
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context "when the employee's age is 65 to 70" do
|
206
|
+
context "lower limit" do
|
207
|
+
let(:birthdate) { Date.new(1957, 8, 15) }
|
208
|
+
it {
|
209
|
+
expect(calculator).
|
210
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age65To70ContributionCalculator
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
context "upper limit" do
|
215
|
+
let(:birthdate) { Date.new(1953, 9, 15) }
|
216
|
+
it {
|
217
|
+
expect(calculator).
|
218
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age65To70ContributionCalculator
|
219
|
+
}
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "when the employee's age is 70 or above" do
|
224
|
+
context "lower limit" do
|
225
|
+
let(:birthdate) { Date.new(1953, 8, 15) }
|
226
|
+
it {
|
227
|
+
expect(calculator).
|
228
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age70UpContributionCalculator
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
context "upper limit" do
|
233
|
+
let(:birthdate) { Date.new(1951, 8, 15) }
|
234
|
+
it {
|
235
|
+
expect(calculator).
|
236
|
+
to be SingaporeCPFCalculator::Year2023::CitizenOrSPR3::Age70UpContributionCalculator
|
237
|
+
}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_below_contribution_calculator_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::SPR1FG::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: 165.00, employee: 37.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: 165.00, employee: 37.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_100.00, employee: 250.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: 1_320.00, employee: 300.00, employer: 1_020.00 }
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::SPR1FG::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: 146.00, employee: 37.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: 146.00, employee: 37.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: 975.00, employee: 250.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_170.00, employee: 300.00, employer: 870.00 }
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::SPR1FG::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: 120.00, employee: 37.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: 120.00, employee: 37.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: 800.00, employee: 250.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: 960.00, employee: 300.00, employer: 660.00 }
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_65_to_70_contribution_calculator_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::SPR1FG::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: 101.00, employee: 37.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: 101.00, employee: 37.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: 675.00, employee: 250.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: 810.00, employee: 300.00, employer: 510.00 }
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/singapore_cpf_calculator/year_2023/spr_1_fg/age_70_up_contribution_calculator_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SingaporeCPFCalculator::Year2023::SPR1FG::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
|