Module: HrLite::Calculators::Tds
- Defined in:
- app/services/hr_lite/calculators/tds.rb
Overview
Projection-grade TDS (not Form-16-grade — no surcharge, perquisites or HRA-exemption math; the per-slip override is the escape hatch and the slip shows the whole working so "why is my TDS X" answers itself).
projected annual gross = FY gross paid so far + this month
+ structure gross × months remaining after this one
taxable = projected − standard deduction − (old regime: declared deductions)
annual = slab tax − 87A rebate (full when taxable ≤ cap) + 4% cess, §288B rounded
monthly = max((annual − TDS already deducted) / months remaining incl. this, 0)
Defined Under Namespace
Classes: Result
Constant Summary collapse
- HIGH_INCOME_WARNING_THRESHOLD =
BigDecimal("5000000")
Class Method Summary collapse
Class Method Details
.call(regime:, structure_monthly_gross:, gross_earned_this_month:, fy_gross_paid:, fy_tds_paid:, months_remaining:, declared_annual_deductions:, rates:, override: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/services/hr_lite/calculators/tds.rb', line 18 def self.call(regime:, structure_monthly_gross:, gross_earned_this_month:, fy_gross_paid:, fy_tds_paid:, months_remaining:, declared_annual_deductions:, rates:, override: nil) table = rates[regime.to_s] || rates["new"] if override.present? monthly = Money.round_rupee(override) return Result.new(monthly: monthly, projected_annual_gross: nil, taxable: nil, annual_tax: nil, details: { "regime" => regime.to_s, "override" => monthly.to_s("F") }) end months_remaining = [ months_remaining.to_i, 1 ].max projected = Money.d(fy_gross_paid) + Money.d(gross_earned_this_month) + (Money.d(structure_monthly_gross) * (months_remaining - 1)) deductions = table[:standard_deduction] deductions += Money.d(declared_annual_deductions) if regime.to_s == "old" taxable = [ projected - deductions, BigDecimal(0) ].max slab_tax = slab_tax_for(taxable, table[:slabs]) slab_tax = BigDecimal(0) if taxable <= table[:rebate_cap] # §87A full rebate annual = Money.round_to_10(slab_tax * (1 + table[:cess_rate])) monthly = Money.round_rupee((annual - Money.d(fy_tds_paid)) / months_remaining) monthly = BigDecimal(0) if monthly.negative? Result.new( monthly: monthly, projected_annual_gross: Money.round2(projected), taxable: Money.round2(taxable), annual_tax: annual, details: { "regime" => regime.to_s, "projected_annual_gross" => Money.round2(projected).to_s("F"), "standard_deduction" => table[:standard_deduction].to_s("F"), "declared_deductions" => (regime.to_s == "old" ? Money.d(declared_annual_deductions).to_s("F") : "0"), "taxable" => Money.round2(taxable).to_s("F"), "annual_tax_with_cess" => annual.to_s("F"), "fy_tds_already_deducted" => Money.d(fy_tds_paid).to_s("F"), "months_remaining" => months_remaining.to_s, "high_income_review" => (taxable > HIGH_INCOME_WARNING_THRESHOLD).to_s } ) end |