Class: Ecom::Core::CrewOvertime
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Ecom::Core::CrewOvertime
- Defined in:
- app/models/ecom/core/crew_overtime.rb
Instance Method Summary collapse
Instance Method Details
#calculate_hours ⇒ Object
40 41 42 43 |
# File 'app/models/ecom/core/crew_overtime.rb', line 40 def calculate_hours rate = OvertimeType.find(overtime_type_id).rate self.hours = raw_hours * rate end |
#validate_overtime_by_type ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/ecom/core/crew_overtime.rb', line 25 def validate_overtime_by_type return unless overtime_type start = Time.zone.parse(overtime_type.from) finish = Time.zone.parse(overtime_type.to) diff = if finish >= start ((finish - start) / 3600).round else ((start - finish) / 3600).round end return unless raw_hours > diff errors.add(:crew_overtime, 'The selected overtime type does not allow the specified amount of hours.') end |