4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/hr_lite/admin/resignations_controller.rb', line 4
def accept
resignation = Resignation.find(params[:id])
resignation.accept!(
actor: hr_current_user,
last_day: params[:last_day].presence && parse_date_param(params[:last_day]),
note: params[:note]
)
notice = if resignation.exit_date_recorded?
"Resignation accepted — exit date recorded on the profile."
else
"Resignation accepted. No employee profile exists for " \
"#{hr_display_name(resignation.user)}, so no exit date was recorded — " \
"create the profile to clip attendance and payroll."
end
redirect_to admin_employees_path, notice: notice
rescue ActiveRecord::RecordInvalid => e
message = resignation.reload.pending? ? e.record.errors.full_messages.to_sentence
: "Only pending resignations can be accepted."
redirect_to admin_employees_path, alert: message
end
|