Module: HrLite::Calculators::Esi

Defined in:
app/services/hr_lite/calculators/esi.rb

Overview

ESI: eligibility is decided on the FULL structure monthly gross (a low-attendance month must not pull someone into ESI); when eligible, contributions apply to the earned gross and round UP to the next rupee (ESIC rule).

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.call(monthly_gross:, gross_earned:, applicable:, rates:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/hr_lite/calculators/esi.rb', line 12

def self.call(monthly_gross:, gross_earned:, applicable:, rates:)
  eligible = applicable && Money.d(monthly_gross) <= rates[:gross_ceiling]
  return Result.new(applicable: false, employee: BigDecimal(0), employer: BigDecimal(0)) unless eligible

  earned = Money.d(gross_earned)
  Result.new(
    applicable: true,
    employee: Money.ceil_rupee(earned * rates[:employee_rate]),
    employer: Money.ceil_rupee(earned * rates[:employer_rate])
  )
end