Class: HrLite::Admin::ExpensesController
- Inherits:
-
BaseController
- Object
- HrLite::ApplicationController
- BaseController
- HrLite::Admin::ExpensesController
- Defined in:
- app/controllers/hr_lite/admin/expenses_controller.rb
Overview
The other side of the claim: decide it, then say when it was paid.
Instance Method Summary collapse
Instance Method Details
#approve ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/hr_lite/admin/expenses_controller.rb', line 14 def approve expense = decidable.find(params[:id]) expense.approve!(actor: hr_current_user, note: params[:decision_note].presence) redirect_to admin_expenses_path, notice: "Claim approved." end |
#index ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/hr_lite/admin/expenses_controller.rb', line 8 def index @status = params[:status].presence_in(Expense::STATUSES) || "submitted" scope = Expense.where(status: @status).includes(:user, :category).recent_first @expenses = paginate(hr_scope(scope, "expense.approve")) end |
#reimburse ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/controllers/hr_lite/admin/expenses_controller.rb', line 29 def reimburse expense = decidable.find(params[:id]) month = parse_month_param(params[:period_month]) expense.reimburse!(actor: hr_current_user, period_month: month) redirect_to admin_expenses_path, notice: "Marked reimbursed with #{month.strftime('%B %Y')}." rescue ActiveRecord::RecordInvalid redirect_to admin_expenses_path, alert: "Only an approved claim can be reimbursed." end |
#reject ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/hr_lite/admin/expenses_controller.rb', line 20 def reject expense = decidable.find(params[:id]) note = params[:decision_note].to_s.strip return redirect_to admin_expenses_path, alert: "A note is required to reject." if note.blank? expense.reject!(actor: hr_current_user, note: note) redirect_to admin_expenses_path, notice: "Claim rejected." end |