Class: YDIM::Reconciler::InvoiceRef

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

Overview

The bit of an invoice reconciliation cares about. Results travel back to the client over DRb, and a client should not have to load the whole server just to unmarshal them, so matches carry these rather than Invoice::Info. Built from anything answering the same readers.

Constant Summary collapse

KEYS =
[:unique_id, :total_brutto, :currency, :date, :debitor_name,
:payment_received, :deleted]

Instance Method Summary collapse

Constructor Details

#initialize(invoice) ⇒ InvoiceRef

Returns a new instance of InvoiceRef.



27
28
29
30
31
# File 'lib/ydim/reconciler.rb', line 27

def initialize(invoice)
  KEYS.each { |key|
    instance_variable_set("@#{key}", invoice.send(key))
  }
end

Instance Method Details

#payable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ydim/reconciler.rb', line 32

def payable?
  !@payment_received && !@deleted
end

#to_sObject



38
39
40
41
# File 'lib/ydim/reconciler.rb', line 38

def to_s
  sprintf('%s %s %.2f %s', @unique_id, @currency, @total_brutto.to_f,
    @debitor_name)
end

#total_centsObject



35
36
37
# File 'lib/ydim/reconciler.rb', line 35

def total_cents
  (@total_brutto.to_f * 100).round
end