module Logistics module Core class ContractService < ApplicationRecord belongs_to :contract belongs_to :chargeable_service_unit_of_charge belongs_to :chargeable_service belongs_to :unit_of_charge belongs_to :service_delivery_unit delegate(:name, to: :chargeable_service, prefix: true, allow_nil: true) delegate(:contract_number, to: :contract, prefix: false, allow_nil: true) def unit_of_charge_name chargeable_service_unit_of_charge&.unit_of_charge&.name end def service_delivery_unit_name chargeable_service_unit_of_charge&.service_delivery_unit&.name end def service_delivery_unit_id chargeable_service_unit_of_charge&.service_delivery_unit_id end end end end