Class: Billing::Item

Inherits:
ApplicationRecord show all
Defined in:
app/models/billing/item.rb

Overview

Simple record that stores (dynamic) data required to generate billing BIF file it store request_id, project_cost_code, units, billing_product_code, billing_product_description, request_passed_date

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Class Method Details

.created_between(start_date, end_date) ⇒ Object


7
8
9
# File 'app/models/billing/item.rb', line 7

def self.created_between(start_date, end_date)
  where(created_at: start_date..end_date)
end

Instance Method Details

#to_s(fields) ⇒ Object

this method transfers billing_item to one BIF file entry (string)


12
13
14
15
16
17
18
19
20
21
# File 'app/models/billing/item.rb', line 12

def to_s(fields)
  check_product_code
  ''.tap do |result|
    fields.each do |field|
      result << field.value(self).public_send(field.alignment, field.length)
      result << ' ' * fields.spaces_to_next_field(field).to_i
    end
    result << "\n"
  end
end