Class: HouseholdIncomeCalculatorService

Inherits:
BaseCalculatorService show all
Defined in:
app/services/household_income_calculator_service.rb

Overview

A calculator service for the household income for an individual or couple

Constant Summary collapse

MY_FIELDS =
[:marital_status, :fee, :number_of_children, :total_income].freeze
MINIMUM_THRESHOLD =
{ single: 1085, sharing_income: 1245 }.freeze
MAXIMUM_THRESHOLD =
{ single: 5085, sharing_income: 5245 }.freeze
CHILD_ALLOWANCE =
245
VALID_MARITAL_STATUS =
['single', 'sharing_income'].freeze

Instance Attribute Summary

Attributes inherited from BaseCalculatorService

#available_help, #messages, #remission

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCalculatorService

call, #final_decision?, identifier, #initialize

Constructor Details

This class inherits a constructor from BaseCalculatorService

Class Method Details

.fields_required(inputs) ⇒ Object


26
27
28
# File 'app/services/household_income_calculator_service.rb', line 26

def self.fields_required(inputs)
  MY_FIELDS - inputs.keys
end

Instance Method Details

#callObject


14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/household_income_calculator_service.rb', line 14

def call
  return self unless valid?
  if lte_minimum?
    mark_as_help_available
  elsif above_minimum? && lte_maximum?
    mark_as_partial_help_available
  else
    mark_as_help_not_available
  end
  self
end

#valid?Boolean


10
11
12
# File 'app/services/household_income_calculator_service.rb', line 10

def valid?
  all_inputs_present? && all_inputs_correct_type?
end