Class: Sunnyside::Reporter

Inherits:
Object
  • Object
show all
Includes:
Sunnyside
Defined in:
lib/sunnyside/reports/pdf_report.rb

Direct Known Subclasses

ClaimEOP

Constant Summary

Constants included from Sunnyside

DB, DRIVE, PRIVATE_CLIENTS, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sunnyside

access_ftp, add_denial_data, add_provider_to_ftp, add_providers, advanced_opts, cash_receipt, check_prompt, create_folders, create_tables, determine_browser, edi_parser, expiring_auth, ledger_file, parse_pdf, #payable_csv, private_clients, process_private, query, rails_server, #receivable_csv, run_mco_mltc, run_report

Constructor Details

#initialize(payment, post_date, provider) ⇒ Reporter

Returns a new instance of Reporter.



19
20
21
22
23
24
25
26
# File 'lib/sunnyside/reports/pdf_report.rb', line 19

def initialize(payment, , provider)
  @provider  = provider
  @payment   = payment
  @post_date = 
  @claims    = Claim.where(payment_id: payment.id)
  @pdf       = Prawn::Document.new(:page_layout => :landscape) # generate("#{DRIVE}/sunnyside-files/pdf-reports/#{provider.name}-#{payment.check_number}.PDF", :page_layout => :landscape)
  @total     = Money.new(payment.check_total * 100, 'USD').format
end

Instance Attribute Details

#claimsObject (readonly)

Returns the value of attribute claims.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def claims
  @claims
end

#paymentObject (readonly)

Returns the value of attribute payment.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def payment
  @payment
end

#pdfObject (readonly)

Returns the value of attribute pdf.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def pdf
  @pdf
end

#post_dateObject (readonly)

Returns the value of attribute post_date.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def 
  @post_date
end

#providerObject (readonly)

Returns the value of attribute provider.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def provider
  @provider
end

#totalObject (readonly)

Returns the value of attribute total.



17
18
19
# File 'lib/sunnyside/reports/pdf_report.rb', line 17

def total
  @total
end

Instance Method Details

#check_headerObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sunnyside/reports/pdf_report.rb', line 28

def check_header
  puts "creating report for #{provider.name} - Check Number: #{payment.check_number} - posted on: #{}"
  pdf.text "CLAIMS FOR #{provider.name} - CHECK NUMBER: #{payment.check_number} - CHECK TOTAL: #{total}"
  pdf.move_down 50

  pdf.text "Claims with payments."

  paid_claims do |clm|
    pdf.move_down 10
    claim = ClaimEOP.new(clm, , pdf, clm.paid, clm.billed)
    claim.create_block
  end

  if claims.where(status: '4').count > 0
    pdf.start_new_page
    pdf.text "Claims with denials."

    denied_claims do |clm|
      pdf.move_down 10
      claim = ClaimEOP.new(clm, , pdf, clm.paid, clm.billed)
      claim.create_block
    end
  end

  if claims.where(status: '22').count > 0
    pdf.start_new_page
    pdf.text "Claims with takebacks."

    takeback_claims do |clm|
      pdf.move_down 10
      claim = ClaimEOP.new(clm, , pdf, clm.paid, clm.billed)
      claim.create_block
    end
  end

  page_numbering

  pdf.render_file("#{DRIVE}/sunnyside-files/pdf-reports/#{provider.name.gsub(/[\.\/]/, '')}-#{payment.check_number}.PDF")
end

#denied_claimsObject



72
73
74
# File 'lib/sunnyside/reports/pdf_report.rb', line 72

def denied_claims
  claims.where(status: '4').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
end

#page_numberingObject



68
69
70
# File 'lib/sunnyside/reports/pdf_report.rb', line 68

def page_numbering
  pdf.number_pages('Page <page> of <total>', { :at => [pdf.bounds.right - 150, - 10], :width => 150, :align => :center, :start_count_at => 1 } )
end


76
77
78
# File 'lib/sunnyside/reports/pdf_report.rb', line 76

def paid_claims
  claims.where(status: '1').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
end

#takeback_claimsObject



80
81
82
# File 'lib/sunnyside/reports/pdf_report.rb', line 80

def takeback_claims
  claims.where(status: '22').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
end