Class: Norma43::Models::Transaction

Inherits:
Object
  • Object
show all
Includes:
Mixins::AttributesAssignment
Defined in:
lib/norma43/models/transaction.rb

Constant Summary

Constants included from Mixins::AttributesAssignment

Mixins::AttributesAssignment::EMPTY_ATTRIBUTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::AttributesAssignment

#attributes, #attributes=

Constructor Details

#initialize(attributes = EMPTY_ATTRIBUTES) ⇒ Transaction

Returns a new instance of Transaction.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/norma43/models/transaction.rb', line 21

def initialize(attributes = EMPTY_ATTRIBUTES)
  @origin_branch_code,
  @transaction_date,
  @value_date,
  @shared_item,
  @own_item,
  @amount_code,
  @amount,
  @document_number,
  @reference_1,
  @reference_2,
  additional_items,
  additional_currency = Hash(attributes).values_at(
    :origin_branch_code,
    :transaction_date,
    :value_date,
    :shared_item,
    :own_item,
    :amount_code,
    :amount,
    :document_number,
    :reference_1,
    :reference_2)
  @additional_items = Array(additional_items).map { |attrs| AdditionalItem.new(attrs) }
  @additional_currency = AdditionalCurrency.new(additional_currency) if additional_currency
end

Instance Attribute Details

#additional_currencyObject

Returns the value of attribute additional_currency.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def additional_currency
  @additional_currency
end

#additional_itemsObject

Returns the value of attribute additional_items.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def additional_items
  @additional_items
end

#amountObject

Returns the value of attribute amount.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def amount
  @amount
end

#amount_codeObject

Returns the value of attribute amount_code.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def amount_code
  @amount_code
end

#document_numberObject

Returns the value of attribute document_number.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def document_number
  @document_number
end

#origin_branch_codeObject

Returns the value of attribute origin_branch_code.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def origin_branch_code
  @origin_branch_code
end

#own_itemObject

Returns the value of attribute own_item.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def own_item
  @own_item
end

#reference_1Object

Returns the value of attribute reference_1.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def reference_1
  @reference_1
end

#reference_2Object

Returns the value of attribute reference_2.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def reference_2
  @reference_2
end

#shared_itemObject

Returns the value of attribute shared_item.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def shared_item
  @shared_item
end

#transaction_dateObject

Returns the value of attribute transaction_date.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def transaction_date
  @transaction_date
end

#value_dateObject

Returns the value of attribute value_date.



8
9
10
# File 'lib/norma43/models/transaction.rb', line 8

def value_date
  @value_date
end

Instance Method Details

#debit?Boolean

Returns:

  • (Boolean)


48
# File 'lib/norma43/models/transaction.rb', line 48

def debit?; self.amount_code == DEBIT_CODE end