Sha256: 66220eaebaaccc2696a8ed7a38c8c28cfd159c8edcee4c58f7f5a76af2a6b847
Contents?: true
Size: 834 Bytes
Versions: 18
Compression:
Stored size: 834 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, :raw_hours, presence: true scope :by_overtime, lambda { |id| joins(:overtime_sheet_entry).where(ecom_core_overtime_sheet_entries: { overtime_sheet_id: id }) } scope :revised, ->(revised) { where(revised: revised) } before_save :calculate_hours def calculate_hours rate = OvertimeType.find(overtime_type_id).rate self.hours = raw_hours * rate end end end end
Version data entries
18 entries across 18 versions & 1 rubygems