Sha256: 8eba0957f16f5a173cf4cb3f5f55e43ad38a49ace3bbc7e05b185c664258140b

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 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'

      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

1 entries across 1 versions & 1 rubygems

Version Path
ecom_core-1.1.17 app/models/ecom/core/crew_overtime.rb