Module: HrLite::Calculators::Proration

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

Overview

Calendar-day proration: each structure component earns full × payable/days_in_month, rounded to paise per line.

Constant Summary collapse

COMPONENTS =
[
  [ "basic", "Basic" ],
  [ "hra", "HRA" ],
  [ "special_allowance", "Special allowance" ],
  [ "other_earnings", "Other earnings" ]
].freeze

Class Method Summary collapse

Class Method Details

.call(structure:, payable_days:, days_in_month:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/hr_lite/calculators/proration.rb', line 13

def self.call(structure:, payable_days:, days_in_month:)
  factor = Money.d(payable_days) / Money.d(days_in_month)

  COMPONENTS.filter_map do |attribute, label|
    full = structure.public_send(attribute)
    next if full.nil? || full.zero?

    {
      code: attribute,
      label: label,
      full_amount: Money.round2(full),
      amount: Money.round2(full * factor)
    }
  end
end