Module: SingaporeCharitableDonations::Calculators::CDAC::Year2015Calculator

Defined in:
lib/singapore_charitable_donations/calculators/cdac/year_2015_calculator.rb

Overview

Chinese Development Assistance Council (CDAC) Fund contribution calculator for year 2015 onwards.

Class Method Summary collapse

Class Method Details

.applies_to?(date, type) ⇒ TrueClass, FalseClass

Parameters:

  • date (Date)

    to be considered for calculation

  • type (String)

    of charitable contribution

Returns:

  • (TrueClass, FalseClass)


29
30
31
# File 'lib/singapore_charitable_donations/calculators/cdac/year_2015_calculator.rb', line 29

def applies_to?(date, type)
  date.year >= 2015 && type == 'CDAC'
end

.calculate(total_wage) ⇒ BigDecimal

Returns contribution amount.

Parameters:

  • total_wage (BigDecimal)

Returns:

  • (BigDecimal)

    contribution amount



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/singapore_charitable_donations/calculators/cdac/year_2015_calculator.rb', line 11

def calculate(total_wage)
  case
  when total_wage <= 2_000.00
    BigDecimal "0.50"
  when total_wage <= 3_500.00
    BigDecimal "1.00"
  when total_wage <= 5_000.00
    BigDecimal "1.50"
  when total_wage <= 7_500.00
    BigDecimal "2.00"
  when total_wage > 7_500.00
    BigDecimal "3.00"
  end
end