module Logistics module Core class EslTransportTariffRate < ApplicationRecord belongs_to :esl_transport_tariff validates :esl_transport_tariff, :qt_from, :qt_to, :rate, presence: true validates_uniqueness_of :esl_transport_tariff, :scope => [:qt_from, :qt_to] def to_json JSON.parse( Jbuilder.encode do |json| json.id self.id json.esl_transport_tariff_id self.esl_transport_tariff_id json.esl_transport_tariff_name self.esl_transport_tariff ? "#{self.esl_transport_tariff.name} (#{self.esl_transport_tariff.storage_point})" : '' json.qt_from self.qt_from json.qt_to self.qt_to json.rate self.rate end ) end end end end