Class: HrLite::SalaryStructure

Inherits:
ApplicationRecord show all
Includes:
Audited, EncryptedMoney
Defined in:
app/models/hr_lite/salary_structure.rb

Overview

Versioned by effective_from (always the 1st — mid-month revisions and their blended-rate complexity are deliberately unsupported). Structures are never destroyed; a new revision supersedes. Slips snapshot every computed number, so editing a structure cannot corrupt history.

Constant Summary

Constants included from Audited

Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.effective_for(user, period_month) ⇒ Object



21
22
23
24
25
26
# File 'app/models/hr_lite/salary_structure.rb', line 21

def self.effective_for(user, period_month)
  where(user_id: user.id)
    .where(effective_from: ..period_month.beginning_of_month)
    .order(effective_from: :desc)
    .first
end

Instance Method Details

#annual_grossObject



32
33
34
# File 'app/models/hr_lite/salary_structure.rb', line 32

def annual_gross
  monthly_gross * 12
end

#monthly_grossObject



28
29
30
# File 'app/models/hr_lite/salary_structure.rb', line 28

def monthly_gross
  [ basic, hra, special_allowance, other_earnings ].compact.sum(BigDecimal(0))
end