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:) ⇒ 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:) ⇒ BaseCalculator
constructor
A new instance of BaseCalculator.
Constructor Details
#initialize(ordinary_wages:, additional_wages:) ⇒ BaseCalculator
Returns a new instance of BaseCalculator.
33 34 35 36 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 33 def initialize(ordinary_wages:, additional_wages:) @ordinary_wages = ordinary_wages @additional_wages = additional_wages 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:) ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution
22 23 24 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 22 def calculate(ordinary_wages:, additional_wages:) new(ordinary_wages: ordinary_wages, additional_wages: additional_wages).calculate end |
Instance Method Details
#calculate ⇒ Hash
Returns the total, employee, employer amounts for the CPF contribution
39 40 41 42 |
# File 'lib/singapore_cpf_calculator/base_calculator.rb', line 39 def calculate CPFContribution.new total: total_contribution, employee: employee_contribution end |