Class: Bill

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/bill.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_name(name) ⇒ Object


18
19
20
# File 'app/models/bill.rb', line 18

def from_name name
  find_or_create_by_name(name)
end

Instance Method Details

#clauses_fileObject


43
44
45
46
47
48
49
50
51
52
# File 'app/models/bill.rb', line 43

def clauses_file
  files = mif_files.select{|x| x.name[/clauses\./i]}
  if files.size == 1
    files.first
  elsif files.size > 1
    raise "can't find single matching clauses file"
  else
    nil
  end
end

#find_note_for_clause_number(clause_number, search_range = false) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/bill.rb', line 23

def find_note_for_clause_number clause_number, search_range=false
  note = note_by_clauses.find_by_clause_number(clause_number)
  unless note
    note = note_range_by_clauses.find_by_clause_number(clause_number)
  end
  if !note && search_range
    ranges = note_range_by_clauses
    ranges.each do |range|
      if range.contains_clause?(clause_number)
        note = range
      end
    end
  end
  note
end

#find_note_for_schedule_number(schedule_number) ⇒ Object


39
40
41
# File 'app/models/bill.rb', line 39

def find_note_for_schedule_number schedule_number
  note_by_schedules.find_by_schedule_number(schedule_number)
end

#has_effects?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'app/models/bill.rb', line 58

def has_effects?
  !effects.empty?
end

#has_explanatory_notes?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'app/models/bill.rb', line 54

def has_explanatory_notes?
  !note_by_clauses.empty? || !note_by_schedules.empty?
end