singapore_cpf_calculator 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/singapore_cpf_calculator.rb +2 -0
  4. data/lib/singapore_cpf_calculator/age_group.rb +34 -11
  5. data/lib/singapore_cpf_calculator/base_calculator.rb +1 -0
  6. data/lib/singapore_cpf_calculator/requirements.rb +1 -0
  7. data/lib/singapore_cpf_calculator/requirements/group_55_years_and_below.rb +13 -0
  8. data/lib/singapore_cpf_calculator/version.rb +1 -1
  9. data/lib/singapore_cpf_calculator/year_2015.rb +1 -1
  10. data/lib/singapore_cpf_calculator/year_2016.rb +38 -0
  11. data/lib/singapore_cpf_calculator/year_2016/base.rb +17 -0
  12. data/lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3.rb +33 -0
  13. data/lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_below_contribution_calculator.rb +32 -0
  14. data/lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_to_60_contribution_calculator.rb +32 -0
  15. data/lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_60_to_65_contribution_calculator.rb +32 -0
  16. data/lib/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_65_up_contribution_calculator.rb +32 -0
  17. data/lib/singapore_cpf_calculator/year_2016/spr_1_fg.rb +35 -0
  18. data/lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_below_contribution_calculator.rb +32 -0
  19. data/lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_to_60_contribution_calculator.rb +32 -0
  20. data/lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_60_to_65_contribution_calculator.rb +32 -0
  21. data/lib/singapore_cpf_calculator/year_2016/spr_1_fg/age_65_up_contribution_calculator.rb +32 -0
  22. data/lib/singapore_cpf_calculator/year_2016/spr_1_gg.rb +34 -0
  23. data/lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_below_contribution_calculator.rb +32 -0
  24. data/lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_to_60_contribution_calculator.rb +14 -0
  25. data/lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_60_to_65_contribution_calculator.rb +32 -0
  26. data/lib/singapore_cpf_calculator/year_2016/spr_1_gg/age_65_up_contribution_calculator.rb +14 -0
  27. data/lib/singapore_cpf_calculator/year_2016/spr_2_fg.rb +34 -0
  28. data/lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_below_contribution_calculator.rb +32 -0
  29. data/lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_to_60_contribution_calculator.rb +32 -0
  30. data/lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_60_to_65_contribution_calculator.rb +32 -0
  31. data/lib/singapore_cpf_calculator/year_2016/spr_2_fg/age_65_up_contribution_calculator.rb +32 -0
  32. data/lib/singapore_cpf_calculator/year_2016/spr_2_gg.rb +34 -0
  33. data/lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_below_contribution_calculator.rb +32 -0
  34. data/lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_to_60_contribution_calculator.rb +32 -0
  35. data/lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_60_to_65_contribution_calculator.rb +32 -0
  36. data/lib/singapore_cpf_calculator/year_2016/spr_2_gg/age_65_up_contribution_calculator.rb +32 -0
  37. data/spec/singapore_cpf_calculator/year_2015/citizen_or_spr_3_spec.rb +10 -10
  38. data/spec/singapore_cpf_calculator/year_2015/spr_1_fg_spec.rb +10 -10
  39. data/spec/singapore_cpf_calculator/year_2015/spr_1_gg_spec.rb +11 -11
  40. data/spec/singapore_cpf_calculator/year_2015/spr_2_fg_spec.rb +11 -11
  41. data/spec/singapore_cpf_calculator/year_2015/spr_2_gg_spec.rb +11 -11
  42. data/spec/singapore_cpf_calculator/year_2015_spec.rb +3 -3
  43. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_below_contribution_calculator_spec.rb +63 -0
  44. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_55_to_60_contribution_calculator_spec.rb +63 -0
  45. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_60_to_65_contribution_calculator_spec.rb +63 -0
  46. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3/age_65_up_contribution_calculator_spec.rb +63 -0
  47. data/spec/singapore_cpf_calculator/year_2016/citizen_or_spr_3_spec.rb +158 -0
  48. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  49. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  50. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  51. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg/age_65_up_contribution_calculator_spec.rb +63 -0
  52. data/spec/singapore_cpf_calculator/year_2016/spr_1_fg_spec.rb +158 -0
  53. data/spec/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_below_contribution_calculator_spec.rb +63 -0
  54. data/spec/singapore_cpf_calculator/year_2016/spr_1_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  55. data/spec/singapore_cpf_calculator/year_2016/spr_1_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  56. data/spec/singapore_cpf_calculator/year_2016/spr_1_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  57. data/spec/singapore_cpf_calculator/year_2016/spr_1_gg_spec.rb +158 -0
  58. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_below_contribution_calculator_spec.rb +63 -0
  59. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  60. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  61. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg/age_65_up_contribution_calculator_spec.rb +63 -0
  62. data/spec/singapore_cpf_calculator/year_2016/spr_2_fg_spec.rb +158 -0
  63. data/spec/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_below_contribution_calculator_spec.rb +63 -0
  64. data/spec/singapore_cpf_calculator/year_2016/spr_2_gg/age_55_to_60_contribution_calculator_spec.rb +63 -0
  65. data/spec/singapore_cpf_calculator/year_2016/spr_2_gg/age_60_to_65_contribution_calculator_spec.rb +63 -0
  66. data/spec/singapore_cpf_calculator/year_2016/spr_2_gg/age_65_up_contribution_calculator_spec.rb +63 -0
  67. data/spec/singapore_cpf_calculator/year_2016/spr_2_gg_spec.rb +158 -0
  68. data/spec/singapore_cpf_calculator/year_2016_spec.rb +187 -0
  69. data/spec/spec_helper.rb +3 -3
  70. metadata +82 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c10a9da895045667814bc945fe76c308fa58f61a
