Class: ActsAsAccount::Transfer

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_account/transfer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(posting_1, posting_2) ⇒ Transfer

Returns a new instance of Transfer.



5
6
7
8
9
10
# File 'lib/acts_as_account/transfer.rb', line 5

def initialize(posting_1, posting_2)
  @amount, @reference = posting_2.amount, posting_2.reference
  @from, @to = posting_1., posting_2.
  @journal = posting_1.journal
  @valuta = posting_1.valuta
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def amount
  @amount
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def from
  @from
end

#journalObject

Returns the value of attribute journal.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def journal
  @journal
end

#referenceObject

Returns the value of attribute reference.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def reference
  @reference
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def to
  @to
end

#valutaObject

Returns the value of attribute valuta.



3
4
5
# File 'lib/acts_as_account/transfer.rb', line 3

def valuta
  @valuta
end

Instance Method Details

#referencing_a?(klasse) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/acts_as_account/transfer.rb', line 12

def referencing_a?(klasse)
  reference.kind_of?(klasse)
end

#reverse(valuta = Time.now, reference = @reference, amount = @amount) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/acts_as_account/transfer.rb', line 16

def reverse(valuta = Time.now, reference = @reference, amount = @amount)
  @journal.transfer(
    amount,
    @to,
    @from,
    reference,
    valuta)
end