Class: InstanceAccountant::JournalEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/instance_accountant/journal_entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = { }) ⇒ JournalEntry

Returns a new instance of JournalEntry.



6
7
8
9
10
# File 'lib/instance_accountant/journal_entry.rb', line 6

def initialize options = { }
  @options = options

  @subledger = options[:subledger] || Subledger.new(@options.dup)
end

Instance Method Details

#hash_for(hour, now) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/instance_accountant/journal_entry.rb', line 12

def hash_for hour, now
  hour_string = hour.hour_string

  lines = cost_lines hour_string

  lines += price_lines(hour_string) if include_price_lines?

  hash = {
    effective_at: now,
    description:  description(hour_string),
    lines:        lines
  }

  hash.merge!(reference: @options[:reference]) if @options[:reference]

  hash
end