Sha256: 148c6303d906234842bccf759e97bbe96fa0532ef350e1a56c6027a9df409f3e

Contents?: true

Size: 978 Bytes

Versions: 9

Compression:

Stored size: 978 Bytes

Contents

module Logistics
  module Core
    class BreakBulkDemurrageRate < ApplicationRecord
      belongs_to :break_bulk_unit
      belongs_to :transaction_type
      belongs_to :demurrage_rate_period

      def self.generate_demurage_rate(rate_period_id, effective_date)
        transaction_types = get_transaction_types
        break_bulk_units = get_break_bulk_units
        transaction_types.each { |tt|
          break_bulk_units.each{ |bb|
            bdr = BreakBulkDemurrageRate.where('transaction_type_id' => tt.id, 'demurage_rate_period_id' => rate_period_id,
                                              'break_bulk_unit_id' => bb.id)
            if bdr.count == 0
              BreakBulkDemurrageRate.create('transaction_type_id' => tt.id, 'demurage_rate_period_id' => rate_period_id,
                                           'break_bulk_unit_id' => bb.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/break_bulk_demurrage_rate.rb
logistics_core-21.11.1 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-21.08.1 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-21.03.1 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-20.10.3 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-20.10.2 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-20.10.1 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-20.9.1 app/models/logistics/core/break_bulk_demurrage_rate.rb
logistics_core-20.8.1 app/models/logistics/core/break_bulk_demurrage_rate.rb