Class: HrLite::SalaryComponent

Inherits:
ApplicationRecord show all
Includes:
Audited
Defined in:
app/models/hr_lite/salary_component.rb

Overview

An earning or deduction head. Data, so an install can add "Night shift allowance" without a gem release — and so a payslip line says what it was for instead of disappearing into "other".

Constant Summary collapse

KINDS =
%w[earning deduction].freeze
STRUCTURAL_CODES =

Heads the structure itself owns. A line item may not use these — they already have a column, and two sources for one number is how a payslip stops adding up.

%w[basic hra special_allowance other_earnings].freeze

Constants included from Audited

Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES

Class Method Summary collapse

Class Method Details

.seed_defaults!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/hr_lite/salary_component.rb', line 31

def self.seed_defaults!
  [
    { code: "bonus", label: "Bonus", prorated: false, position: 10 },
    { code: "incentive", label: "Incentive", prorated: false, position: 20 },
    { code: "arrears", label: "Arrears", prorated: false, position: 30 },
    { code: "lta", label: "Leave travel allowance", prorated: false, position: 40 },
    { code: "reimbursement", label: "Reimbursement", prorated: false, taxable: false,
      counts_for_esi: false, position: 50 },
    { code: "loan_repayment", label: "Loan repayment", kind: "deduction",
      prorated: false, taxable: false, counts_for_esi: false, position: 60 },
    { code: "other_deduction", label: "Other deduction", kind: "deduction",
      prorated: false, taxable: false, counts_for_esi: false, position: 70 }
  ].filter_map do |attributes|
    next if exists?(code: attributes[:code])

    create!(attributes)
    attributes[:code]
  end
end