Class: SingaporeCPFCalculator::BaseCalculator
- Inherits:
-
Object
- Object
- SingaporeCPFCalculator::BaseCalculator
- Defined in:
- lib/singapore_cpf_calculator/base_calculator.rb
Overview
Base class for CPF calculators.
Direct Known Subclasses
Class Method Summary collapse
-
.applies_to?(date, birthdate:) ⇒ true, false
Returns true if the calculator applies to the employee’s age.
-
.calculate(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution.
Instance Method Summary collapse
-
#calculate ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution.
-
#initialize(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) ⇒ BaseCalculator
constructor
A new instance of BaseCalculator.
Constructor Details
#initialize(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) ⇒ BaseCalculator
Returns a new instance of BaseCalculator.
38 39 40 41 42 43 44 45 46 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 38 def initialize(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) @ordinary_wages = ordinary_wages @ytd_ow_subject_to_cpf = ytd_ow_subject_to_cpf @ytd_additional_wages = ytd_additional_wages @estimated_yearly_ow = estimated_yearly_ow @additional_wages = additional_wages clip_additional_wages_based_on_ceiling() end |
Class Method Details
.applies_to?(date, birthdate:) ⇒ true, false
Returns true if the calculator applies to the employee’s age.
8 9 10 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 8 def applies_to?(date, birthdate:) AgeGroup.get(date, birthdate: birthdate) == required_age_group end |
.calculate(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution
24 25 26 27 28 29 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 24 def calculate(ordinary_wages:, additional_wages:, ytd_additional_wages: 0.0, ytd_ow_subject_to_cpf: 0.0, estimated_yearly_ow: 0.0) new(ordinary_wages: ordinary_wages, additional_wages: additional_wages, ytd_ow_subject_to_cpf: ytd_ow_subject_to_cpf, ytd_additional_wages: ytd_additional_wages, estimated_yearly_ow: estimated_yearly_ow).calculate end |
Instance Method Details
#calculate ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution
49 50 51 52 53 54 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 49 def calculate CPFContribution.new total: total_contribution, employee: employee_contribution, aw_subject_to_cpf: additional_wages, ow_subject_to_cpf: capped_ordinary_wages end |