module Logistics module Core class DemurrageRatePeriod < ApplicationRecord validates :carrier_agent, :from, :to, :rate_period, presence: true belongs_to :carrier_agent def self.generate_carrier_agent_matrix carrier_agents = CarrierAgent.all carrier_agents.each { |carrier_agent| ca = DemurrageRatePeriod.where('carrier_agent_id' => carrier_agent.id) if ca.count == 0 DemurrageRatePeriod.create('carrier_agent_id' => carrier_agent.id, 'from' => 0, 'to' => 0) end } end end end end