Class: HrLite::TaxDeclaration
Overview
What an employee claims for the year, section by section, replacing the
single declared_annual_deductions figure an admin used to type in.
The whole year's TDS is projected from this number, so it matters that it
is broken down, that the employee submitted it themselves, and that HR
can record what the proof actually supported.
Constant Summary
collapse
- STATUSES =
%w[draft submitted verified rejected].freeze
- REGIMES =
%w[new old].freeze
Constants included
from Audited
Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.for(user, period_month) ⇒ Object
29
30
31
|
# File 'app/models/hr_lite/tax_declaration.rb', line 29
def self.for(user, period_month)
find_by(user_id: user.id, financial_year: FinancialYear.start_for(period_month))
end
|
Instance Method Details
#allowable_total ⇒ Object
What payroll should actually deduct against. Until HR has verified it,
the declared figure stands — asking somebody to overpay tax all year
because paperwork is slow is its own kind of wrong — but once verified,
only what the proof supported counts.
41
42
43
44
45
|
# File 'app/models/hr_lite/tax_declaration.rb', line 41
def allowable_total
return declared_total unless verified?
tax_declaration_items.sum(BigDecimal(0)) { |i| i.verified_amount || BigDecimal(0) }
end
|
#declared_total ⇒ Object
35
|
# File 'app/models/hr_lite/tax_declaration.rb', line 35
def declared_total = tax_declaration_items.sum(BigDecimal(0)) { |i| i.declared_amount || 0 }
|
#label ⇒ Object
33
|
# File 'app/models/hr_lite/tax_declaration.rb', line 33
def label = "FY #{FinancialYear.label(financial_year)}"
|
#reject!(actor:, note:) ⇒ Object
69
70
71
72
73
74
75
|
# File 'app/models/hr_lite/tax_declaration.rb', line 69
def reject!(actor:, note:)
raise ArgumentError, "a rejection needs a reason" if note.blank?
update!(status: "rejected", verified_by_id: actor.id, verified_at: Time.current, note: note)
notify_employee("Your #{label} tax declaration needs attention")
true
end
|
#submit!(actor:) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/models/hr_lite/tax_declaration.rb', line 47
def submit!(actor:)
raise ActiveRecord::RecordInvalid.new(self), "not a draft" unless draft? || rejected?
update!(status: "submitted", submitted_at: Time.current)
Notifications.publish(
"tax.declaration_submitted",
title: "#{HrLite.display_name(user)} submitted a #{label} tax declaration",
path: "/admin/tax_declarations/#{id}",
bell_to: HrLite.users_holding("tax.manage").to_a
)
true
end
|
#verify!(actor:, note: nil) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'app/models/hr_lite/tax_declaration.rb', line 60
def verify!(actor:, note: nil)
raise ActiveRecord::RecordInvalid.new(self), "not submitted" unless submitted?
update!(status: "verified", verified_by_id: actor.id, verified_at: Time.current,
note: note.presence)
notify_employee("Your #{label} tax declaration was verified")
true
end
|