4
- data.tar.gz: 0c7815f181658ee0511bdf631822ef6c4871164f
3
+ metadata.gz: 0d44d25461342a4f59f937164260f9b7f4a80997
4
+ data.tar.gz: 5ae6f53a86bb4b3765673b5e8c7d94af62efa288
5
5
  SHA512:
6
- metadata.gz: d7bd99c5b7bdd11616e9773158838aa03f293e61a3d5555165185702ac423ddb1a4fa5bcc48ff4fc86dd7091f370c698f3e75aaf4f0c31fb2f708d66486fa363
7
- data.tar.gz: 976dec1337b458a379b4478b3db71e3ca7451ecdf1d5998db3bfc47769adfed4558036f87f1fbe0d7d1933f9e8cd951e15f87096693af7ed193a75602289f865
6
+ metadata.gz: 6c2beef08f80b1090938105321b0e7f27d6cc0fb1ae858a9557bae5a140288b27012a7ee2bde9063dd27f3202d115ba15ec19e7ec8672f412b555c5ca843edc1
7
+ data.tar.gz: 5b0bac0f364682ff322895cfe39534a3bf645f9b422e717a05e4792bd7d83f7362b70303eab34b5564723ec75302d05df347281143bd303b75b761121ee3b084
data/README.md CHANGED
@@ -78,9 +78,9 @@ The following parameters needs to be specified:
78
78
  * required if the `residency_status` is `permanent_resident`
