Class: HrLite::HrRequest
Overview
"Can I have a salary certificate?" — the questions that were going to
somebody's inbox and getting lost there.
Constant Summary
collapse
- STATUSES =
%w[open in_progress resolved closed cancelled].freeze
- CATEGORIES =
%w[
salary_certificate employment_certificate address_change bank_change
document_request payroll_query tax_query insurance_query policy_query other
].freeze
Constants included
from Audited
Audited::REDACTED, Audited::SKIPPED_ATTRIBUTES
Instance Method Summary
collapse
Instance Method Details
#assign!(actor:, assignee:) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'app/models/hr_lite/hr_request.rb', line 30
def assign!(actor:, assignee:)
update!(assigned_to_id: assignee.id, status: "in_progress")
Notifications.publish(
"hr_request.assigned",
title: "#{category_label}: #{subject}",
body: "Assigned to you by #{HrLite.display_name(actor)}.",
path: "/admin/hr_requests/#{id}", bell_to: [ assignee ]
)
true
end
|
#cancel!(actor:) ⇒ Object
55
56
57
58
59
60
|
# File 'app/models/hr_lite/hr_request.rb', line 55
def cancel!(actor:)
raise ActiveRecord::RecordInvalid.new(self), "already settled" unless open? || in_progress?
update!(status: "cancelled")
true
end
|
#category_label ⇒ Object
28
|
# File 'app/models/hr_lite/hr_request.rb', line 28
def category_label = category.humanize
|
#resolve!(actor:, resolution:) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/models/hr_lite/hr_request.rb', line 41
def resolve!(actor:, resolution:)
raise ArgumentError, "a resolution needs an answer" if resolution.blank?
update!(status: "resolved", resolution: resolution, resolved_at: Time.current,
assigned_to_id: assigned_to_id || actor.id)
Notifications.publish(
"hr_request.resolved",
title: "Your request was answered — #{subject}",
body: resolution, path: "/hr_requests/#{id}",
bell_to: [ user ], email_to: [ user ]
)
true
end
|