class Sunnyside::AuthReport

Attributes

auth[R]
client_auth[R]
invoices[R]
visits[R]

Public Class Methods

new(client, auth) click to toggle source
# File lib/sunnyside/expiring_auth.rb, line 79
def initialize(client, auth)
  @auth   = auth
  @client_auth            = client
  @visits                 = Visit.where(member_id: client.get(:client_number)).all.select { |visit| auth.end_date < visit.dos }
end

Public Instance Methods

create_csv() click to toggle source
# File lib/sunnyside/expiring_auth.rb, line 85
def create_csv
  if expired?
    CSV.open('auth_report', 'a+') { |row| row << ['EXPIRED', auth.client, auth.provider, auth.start_date, auth.end_date, auth.auth] }
    if visits.count > 0
      # puts visits
      visits.each { |visit| CSV.open('auth_report', 'a+') { |row| row << [''       , visit.dos, visit.service_code, visit.units, visit.amount] } }
    end
  else
    CSV.open('auth_report', 'a+') { |row| row << ['PENDING', auth.client, auth.provider, auth.start_date, auth.end_date, auth.auth] }
  end
end
expired?() click to toggle source
# File lib/sunnyside/expiring_auth.rb, line 97
def expired?
  auth.end_date < Date.today
end