Sha256: 2ca04a455d269a24409fe4d8e619032db11c13e28d6316f4c0d218f3f56f458b

Contents?: true

Size: 661 Bytes

Versions: 9

Compression:

Stored size: 661 Bytes

Contents

module Logistics
  module Core
    class DemurrageRate < ApplicationRecord
      belongs_to :demurrage_rate_period
      belongs_to :unit_of_charge

      def self.generate_demurage_rate(rate_period_id)
        unit_of_charges = UnitOfCharge.all
        unit_of_charges.each { |unit_of_charge|
          uoc = DemurrageRate.where('unit_of_charge_id' => unit_of_charge.id, 'demurage_rate_period_id' => rate_period_id)
          if uoc.count == 0
            DemurrageRate.create('unit_of_charge_id' => unit_of_charge.id, 'demurage_rate_period_id' => rate_period_id,
                                'rate' => 0)
          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/demurrage_rate.rb
logistics_core-21.11.1 app/models/logistics/core/demurrage_rate.rb
logistics_core-21.08.1 app/models/logistics/core/demurrage_rate.rb
logistics_core-21.03.1 app/models/logistics/core/demurrage_rate.rb
logistics_core-20.10.3 app/models/logistics/core/demurrage_rate.rb
logistics_core-20.10.2 app/models/logistics/core/demurrage_rate.rb
logistics_core-20.10.1 app/models/logistics/core/demurrage_rate.rb
logistics_core-20.9.1 app/models/logistics/core/demurrage_rate.rb
logistics_core-20.8.1 app/models/logistics/core/demurrage_rate.rb