module Mks module Rate class ServiceRate < ApplicationRecord validates :base_rate, :utilization_rate, :chargeable_service_id, presence: true belongs_to :chargeable_service belongs_to :equipment_item, class_name: 'Mks::Edm::EquipmentItem', optional: true delegate(:name, to: :chargeable_service, prefix: true) delegate(:name, to: :equipment_item, prefix: true, allow_nil: true) delegate(:service_delivery_unit_id, to: :chargeable_service, prefix: false) delegate(:service_delivery_unit_name, to: :chargeable_service, prefix: false) alias_method :sdu_id, :service_delivery_unit_id alias_method :sdu_name, :service_delivery_unit_name end end end