Class: Financo::Transaction

Inherits:
Struct
  • Object
show all
Defined in:
lib/financo/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject

Returns the value of attribute account

Returns:

  • (Object)

    the current value of account



4
5
6
# File 'lib/financo/transaction.rb', line 4

def 
  @account
end

#amountObject

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



4
5
6
# File 'lib/financo/transaction.rb', line 4

def amount
  @amount
end

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



4
5
6
# File 'lib/financo/transaction.rb', line 4

def comment
  @comment
end

#commodityObject

Returns the value of attribute commodity

Returns:

  • (Object)

    the current value of commodity



4
5
6
# File 'lib/financo/transaction.rb', line 4

def commodity
  @commodity
end

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



4
5
6
# File 'lib/financo/transaction.rb', line 4

def date
  @date
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



4
5
6
# File 'lib/financo/transaction.rb', line 4

def description
  @description
end

#exchange_rateObject

Returns the value of attribute exchange_rate

Returns:

  • (Object)

    the current value of exchange_rate



4
5
6
# File 'lib/financo/transaction.rb', line 4

def exchange_rate
  @exchange_rate
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



4
5
6
# File 'lib/financo/transaction.rb', line 4

def id
  @id
end

#original_commodityObject

Returns the value of attribute original_commodity

Returns:

  • (Object)

    the current value of original_commodity



4
5
6
# File 'lib/financo/transaction.rb', line 4

def original_commodity
  @original_commodity
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



4
5
6
# File 'lib/financo/transaction.rb', line 4

def status
  @status
end

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/financo/transaction.rb', line 16

def to_s
  StringIO.open do |s|
    s.puts "#{Time.at(date / 1000).strftime('%Y-%m-%d')} * #{description}"
    s.puts "    ; #{comment}" unless comment.nil? || comment.strip.empty?
    s << "    #{format('%-50s', )} #{amount} #{commodity}"
    s << " {#{exchange_rate} #{original_commodity}}" if
      original_commodity && commodity != original_commodity
    s.puts
    s.puts "      ; TransactionId: #{id}"

    s.string
  end
end