Module: Models::EmployeeTimeOffDeductions
- Extended by:
- ActiveSupport::Concern
- Included in:
- EmployeeTimeOffAccruals
- Defined in:
- app/concerns/models/employee_time_off_deductions.rb
Overview
Time-off request deductions and non-accruable balance adjustments.
Included into Employee. Records deduction balances for approved time-off
requests and adjusts vacation accruals for requests whose type does not
accrue PTO.
Instance Method Summary collapse
-
#process_time_off_requests ⇒ void
Creates deduction balances for approved time-off requests starting on or before today.
Instance Method Details
#process_time_off_requests ⇒ void
This method returns an undefined value.
Creates deduction balances for approved time-off requests starting on or
before today.
Skips banked-time requests and requests that already have a deduction
balance recorded.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/concerns/models/employee_time_off_deductions.rb', line 22 def process_time_off_requests time_off_requests.approved.where(start_date: ..Date.current).find_each do |request| next if request.banked_time_request? next if time_off_balances.exists?(time_off_request_id: request.id, category: 'deduction') create_balance( time_off_type: request.time_off_type, date: request.start_date, amount: -request.amount, note: "#{request.time_off_type.name} Time off used for #{request.start_date} to #{request.end_date}", time_off_request_id: request.id, category: 'deduction' ) end end |