Sha256: 023bf09204e5534b1a2c4c1aef9cb2c3f42d91520994a5b1c99d600cf4686db8
Contents?: true
Size: 1.14 KB
Versions: 9
Compression:
Stored size: 1.14 KB
Contents
module Logistics module Core class ContainerDemurrageRate < ApplicationRecord belongs_to :container_size belongs_to :transaction_type belongs_to :demurrage_rate_period belongs_to :container_type def self.generate_demurage_rate(rate_period_id) transaction_types = TransactionType.all container_sizes = ContainerSize.all container_types = ContainerType.all transaction_types.each { |t| container_sizes.each { |c| container_types.each { |ct| rate = ContainerDemurrageRate.where('transaction_type_id' => t.id, 'container_size_id' => c.id, 'container_type_id' => ct.id, 'demurrage_rate_period_id' => rate_period_id) if rate.count == 0 ContainerDemurrageRate.create('transaction_type_id' => t.id, 'container_size_id' => c.id, 'container_type_id' => ct.id, 'demurrage_rate_period_id' => rate_period_id, 'rate' => 0) end } } } end end end end
Version data entries
9 entries across 9 versions & 1 rubygems