Sha256: b146b7a4047627d34a8089512b3686abcd94c664ea26f88a119daab891e80c2e

Contents?: true

Size: 917 Bytes

Versions: 5

Compression:

Stored size: 917 Bytes

Contents

module ESA
  class BalanceChecker
    def self.check(context)
      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

5 entries across 5 versions & 1 rubygems

Version Path
event_sourced_accounting-0.1.6 lib/esa/balance_checker.rb
event_sourced_accounting-0.1.4 lib/esa/balance_checker.rb
event_sourced_accounting-0.1.3 lib/esa/balance_checker.rb
event_sourced_accounting-0.1.1 lib/esa/balance_checker.rb
event_sourced_accounting-0.1.0 lib/esa/balance_checker.rb