class ESA::BalanceChecker

Public Class Methods

check(context, options = {}) click to toggle source
# File lib/esa/balance_checker.rb, line 3
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