Class: HrLite::Admin::PayrollRunsController
- Inherits:
-
LeadershipController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- HrLite::Admin::PayrollRunsController
- Defined in:
- app/controllers/hr_lite/admin/payroll_runs_controller.rb
Instance Method Summary collapse
- #compute ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #finalize ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #publish ⇒ Object
-
#register ⇒ Object
Payout register: the full money sheet including bank details — deliberately leadership-only PII.
- #show ⇒ Object
- #unlock ⇒ Object
Instance Method Details
#compute ⇒ Object
38 39 40 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 38 def compute transition { |run| run.compute!(actor: hr_current_user) && "Computed — review the slips." } end |
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 12 def create month = parse_month_param(params.dig(:payroll_run, :period_month)) @run = PayrollRun.new(period_month: month, created_by_id: hr_current_user.id, notes: params.dig(:payroll_run, :notes)) if @run.save redirect_to admin_payroll_run_path(@run), notice: "Run created — compute when ready." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 28 def destroy run = PayrollRun.find(params[:id]) if run.destroy redirect_to admin_payroll_runs_path, notice: "Draft run deleted.", status: :see_other else redirect_to admin_payroll_run_path(run), alert: run.errors..to_sentence, status: :see_other end end |
#finalize ⇒ Object
42 43 44 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 42 def finalize transition { |run| run.finalize!(actor: hr_current_user) && "Run finalized." } end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 4 def index @runs = paginate(PayrollRun.recent_first) end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 8 def new @run = PayrollRun.new(period_month: Date.current.prev_month.beginning_of_month) end |
#publish ⇒ Object
50 51 52 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 50 def publish transition { |run| run.publish!(actor: hr_current_user) && "Published — employees notified." } end |
#register ⇒ Object
Payout register: the full money sheet including bank details — deliberately leadership-only PII.
56 57 58 59 60 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 56 def register run = PayrollRun.find(params[:id]) send_data register_csv(run), filename: "payroll-register-#{run.period_month.strftime('%Y-%m')}.csv", type: "text/csv" end |
#show ⇒ Object
23 24 25 26 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 23 def show @run = PayrollRun.find(params[:id]) @slips = @run.salary_slips.includes(:user).sort_by { |slip| HrLite.display_name(slip.user) } end |
#unlock ⇒ Object
46 47 48 |
# File 'app/controllers/hr_lite/admin/payroll_runs_controller.rb', line 46 def unlock transition { |run| run.unlock!(actor: hr_current_user) && "Back in review." } end |