Class: HrLite::Admin::SalaryStructuresController

Inherits:
LeadershipController show all
Defined in:
app/controllers/hr_lite/admin/salary_structures_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/hr_lite/admin/salary_structures_controller.rb', line 11

def create
  @structure = SalaryStructure.new(structure_params.merge(
    user_id: @profile.user_id, created_by_id: hr_current_user.id
  ))
  if @structure.save
    redirect_to admin_employee_path(@profile), notice: "Salary structure saved."
  else
    render :new, status: :unprocessable_entity
  end
end

#editObject



22
23
24
# File 'app/controllers/hr_lite/admin/salary_structures_controller.rb', line 22

def edit
  @structure = SalaryStructure.where(user_id: @profile.user_id).find(params[:id])
end

#newObject



6
7
8
9
# File 'app/controllers/hr_lite/admin/salary_structures_controller.rb', line 6

def new
  @structure = SalaryStructure.new(user_id: @profile.user_id,
                                   effective_from: Date.current.beginning_of_month)
end

#updateObject



26
27
28
29
30
31
32
33
# File 'app/controllers/hr_lite/admin/salary_structures_controller.rb', line 26

def update
  @structure = SalaryStructure.where(user_id: @profile.user_id).find(params[:id])
  if @structure.update(structure_params)
    redirect_to admin_employee_path(@profile), notice: "Salary structure updated."
  else
    render :edit, status: :unprocessable_entity
  end
end