Sha256: d4cfc1d14141e6da5bb4843e37e34833ed83854654d5747bbd2ba7f494901977
Contents?: true
Size: 716 Bytes
Versions: 15
Compression:
Stored size: 716 Bytes
Contents
module Ecom module Core class CrewTime < ApplicationRecord belongs_to :crew belongs_to :overtime_type, optional: true validates :date, :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
15 entries across 15 versions & 1 rubygems