Class: Sunnyside::CashReceipt

Inherits:
Object
  • Object
show all
Defined in:
lib/sunnyside/cash_receipts/cash_receipt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_of_entry) ⇒ CashReceipt

Returns a new instance of CashReceipt.



23
24
25
26
27
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 23

def initialize(type_of_entry)
  print "Enter in post date (YYYY-MM-DD): "
  @post_date        = Date.parse(gets.chomp)
  @type_of_entry    = type_of_entry
end

Instance Attribute Details

#post_dateObject (readonly)

Returns the value of attribute post_date.



21
22
23
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 21

def 
  @post_date
end

#type_of_entryObject (readonly)

Returns the value of attribute type_of_entry.



21
22
23
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 21

def type_of_entry
  @type_of_entry
end

Instance Method Details

#collateObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 29

def collate
  case type_of_entry
  when :electronic
    Sunnyside.check_prompt { |payment_id| EdiPayment.new(payment_id, ).collate }
  when :manual
    manual_invoices
  else
    exit
  end
end

#invoice_selectionObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 40

def invoice_selection
  puts "Enter in the invoices, each separated by a space. If any invoice has a denial, 'flag' it by typing '-d' after the invoice number.\n"
  invoices = gets.chomp.split
  print "You have typed out #{invoices.length} number of invoices. Do you wish to add more to the same check? (Y or N): "
  if gets.chomp.upcase == 'Y'
    more_invoices = gets.chomp.split
    return (more_invoices + invoices).uniq
  else
    return invoices.uniq
  end
end

#invoices_exist?(invoices) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 70

def invoices_exist?(invoices)
  invoices.map { |invoice| invoice.gsub(/-d/, '') }.all? { |invoice| !Invoice[invoice].nil? }
end

#manual_invoicesObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 52

def manual_invoices
  print "# of checks to enter for the post date of #{}? "
  num = gets.chomp.to_i
  num.times do 
    prov     = provider
    print "Enter in the check number: "
    check    = gets.chomp
    invoices = invoice_selection
    if invoices_exist?(invoices)
      manual   = ManualPayment.new(invoices, , prov, check) 
      manual.seed_claims_and_services
      manual.create_csv
    else
      manual_invoices
    end
  end
end

#providerObject



74
75
76
77
78
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 74

def provider
  Provider.all.each { |prov| puts "#{prov.id}: #{prov.name}"}
  print "Type in the Provider ID: "
  return Provider[gets.chomp] || ''
end