Sha256: 854806d77b28cbfbb28eba5b08530fb61f91d2db2f9b0c9e744739b69ec7ed23

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

module Ecom
  module Core
    class CrewOvertime < ApplicationRecord
      belongs_to :overtime_type
      belongs_to :overtime_sheet_entry
      belongs_to :revision_to, class_name: 'Ecom::Core::CrewOvertime', optional: true
      belongs_to :created_by, class_name: 'Ecom::Core::User'

      has_one :revision, class_name: 'Ecom::Core::CrewOvertime', foreign_key: :revision_to_id

      validates :hours, :converted_hours, presence: true

      before_save :calculate_converted_hours

      def calculate_converted_hours
        rate = OvertimeType.find(overtime_type_id).rate
        self.converted_hours = hours * rate
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecom_core-1.1.20 app/models/ecom/core/crew_overtime.rb
ecom_core-1.1.19 app/models/ecom/core/crew_overtime.rb
ecom_core-1.1.18 app/models/ecom/core/crew_overtime.rb