class MudratProjector::Projection

Constants

SequenceEntry

Attributes

range[R]

Public Class Methods

new(range: date_range, chart: chart_of_accounts) click to toggle source
# File lib/mudrat_projector/projection.rb, line 15
def initialize range: date_range, chart: chart_of_accounts
  @chart                = chart
  @batch_id             = 0
  @range                = range
  @transaction_sequence = []
end

Public Instance Methods

<<(transaction) click to toggle source
# File lib/mudrat_projector/projection.rb, line 22
def << transaction
  @transaction_sequence.push SequenceEntry.new(transaction, @batch_id)
end
add_transaction_batch(batch) click to toggle source
# File lib/mudrat_projector/projection.rb, line 26
def add_transaction_batch batch
  batch.each do |transaction| 
    self << transaction
    @batch_id += 1
  end
end
project!() { |transaction| ... } click to toggle source
# File lib/mudrat_projector/projection.rb, line 33
def project!
  freeze
  transaction_sequence.each do |transaction|
    @chart.apply_transaction transaction
    yield transaction if block_given?
  end
end
transaction_sequence() click to toggle source
# File lib/mudrat_projector/projection.rb, line 41
def transaction_sequence
  @transaction_sequence.tap(&:sort!).map &:transaction
end