Sha256: 37e38709d6078e73dc5e1eaa03b0400ddc80320f949d6cde4977842c40492179

Contents?: true

Size: 416 Bytes

Versions: 6

Compression:

Stored size: 416 Bytes

Contents

module Plutus
  # Association extension for has_many :amounts relations. Internal.
  module AmountsExtension
    # Returns a sum of the referenced Amount objects.
    def balance
      balance = BigDecimal.new('0')
      each do |amount_record|
        if amount_record.amount
          balance += amount_record.amount
        else
          balance = nil
        end
      end
      return balance
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
plutus-0.10.1 app/models/plutus/amounts_extension.rb
plutus-0.10.0 app/models/plutus/amounts_extension.rb
plutus-0.9.0 app/models/plutus/amounts_extension.rb
plutus-0.8.1 app/models/plutus/amounts_extension.rb
plutus-0.8.0 app/models/plutus/amounts_extension.rb
plutus-0.7.4 app/models/plutus/amounts_extension.rb