Class: Logistics::Core::FreightTonDemurrageRate

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/logistics/core/freight_ton_demurrage_rate.rb

Class Method Summary collapse

Methods inherited from ApplicationRecord

as_json

Class Method Details

.generate_demurage_rate(rate_period_id, effective_date) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/models/logistics/core/freight_ton_demurrage_rate.rb', line 7

def self.generate_demurage_rate(rate_period_id, effective_date)
  transaction_types = get_transaction_types
  transaction_types.each { |tt|
    tdr = FreightTonDemurrageRate.where('transaction_type_id' => tt.id, 'demurage_rate_period_id' => rate_period_id)
    if tdr.count == 0
      FreightTonDemurrageRate.create('transaction_type_id' => tt.id, 'demurage_rate_period_id' => rate_period_id,
                                     'rate' => 0, 'effective_date' => effective_date)
    end
  }
end