Class: Sunnyside::ParseInvoice

Inherits:
Object
  • Object
show all
Defined in:
lib/sunnyside/ledger/auth_report.rb

Direct Known Subclasses

ClientData, InvoiceDetail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ ParseInvoice

Returns a new instance of ParseInvoice.



20
21
22
23
# File 'lib/sunnyside/ledger/auth_report.rb', line 20

def initialize(entry)
  @client_line = entry.split(/\n/).select { |line| line =~ /\s+001\s+/ }.join
  @visits      = entry.split(/\n/).select { |line| line =~ /^\d{6}/    }
end

Instance Attribute Details

#client_lineObject (readonly)

Returns the value of attribute client_line.



18
19
20
# File 'lib/sunnyside/ledger/auth_report.rb', line 18

def client_line
  @client_line
end

#visitsObject (readonly)

Returns the value of attribute visits.



18
19
20
# File 'lib/sunnyside/ledger/auth_report.rb', line 18

def visits
  @visits
end

Instance Method Details

#client_dataObject



25
26
27
# File 'lib/sunnyside/ledger/auth_report.rb', line 25

def client_data
  client_line.slice(9..28) + client_line.slice(54..120)
end

#invoice_linesObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sunnyside/ledger/auth_report.rb', line 29

def invoice_lines
  visits.map { |inv| 
      InvoiceDetail.new(
        client_data, 
        { :invoice  => inv[0..5], 
          :svc_code => inv[18..22], 
          :modifier => inv[25..30], 
          :dos      => inv[57..66], 
          :units    => inv[69..75], 
          :amount   => inv[79..88] }
      )
  }
end

#processObject

removes the client name from the line



45
46
47
# File 'lib/sunnyside/ledger/auth_report.rb', line 45

def process
  invoice_lines.each { |inv| inv.to_db }
end