Class: YDIM::Reconciler::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/ydim/reconciler.rb

Overview

One bank entry and the invoices it was matched to.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, invoices, state, reason = nil) ⇒ Match

Returns a new instance of Match.



48
49
50
51
52
53
54
# File 'lib/ydim/reconciler.rb', line 48

def initialize(entry, invoices, state, reason = nil)
  @entry = entry
  @invoices = invoices
  @state = state
  @reason = reason
  @applied = false
end

Instance Attribute Details

#appliedObject

Returns the value of attribute applied.



47
48
49
# File 'lib/ydim/reconciler.rb', line 47

def applied
  @applied
end

#entryObject (readonly)

Returns the value of attribute entry.



46
47
48
# File 'lib/ydim/reconciler.rb', line 46

def entry
  @entry
end

#invoicesObject (readonly)

Returns the value of attribute invoices.



46
47
48
# File 'lib/ydim/reconciler.rb', line 46

def invoices
  @invoices
end

#reasonObject

Returns the value of attribute reason.



47
48
49
# File 'lib/ydim/reconciler.rb', line 47

def reason
  @reason
end

#stateObject (readonly)

Returns the value of attribute state.



46
47
48
# File 'lib/ydim/reconciler.rb', line 46

def state
  @state
end

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/ydim/reconciler.rb', line 55

def applicable?
  APPLICABLE.include?(@state)
end

#applied?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/ydim/reconciler.rb', line 62

def applied?
  @applied
end

#invoice_idsObject



65
66
67
# File 'lib/ydim/reconciler.rb', line 65

def invoice_ids
  @invoices.collect { |info| info.unique_id }
end

#review?Boolean

Matched, but not well enough to book automatically.

Returns:

  • (Boolean)


59
60
61
# File 'lib/ydim/reconciler.rb', line 59

def review?
  !applicable? && !@invoices.empty?
end