Sha256: dd94bf9dca88ada137bee5b4cf42746a32bee323cbca59d182a32c28c931cedb

Contents?: true

Size: 955 Bytes

Versions: 9

Compression:

Stored size: 955 Bytes

Contents

module Logistics
  module Core
    class FreightTonStorageRate < ApplicationRecord
      belongs_to :content_type
      belongs_to :transaction_type
      belongs_to :warehouse_rate_period

      def self.generate_storage_rate(rate_period_id, effective_date)
        transaction_types = TransactionType.all
        content_types = ContentType.all
        transaction_types.each { |tt|
          content_types.each { |ct|
            fsr = FreightTonStorageRate.where('transaction_type_id' => tt.id, 'warehouse_rate_period_id' => rate_period_id,
                                              'content_type_id' => ct.id)
            if fsr.count == 0
              FreightTonStorageRate.create('transaction_type_id' => tt.id, 'warehouse_rate_period_id' => rate_period_id,
                                           'content_type_id' => ct.id,'rate' => 0, '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/freight_ton_storage_rate.rb
logistics_core-21.11.1 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-21.08.1 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-21.03.1 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-20.10.3 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-20.10.2 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-20.10.1 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-20.9.1 app/models/logistics/core/freight_ton_storage_rate.rb
logistics_core-20.8.1 app/models/logistics/core/freight_ton_storage_rate.rb