Sha256: e230146a7213692ed5a82321f91d4f7265081c623d765f40060443e57e0caffe

Contents?: true

Size: 931 Bytes

Versions: 4

Compression:

Stored size: 931 Bytes

Contents

module ESA
  class BalanceChecker
    def self.check(context, options = {})
      if context.can_be_persisted? and not context.freshness.nil?
        #context.event_count = context.events.created_before(context.freshness).count
        #context.flag_count = context.flags.created_before(context.freshness).count
        context.transaction_count = context.transactions.created_before(context.freshness).count
        context.amount_count = context.amounts.created_before(context.freshness).count

        context.debits_total = context.amounts.debits.created_before(context.freshness).total
        context.credits_total = context.amounts.credits.created_before(context.freshness).total
        context.opening_balance = context.opening_context.amounts.created_before(context.freshness).balance
        context.closing_balance = context.closing_context.amounts.created_before(context.freshness).balance
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
event_sourced_accounting-0.2.6 lib/esa/balance_checker.rb
event_sourced_accounting-0.2.4 lib/esa/balance_checker.rb
event_sourced_accounting-0.2.3 lib/esa/balance_checker.rb
event_sourced_accounting-0.2.2 lib/esa/balance_checker.rb