module Logistics module Core class WarehouseRatePeriod < ApplicationRecord validates :warehouse_id, :from, :to, :rate_period, presence: true belongs_to :warehouse def self.generate_rate_period_matrix warehouses = Warehouse.all warehouses.each { |warehouse| w = WarehouseRatePeriod.where('warehouse_id' => warehouse.id) if w.count == 0 WarehouseRatePeriod.create('warehouse_id' => warehouse.id, 'from' => 0, 'to' => 0) end } end end end end