Sha256: b66f47b65cafbd5a021ed4d1d5e001a70453d13aa75358c1a5bb6b56ed75d7b2

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

module Logistics
  module Core
    class ContainerStorageRate < ApplicationRecord
      belongs_to :container_size
      belongs_to :transaction_type
      belongs_to :warehouse_rate_period
      belongs_to :container_type
      belongs_to :content_type

      def self.generate_storage_rate(rate_period_id, effective_date)
        transaction_types = TransactionType.all
        container_sizes = ContainerSize.all
        content_types = ContentType.all
        container_types = ContainerType.all
        transaction_types.each { |t|
          container_sizes.each { |c|
            content_types.each { |ct|
              container_types.each { |container_type|
                rate = ContainerStorageRate.where('transaction_type_id' => t.id, 'container_size_id' => c.id,
                                                  'content_type_id' => ct.id, 'container_type_id' => container_type.id,
                                                  'warehouse_rate_period_id' => rate_period_id)
                if rate.count == 0
                  ContainerStorageRate.create('transaction_type_id' => t.id, 'container_size_id' => c.id, 'rate' => 0,
                                              'content_type_id' => ct.id, 'container_type_id' => container_type.id,
                                              'warehouse_rate_period_id' => rate_period_id, 'effective_date' => effective_date)
                end
              }
            }
          }
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/models/logistics/core/container_storage_rate.rb
logistics_core-21.11.1 app/models/logistics/core/container_storage_rate.rb
logistics_core-21.08.1 app/models/logistics/core/container_storage_rate.rb
logistics_core-21.03.1 app/models/logistics/core/container_storage_rate.rb
logistics_core-20.10.3 app/models/logistics/core/container_storage_rate.rb
logistics_core-20.10.2 app/models/logistics/core/container_storage_rate.rb
logistics_core-20.10.1 app/models/logistics/core/container_storage_rate.rb
logistics_core-20.9.1 app/models/logistics/core/container_storage_rate.rb
logistics_core-20.8.1 app/models/logistics/core/container_storage_rate.rb