Class: HrLite::ProfessionalTaxSlab

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

Overview

One state's professional-tax band. PT is a state levy with its own slabs and its own revision schedule, so it is dated separately from the central rate card rather than living inside it.

Constant Summary collapse

NO_LEVY =

A state that genuinely levies nothing. Distinct from a state nobody has configured — see configured?, which is what stops payroll quietly deducting zero for a state whose slabs simply were never entered.

"none".freeze

Constants included from Audited

Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES

Class Method Summary collapse

Class Method Details

.effective_for(state, period_month) ⇒ Object

The bands in force for a state in a given month: the newest effective date that is not in the future, and every band carrying it.



25
26
27
28
29
30
31
# File 'app/models/hr_lite/professional_tax_slab.rb', line 25

def self.effective_for(state, period_month)
  dates = for_state(state).where(effective_from: ..period_month)
  newest = dates.maximum(:effective_from)
  return none if newest.nil?

  for_state(state).where(effective_from: newest).order(:from_amount)
end

.table_for(state, period_month) ⇒ Object

The shape Calculators::ProfessionalTax reads.



34
35
36
37
38
39
# File 'app/models/hr_lite/professional_tax_slab.rb', line 34

def self.table_for(state, period_month)
  effective_for(state, period_month).map do |slab|
    { from: Money.d(slab.from_amount), monthly: Money.d(slab.monthly),
      feb_extra: slab.feb_extra && Money.d(slab.feb_extra) }.compact
  end
end