Sha256: 8807394d6c648d13e4ee6e8cf0e529b33ead6c215e5cfbb978f865ae8f8ffc36

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

module Ecom
  module Core
    class CrewTime < ApplicationRecord
      belongs_to :crew
      belongs_to :attendance_sheet
      belongs_to :overtime_type, optional: true

      validates :hours, :converted_hours, presence: true
      # validates_each :date do |record, attr, value|
      #   if record.crew && value && (value < record.crew.employment_date)
      #     record.errors.add(attr, 'should be after employment date')
      #   end
      # end

      before_save :calculate_converted_hours

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecom_core-1.1.8 app/models/ecom/core/crew_time.rb