Sha256: e17c01b5ecf8c24f46f8eacf5ff833c5f07432fac9b95cc63d565367084a1c6f

Contents?: true

Size: 742 Bytes

Versions: 4

Compression:

Stored size: 742 Bytes

Contents

require 'time'

module ActsAsAccount
  class Posting < ActiveRecord::Base
    self.table_name = :acts_as_account_postings

    belongs_to :account,       :class_name => 'ActsAsAccount::Account'
    belongs_to :other_account, :class_name => 'ActsAsAccount::Account'
    belongs_to :journal,       :class_name => 'ActsAsAccount::Journal'
    belongs_to :reference, :polymorphic => true

    scope :soll,       -> { where('amount >= 0') }
    scope :haben,      -> { where('amount < 0') }
    scope :start_date, -> date {
      date = Time.parse(date.to_s).utc.to_s(:db)
      where(['valuta >= ?', date])
    }
    scope :end_date,   -> date {
      date = Time.parse(date.to_s).utc.to_s(:db)
      where(['valuta <= ?', date])
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts_as_account-3.2.2 lib/acts_as_account/posting.rb
acts_as_account-3.2.1 lib/acts_as_account/posting.rb
acts_as_account-3.2.0 lib/acts_as_account/posting.rb
acts_as_account-3.1.2 lib/acts_as_account/posting.rb