Class: SalariesController
- Inherits:
-
InvoicesController
- Object
- InvoicesController
- SalariesController
- Defined in:
- app/controllers/salaries_controller.rb
Instance Method Summary collapse
- #new ⇒ Object
- #payslip ⇒ Object
-
#select_employee ⇒ Object
Actions =======.
Instance Method Details
#new ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/salaries_controller.rb', line 26 def new @salary = Salary.new(params[:salary]) @salary.state = 'booked' unless @salary.employee # Trigger validation to flag bad values in select form @salary.valid? render :action => 'select_employee' and return end # Deduced defaults @salary.employer_id = current_tenant.company.id month_name = t('date.month_names')[@salary.duration_from.month] @salary.title = "Lohn #{month_name} #{@salary.duration_from.year} - #{@salary.employee.vcard.full_name}" @salary.duration_to = @salary.duration_from.end_of_month @salary.leave_days_balance = @salary.previous.try(:leave_days_balance) || 0 @salary.used_leave_days = 0 # Prebuild line items @salary.build_line_items # Prebuild an empty attachment instance @salary..build new! end |
#payslip ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/salaries_controller.rb', line 55 def payslip @salary = Salary.find(params[:id]) @include_hours_table = @salary.track_hours? @include_leave_days_table = @salary.track_leave_days? if @include_hours_table @hours_carry = @salary.hours_carry work_days = @salary.work_days @hours_due = work_days.sum(:hours_due) @hours_worked = work_days.sum(:hours_worked) @hours_saldo = work_days.last.overall_overtime end show! do |format| format.html { redirect_to :action => :show } end end |
#select_employee ⇒ Object
Actions
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/salaries_controller.rb', line 14 def select_employee # Allow pre-seeding some parameters salary_params = { :duration_from => Date.today.beginning_of_month } # Set default parameters salary_params.merge!(params[:salary]) if params[:salary] @salary = Salary.new(salary_params) end |