singapore_cpf_calculator 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +97 -0
- data/Rakefile +2 -0
- data/circle.yml +3 -0
- data/lib/singapore_cpf_calculator.rb +125 -0
- data/lib/singapore_cpf_calculator/age_group.rb +71 -0
- data/lib/singapore_cpf_calculator/base_calculator.rb +114 -0
- data/lib/singapore_cpf_calculator/before_spr.rb +36 -0
- data/lib/singapore_cpf_calculator/citizen_or_spr_3_common.rb +27 -0
- data/lib/singapore_cpf_calculator/cpf_contribution.rb +28 -0
- data/lib/singapore_cpf_calculator/null_contribution_calculator.rb +17 -0
- data/lib/singapore_cpf_calculator/requirements.rb +10 -0
- data/lib/singapore_cpf_calculator/requirements/group_50_years_and_below.rb +13 -0
- data/lib/singapore_cpf_calculator/requirements/group_above_50_to_55_years.rb +13 -0
- data/lib/singapore_cpf_calculator/requirements/group_above_55_to_60_years.rb +13 -0
- data/lib/singapore_cpf_calculator/requirements/group_above_60_to_65_years.rb +13 -0
- data/lib/singapore_cpf_calculator/requirements/group_above_65_years.rb +13 -0
- data/lib/singapore_cpf_calculator/residency_module_common.rb +12 -0
- data/lib/singapore_cpf_calculator/spr_1_fg_common.rb +26 -0
- data/lib/singapore_cpf_calculator/spr_1_gg_common.rb +26 -0
- data/lib/singapore_cpf_calculator/spr_2_fg_common.rb +26 -0
- data/lib/singapore_cpf_calculator/spr_2_gg_common.rb +26 -0
- data/lib/singapore_cpf_calculator/spr_status.rb +52 -0
- data/lib/singapore_cpf_calculator/version.rb +3 -0
- data/lib/singapore_cpf_calculator/year_2014.rb +37 -0
- data/lib/singapore_cpf_calculator/year_2014/base.rb +17 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3.rb +35 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb +33 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_below_contribution_calculator.rb +33 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_to_55_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_fg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_to_55_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_55_to_60_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_1_gg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_to_55_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_fg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_to_55_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2014/spr_2_gg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015.rb +38 -0
- data/lib/singapore_cpf_calculator/year_2015/base.rb +17 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3.rb +35 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_to_55_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg.rb +37 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_to_55_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_fg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_to_55_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_55_to_60_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_1_gg/age_65_up_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_to_55_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_fg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg.rb +36 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_below_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_to_55_contribution_calculator.rb +14 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_55_to_60_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_60_to_65_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_2015/spr_2_gg/age_65_up_contribution_calculator.rb +32 -0
- data/lib/singapore_cpf_calculator/year_common.rb +29 -0
- data/singapore_cpf_calculator.gemspec +27 -0
- data/spec/acceptance/company_a.csv +1365 -0
- data/spec/acceptance/company_a_spec.rb +36 -0
- data/spec/singapore_cpf_calculator/age_group_spec.rb +65 -0
- data/spec/singapore_cpf_calculator/spr_status_spec.rb +48 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_below_contribution_calculator_spec.rb +68 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_50_to_55_contribution_calculator_spec.rb +68 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +68 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +68 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3/age_65_up_contribution_calculator_spec.rb +68 -0
- data/spec/singapore_cpf_calculator/year_2014/citizen_or_spr_3_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_below_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_50_to_55_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg/age_65_up_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_below_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_50_to_55_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg/age_65_up_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_1_gg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_below_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_50_to_55_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg/age_65_up_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_below_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_50_to_55_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg/age_65_up_contribution_calculator_spec.rb +73 -0
- data/spec/singapore_cpf_calculator/year_2014/spr_2_gg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2014_spec.rb +183 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_50_to_55_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3/age_65_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_50_to_55_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg/age_65_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_50_to_55_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg/age_65_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_1_gg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_50_to_55_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg/age_65_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_fg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_below_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_50_to_55_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg/age_65_up_contribution_calculator_spec.rb +63 -0
- data/spec/singapore_cpf_calculator/year_2015/spr_2_gg_spec.rb +176 -0
- data/spec/singapore_cpf_calculator/year_2015_spec.rb +187 -0
- data/spec/singapore_cpf_calculator_spec.rb +48 -0
- data/spec/spec_helper.rb +115 -0
- metadata +344 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative "null_contribution_calculator"
|
2
|
+
|
3
|
+
module SingaporeCPFCalculator
|
4
|
+
|
5
|
+
# Residency module for Singaporean Permanent Residents before theirs status effectivity.
|
6
|
+
module BeforeSPR
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
11
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
12
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
13
|
+
# @return [true, false]
|
14
|
+
def applies_to?(
|
15
|
+
status:,
|
16
|
+
current_date:,
|
17
|
+
spr_start_date:,
|
18
|
+
**
|
19
|
+
)
|
20
|
+
status == "permanent_resident" && (
|
21
|
+
spr_start_date.year > current_date.year ||
|
22
|
+
(spr_start_date.year == current_date.year && spr_start_date.month > current_date.month)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param [Object] current_date
|
27
|
+
# @param [Object] birthdate
|
28
|
+
# @return [#calculator] returns the CPF calculator that matches the age.
|
29
|
+
def calculator_for(current_date, birthdate:)
|
30
|
+
NullContributionCalculator
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
3
|
+
module CitizenOrSPR3Common
|
4
|
+
|
5
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
6
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
7
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
8
|
+
# @param [String] employee_contribution_type: ["full", "graduated"]
|
9
|
+
# @param [String] employer_contribution_type: ["full", "graduated"]
|
10
|
+
# @return [true, false]
|
11
|
+
def applies_to?(
|
12
|
+
status:,
|
13
|
+
current_date:,
|
14
|
+
spr_start_date:,
|
15
|
+
employee_contribution_type:,
|
16
|
+
employer_contribution_type:
|
17
|
+
)
|
18
|
+
status == "citizen" || (
|
19
|
+
status == "permanent_resident" && (
|
20
|
+
SPRStatus.get(current_date, status_start_date: spr_start_date) == :SPR3 ||
|
21
|
+
(employee_contribution_type == "full" && employer_contribution_type == "full")
|
22
|
+
)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
|
3
|
+
# Result object that describes the total, employee, and employer contribution.
|
4
|
+
class CPFContribution
|
5
|
+
|
6
|
+
# @return [BigDecimal]
|
7
|
+
attr_reader :total, :employee
|
8
|
+
|
9
|
+
# @param [BigDecimal] total the total contribution amount
|
10
|
+
# @param [BigDecimal] employee the employee contribution amount
|
11
|
+
def initialize(total:, employee:)
|
12
|
+
@total = total
|
13
|
+
@employee = employee
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [BigDecimal] difference between the total and employee contributions
|
17
|
+
def employer
|
18
|
+
@employer ||= total - employee
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param [CPFContribution] other
|
22
|
+
# @return [TrueClass, FalseClass]
|
23
|
+
def ==(other)
|
24
|
+
total == other.total && employee == other.employee
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
|
3
|
+
# Null CPF calculators.
|
4
|
+
module NullContributionCalculator
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# returns zero value
|
9
|
+
def calculate(*)
|
10
|
+
CPFContribution.new total: BigDecimal.new("0.0"),
|
11
|
+
employee: BigDecimal.new("0.0")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
module Requirements
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require_relative "requirements/group_50_years_and_below"
|
7
|
+
require_relative "requirements/group_above_50_to_55_years"
|
8
|
+
require_relative "requirements/group_above_55_to_60_years"
|
9
|
+
require_relative "requirements/group_above_60_to_65_years"
|
10
|
+
require_relative "requirements/group_above_65_years"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
module ResidencyModuleCommon
|
3
|
+
|
4
|
+
# @param [Date] date current date to which the age is calculated
|
5
|
+
# @param [Date] birthdate
|
6
|
+
# @return [#calculator] returns the CPF calculator that matches the age.
|
7
|
+
def calculator_for(date, birthdate:)
|
8
|
+
calculators.find { |calculator| calculator.applies_to? date, birthdate: birthdate }
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module SingaporeCPFCalculator
|
3
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
4
|
+
module SPR1FGCommon
|
5
|
+
|
6
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
7
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
8
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
9
|
+
# @param [String] employee_contribution_type: ["full", "graduated"]
|
10
|
+
# @param [String] employer_contribution_type: ["full", "graduated"]
|
11
|
+
# @return [true, false]
|
12
|
+
def applies_to?(
|
13
|
+
status:,
|
14
|
+
current_date:,
|
15
|
+
spr_start_date:,
|
16
|
+
employee_contribution_type:,
|
17
|
+
employer_contribution_type:
|
18
|
+
)
|
19
|
+
status == "permanent_resident" &&
|
20
|
+
SPRStatus.get(current_date, status_start_date: spr_start_date) == :SPR1 &&
|
21
|
+
employee_contribution_type == "graduated" &&
|
22
|
+
employer_contribution_type == "full"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module SingaporeCPFCalculator
|
3
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
4
|
+
module SPR1GGCommon
|
5
|
+
|
6
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
7
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
8
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
9
|
+
# @param [String] employee_contribution_type: ["full", "graduated"]
|
10
|
+
# @param [String] employer_contribution_type: ["full", "graduated"]
|
11
|
+
# @return [true, false]
|
12
|
+
def applies_to?(
|
13
|
+
status:,
|
14
|
+
current_date:,
|
15
|
+
spr_start_date:,
|
16
|
+
employee_contribution_type:,
|
17
|
+
employer_contribution_type:
|
18
|
+
)
|
19
|
+
status == "permanent_resident" &&
|
20
|
+
SPRStatus.get(current_date, status_start_date: spr_start_date) == :SPR1 &&
|
21
|
+
employee_contribution_type == "graduated" &&
|
22
|
+
employer_contribution_type == "graduated"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module SingaporeCPFCalculator
|
3
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
4
|
+
module SPR2FGCommon
|
5
|
+
|
6
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
7
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
8
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
9
|
+
# @param [String] employee_contribution_type: ["full", "graduated"]
|
10
|
+
# @param [String] employer_contribution_type: ["full", "graduated"]
|
11
|
+
# @return [true, false]
|
12
|
+
def applies_to?(
|
13
|
+
status:,
|
14
|
+
current_date:,
|
15
|
+
spr_start_date:,
|
16
|
+
employee_contribution_type:,
|
17
|
+
employer_contribution_type:
|
18
|
+
)
|
19
|
+
status == "permanent_resident" &&
|
20
|
+
SPRStatus.get(current_date, status_start_date: spr_start_date) == :SPR2 &&
|
21
|
+
employee_contribution_type == "graduated" &&
|
22
|
+
employer_contribution_type == "full"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module SingaporeCPFCalculator
|
3
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
4
|
+
module SPR2GGCommon
|
5
|
+
|
6
|
+
# @param [String] status: ["citizen", "permanent_resident", "foreigner"]
|
7
|
+
# @param [Date] current_date: current date used to determine permanent residency's duration
|
8
|
+
# @param [Date] spr_start_date: date when the permanent residency started
|
9
|
+
# @param [String] employee_contribution_type: ["full", "graduated"]
|
10
|
+
# @param [String] employer_contribution_type: ["full", "graduated"]
|
11
|
+
# @return [true, false]
|
12
|
+
def applies_to?(
|
13
|
+
status:,
|
14
|
+
current_date:,
|
15
|
+
spr_start_date:,
|
16
|
+
employee_contribution_type:,
|
17
|
+
employer_contribution_type:
|
18
|
+
)
|
19
|
+
status == "permanent_resident" &&
|
20
|
+
SPRStatus.get(current_date, status_start_date: spr_start_date) == :SPR2 &&
|
21
|
+
employee_contribution_type == "graduated" &&
|
22
|
+
employer_contribution_type == "graduated"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module SingaporeCPFCalculator
|
2
|
+
|
3
|
+
class SPRStatus
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def get(current_date, status_start_date:)
|
7
|
+
new(current_date, status_start_date: status_start_date).get
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(current_date, status_start_date:)
|
12
|
+
@current_date = current_date
|
13
|
+
@status_start_date = status_start_date
|
14
|
+
end
|
15
|
+
|
16
|
+
def get
|
17
|
+
case
|
18
|
+
when spr1_start <= current_date && current_date <= spr1_end then :SPR1
|
19
|
+
when spr2_start <= current_date && current_date <= spr2_end then :SPR2
|
20
|
+
when spr3_start <= current_date then :SPR3
|
21
|
+
else
|
22
|
+
nil # could not be determined
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :current_date, :status_start_date
|
29
|
+
|
30
|
+
def spr1_start
|
31
|
+
status_start_date
|
32
|
+
end
|
33
|
+
|
34
|
+
def spr1_end
|
35
|
+
@spr1_end ||= (spr1_start.beginning_of_month.advance years: 1).end_of_month
|
36
|
+
end
|
37
|
+
|
38
|
+
def spr2_start
|
39
|
+
@spr2_start ||= spr1_end.beginning_of_month.advance months: 1
|
40
|
+
end
|
41
|
+
|
42
|
+
def spr2_end
|
43
|
+
@spr2_end ||= spr2_start.dup.advance(months: 11).end_of_month
|
44
|
+
end
|
45
|
+
|
46
|
+
def spr3_start
|
47
|
+
spr2_end.beginning_of_month.advance(months: 1)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "year_2014/base"
|
2
|
+
require_relative "year_2014/citizen_or_spr_3"
|
3
|
+
require_relative "year_2014/spr_2_gg"
|
4
|
+
require_relative "year_2014/spr_2_fg"
|
5
|
+
require_relative "year_2014/spr_1_gg"
|
6
|
+
require_relative "year_2014/spr_1_fg"
|
7
|
+
|
8
|
+
module SingaporeCPFCalculator
|
9
|
+
# Contains the calculators that are used for determining CPF contribution for 2014.
|
10
|
+
module Year2014
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
include YearCommon
|
15
|
+
|
16
|
+
# @param [Date] date when the CPF contribution is to be calculated for.
|
17
|
+
# @return [true, false] true when the date's year is 2014
|
18
|
+
def applies_to?(date)
|
19
|
+
date.year == 2014
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def residency_modules
|
25
|
+
[
|
26
|
+
CitizenOrSPR3,
|
27
|
+
SPR2GG,
|
28
|
+
SPR2FG,
|
29
|
+
SPR1GG,
|
30
|
+
SPR1FG,
|
31
|
+
BeforeSPR,
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|