Class: OfxImport

Inherits:
Object
  • Object
show all
Defined in:
app/models/ofx_import.rb

Defined Under Namespace

Classes: InvalidOfxFile, OfxFileHasMultipleAccounts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, cash = nil) ⇒ OfxImport

Returns a new instance of OfxImport.


7
8
9
10
# File 'app/models/ofx_import.rb', line 7

def initialize(file, cash = nil)
  @file = file
  @cash = cash
end

Instance Attribute Details

#bank_statementObject (readonly)

Returns the value of attribute bank_statement


5
6
7
# File 'app/models/ofx_import.rb', line 5

def bank_statement
  @bank_statement
end

#cashObject (readonly)

Returns the value of attribute cash


5
6
7
# File 'app/models/ofx_import.rb', line 5

def cash
  @cash
end

#errorObject (readonly)

Returns the value of attribute error


5
6
7
# File 'app/models/ofx_import.rb', line 5

def error
  @error
end

#internal_errorObject (readonly)

Returns the value of attribute internal_error


5
6
7
# File 'app/models/ofx_import.rb', line 5

def internal_error
  @internal_error
end

Instance Method Details

#recoverable?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'app/models/ofx_import.rb', line 20

def recoverable?
  bank_statement.present?
end

#runObject


12
13
14
15
16
17
18
# File 'app/models/ofx_import.rb', line 12

def run
  read_and_parse_file || (return false)
   || (return false)
  @cash =  unless cash
  @bank_statement = build_bank_statement_with_items
  save_bank_statement
end