app/models/date_attended.rb
# == Schema Information
#
# Table name: dates_attended
#
# id :integer not null, primary key
# date :date
# created_at :datetime
# updated_at :datetime
# date_to :date
# uuid :uuid
# attended_item_id :integer
# attended_item_type :string
#
class DateAttended < ApplicationRecord
include Duplicable
belongs_to :attended_item, polymorphic: true
validates_with DateAttendedValidator
def claim
attended_item.try(:claim)
end
def perform_validation?
claim&.perform_validation?
end
def earliest_date_before_reporder
attended_item.try(:claim).earliest_representation_order_date
end
def to_s
return '' if date.nil?
if date_to.nil?
date.strftime(Settings.date_format).to_s
else
"#{date.strftime(Settings.date_format)} - #{date_to.strftime(Settings.date_format)}"
end
end
end