79
79
  * see: [Year of Singapore Permanent Resident (SPR) Status](http://mycpf.cpf.gov.sg/NR/exeres/3D0D66F9-0085-4FD5-9CB5-35B55C0ADA53,frameless.htm)
80
80
  * **ordinary_wages** :
81
- * see : [ordinary wages definition](http://mycpf.cpf.gov.sg/NR/exeres/24537890-6D8E-495E-80D5-E5EFEFCA1905,frameless.htm)
81
+ * see : [ordinary wages definition](https://mycpf.cpf.gov.sg/Employers/EmployerGuides/employer-guides/hiring-employees/cpf-contributions-for-your-employees)
82
82
  * **additional_wages** :
83
- * see : [additional wages definition](http://mycpf.cpf.gov.sg/Employers/Employers_Guide_to_CPF/Glossary/Glossary_Additional_Wages.htm)
83
+ * see : [additional wages definition](https://mycpf.cpf.gov.sg/Employers/EmployerGuides/employer-guides/hiring-employees/cpf-contributions-for-your-employees)
84
84
  * **employee\_contribution\_type** : type of rates to use for the employee's contribution
85
85
  * accepted values : `"full"`, `"graduated"`
86
86
  * note: *full* rates is not supported if the employer's contribution type is *graduated*
@@ -102,6 +102,7 @@ module SingaporeCPFCalculator
102
102
  [
103
103
  Year2014,
104
104
  Year2015,
105
+ Year2016
105
106
  ]
106
107
  end
107
108
  end
@@ -123,3 +124,4 @@ require_relative "singapore_cpf_calculator/spr_2_fg_common"
123
124
  require_relative "singapore_cpf_calculator/spr_2_gg_common"
124
125
  require_relative "singapore_cpf_calculator/year_2014"
125
126
  require_relative "singapore_cpf_calculator/year_2015"
127
+ require_relative "singapore_cpf_calculator/year_2016"
@@ -11,6 +11,7 @@ module SingaporeCPFCalculator
11
11
  # @param [Date] birthdate
12
12
  # @return [Symbol] the symbol representation of the age group
13
13
  # - :group_50_years_and_below
14
+ # - :group_55_years_and_below
14
15
  # - :group_above_50_to_55_years
15
16
  # - :group_above_55_to_60_years
16
17
  # - :group_above_60_to_65_years
@@ -29,22 +30,16 @@ module SingaporeCPFCalculator
29
30
 
30
31
  # @return [Symbol] the symbol representation of the age group
31
32
  # - :group_50_years_and_below
33
+ # - :group_55_years_and_below
32
34
  # - :group_above_50_to_55_years
33
35
  # - :group_above_55_to_60_years
34
36
  # - :group_above_60_to_65_years
35
37
  # - :group_above_65_years
36
38
  def get
37
- case
38
- when age < 50
39
- :group_50_years_and_below
40
- when 50 <= age && age < 55
41
- :group_above_50_to_55_years
42
- when 55 <= age && age < 60
43
- :group_above_55_to_60_years
44
- when 60 <= age && age < 65
45
- :group_above_60_to_65_years
46
- else # 65 <= age
47
- :group_above_65_years
39
+ if current_date.year <= 2015
40
+ age_grouping_for_2015_and_earlier
41
+ else
42
+ age_grouping_for_2016_and_later
48
43
  end
49
44
  end
50
45
 
@@ -66,6 +61,34 @@ module SingaporeCPFCalculator
66
61
  end
67
62
  end
68
63
 
64
+ def age_grouping_for_2015_and_earlier
65
+ case
66
+ when age < 50
67
+ :group_50_years_and_below
68
+ when 50 <= age && age < 55
69
+ :group_above_50_to_55_years
70
+ when 55 <= age && age < 60
71
+ :group_above_55_to_60_years
72
+ when 60 <= age && age < 65
73
+ :group_above_60_to_65_years
74
+ else # 65 <= age
75
+ :group_above_65_years
76
+ end
77
+ end
78
+
79
+ def age_grouping_for_2016_and_later
80
+ case
81
+ when age < 55
82
+ :group_55_years_and_below
83
+ when 55 <= age && age < 60
84
+ :group_above_55_to_60_years
85
+ when 60 <= age && age < 65
86
+ :group_above_60_to_65_years
87
+ else # 65 <= age
88
+ :group_above_65_years
89
+ end
90
+ end
91
+
69
92
  end
70
93
 
71
94
  end
@@ -85,6 +85,7 @@ module SingaporeCPFCalculator
85
85
  end
86
86
  end
87
87
 
88
+ # TC Rate 1 is
88
89
  def tc_rate_1
89
90
  raise NotImplementedError, "sub classes needs to implement #tc_rate_1"
90
91
  end
@@ -4,6 +4,7 @@ module SingaporeCPFCalculator
4
4
  end
5
5
 
6
6
  require_relative "requirements/group_50_years_and_below"
7
+ require_relative "requirements/group_55_years_and_below"
7
8
  require_relative "requirements/group_above_50_to_55_years"
8
9
  require_relative "requirements/group_above_55_to_60_years"
9
10
  require_relative "requirements/group_above_60_to_65_years"
@@ -0,0 +1,13 @@
1
+ module SingaporeCPFCalculator
2
+ module Requirements
3
+ module Group55YearsAndBelow
4
+
5
+ private
6
+
7
+ def required_age_group
8
+ :group_55_years_and_below
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module SingaporeCPFCalculator
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -16,7 +16,7 @@ module SingaporeCPFCalculator
16
16
  # @param [Date] date when the CPF contribution is to be calculated for.
17
17
  # @return [true, false] true when the date's year is 2014
18
18
  def applies_to?(date)
19
- date.year >= 2015
19
+ date.year == 2015
20
20
  end
21
21
 
22
22
  private
@@ -0,0 +1,38 @@
1
+ require_relative "year_2016/base"
2
+ require_relative "year_2016/citizen_or_spr_3"
3
+ require_relative "year_2016/spr_2_gg"
4
+ require_relative "year_2016/spr_2_fg"
5
+ require_relative "year_2016/spr_1_gg"
6
+ require_relative "year_2016/spr_1_fg"
7
+
8
+ module SingaporeCPFCalculator
9
+ # Contains the calculators that are used for determining CPF contribution for 2014.
10
+ module Year2016
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 2015
18
+ def applies_to?(date)
19
+ date.year >= 2016
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
+
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+
4
+ # Base class for 2014 CPF calculators.
5
+ class Base < BaseCalculator
6
+
7
+ private
8
+
9
+ def capped_ordinary_wages
10
+ [d("6_000"), ordinary_wages].min
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "citizen_or_spr_3/age_55_below_contribution_calculator"
2
+ require_relative "citizen_or_spr_3/age_55_to_60_contribution_calculator"
3
+ require_relative "citizen_or_spr_3/age_60_to_65_contribution_calculator"
4
+ require_relative "citizen_or_spr_3/age_65_up_contribution_calculator"
5
+
6
+ module SingaporeCPFCalculator
7
+ module Year2016
8
+
9
+ # Residency module for Singaporean Citizen and Permanent Residents on their 3rd year.
10
+ module CitizenOrSPR3
11
+
12
+ extend ResidencyModuleCommon
13
+ extend CitizenOrSPR3Common
14
+
15
+ class << self
16
+
17
+ private
18
+
19
+ def calculators
20
+ [
21
+ Age55BelowContributionCalculator,
22
+ Age55To60ContributionCalculator,
23
+ Age60To65ContributionCalculator,
24
+ Age65UpContributionCalculator,
25
+ ]
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+ module CitizenOrSPR3
4
+
5
+ # Payment calculator for Singapore's Central Provident Fund for employee's age 50 and below.
6
+ class Age55BelowContributionCalculator < Year2016::Base
7
+
8
+ extend Requirements::Group55YearsAndBelow
9
+
10
+ private
11
+
12
+ def tc_rate_1
13
+ "0.17"
14
+ end
15
+
16
+ def tc_rate_2
17
+ "0.37"
18
+ end
19
+
20
+ def ec_rate
21
+ "0.20"
22
+ end
23
+
24
+ def adjustment_rate
25
+ "0.6"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+ module CitizenOrSPR3
4
+
5
+ # Payment calculator for Singapore's Central Provident Fund for employee's age 55 to 60.
6
+ class Age55To60ContributionCalculator < Year2016::Base
7
+
8
+ extend Requirements::GroupAbove55To60Years
9
+
10
+ private
11
+
12
+ def tc_rate_1
13
+ "0.13"
14
+ end
15
+
16
+ def tc_rate_2
17
+ "0.26"
18
+ end
19
+
20
+ def ec_rate
21
+ "0.13"
22
+ end
23
+
24
+ def adjustment_rate
25
+ "0.39"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+ module CitizenOrSPR3
4
+
5
+ # Payment calculator for Singapore's Central Provident Fund for employee's age 60 to 65.
6
+ class Age60To65ContributionCalculator < Year2016::Base
7
+
8
+ extend Requirements::GroupAbove60To65Years
9
+
10
+ private
11
+
12
+ def tc_rate_1
13
+ "0.09"
14
+ end
15
+
16
+ def tc_rate_2
17
+ "0.165"
18
+ end
19
+
20
+ def ec_rate
21
+ "0.075"
22
+ end
23
+
24
+ def adjustment_rate
25
+ "0.225"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+ module CitizenOrSPR3
4
+
5
+ # Payment calculator for Singapore's Central Provident Fund for employee's age 65 and above.
6
+ class Age65UpContributionCalculator < Year2016::Base
7
+
8
+ extend Requirements::GroupAbove65Years
9
+
10
+ private
11
+
12
+ def tc_rate_1
13
+ "0.075"
14
+ end
15
+
16
+ def tc_rate_2
17
+ "0.125"
18
+ end
19
+
20
+ def ec_rate
21
+ "0.05"
22
+ end
23
+
24
+ def adjustment_rate
25
+ "0.15"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ require_relative "spr_1_fg/age_55_below_contribution_calculator"
2
+ require_relative "spr_1_fg/age_55_to_60_contribution_calculator"
3
+ require_relative "spr_1_fg/age_60_to_65_contribution_calculator"
4
+ require_relative "spr_1_fg/age_65_up_contribution_calculator"
5
+
6
+ module SingaporeCPFCalculator
7
+ module Year2016
8
+
9
+ # For Singapore Permanent Resident (SPR) on their first year with graduated (G, partial)
10
+ # employee contribution and full (F) employer contribution
11
+ module SPR1FG
12
+
13
+ extend ResidencyModuleCommon
14
+ extend SPR1FGCommon
15
+
16
+
17
+ class << self
18
+
19
+ private
20
+
21
+ def calculators
22
+ [
23
+ Age55BelowContributionCalculator,
24
+ Age55To60ContributionCalculator,
25
+ Age60To65ContributionCalculator,
26
+ Age65UpContributionCalculator,
27
+ ]
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ module SingaporeCPFCalculator
2
+ module Year2016
3
+ module SPR1FG
4
+
5
+ # Payment calculator for Singapore's Central Provident Fund for employee's age 50 and below.
6
+ class Age55BelowContributionCalculator < Year2016::Base
7
+
8
+ extend Requirements::Group55YearsAndBelow
9
+
10
+ private
11
+
12
+ def tc_rate_1
13
+ "0.17"
14
+ end
15
+
16
+ def tc_rate_2
17
+ "0.22"
18
+ end
19
+
20
+ def ec_rate
21
+ "0.05"
22
+ end
23
+
24
+ def adjustment_rate
25
+ "0.15"
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end