Module: HrLite::Money

Defined in:
lib/hr_lite/money.rb

Overview

Central rounding discipline. Each statutory line rounds by its own rule exactly once; nets are plain subtraction of already-rounded lines.

Class Method Summary collapse

Class Method Details

.ceil_rupee(value) ⇒ Object

Next rupee (ESIC rounds contributions UP).



19
20
21
# File 'lib/hr_lite/money.rb', line 19

def ceil_rupee(value)
  d(value).ceil(0)
end

.d(value) ⇒ Object



7
8
9
10
11
# File 'lib/hr_lite/money.rb', line 7

def d(value)
  return BigDecimal(0) if value.nil?

  value.is_a?(BigDecimal) ? value : BigDecimal(value.to_s)
end

.round2(value) ⇒ Object

Paise precision (earnings proration).



24
25
26
# File 'lib/hr_lite/money.rb', line 24

def round2(value)
  d(value).round(2)
end

.round_rupee(value) ⇒ Object

Nearest rupee, half-up (PF, TDS monthly).



14
15
16
# File 'lib/hr_lite/money.rb', line 14

def round_rupee(value)
  d(value).round(0, BigDecimal::ROUND_HALF_UP)
end

.round_to_10(value) ⇒ Object

Section 288B: annual tax to the nearest ten rupees.



29
30
31
# File 'lib/hr_lite/money.rb', line 29

def round_to_10(value)
  (d(value) / 10).round(0, BigDecimal::ROUND_HALF_UP) * 10
end