Class: Sunnyside::CashReceipt
- Inherits:
-
Object
- Object
- Sunnyside::CashReceipt
- Defined in:
- lib/sunnyside/cash_receipts/cash_receipt.rb
Instance Attribute Summary collapse
-
#post_date ⇒ Object
readonly
Returns the value of attribute post_date.
-
#type_of_entry ⇒ Object
readonly
Returns the value of attribute type_of_entry.
Instance Method Summary collapse
- #collate ⇒ Object
-
#initialize(type_of_entry) ⇒ CashReceipt
constructor
A new instance of CashReceipt.
- #invoice_selection ⇒ Object
- #invoices_exist?(invoices) ⇒ Boolean
- #manual_invoices ⇒ Object
- #provider ⇒ Object
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_date ⇒ Object (readonly)
Returns the value of attribute post_date.
21 22 23 |
# File 'lib/sunnyside/cash_receipts/cash_receipt.rb', line 21 def post_date @post_date end |
#type_of_entry ⇒ Object (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
#collate ⇒ Object
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, post_date).collate } when :manual manual_invoices else exit end end |
#invoice_selection ⇒ Object
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
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_invoices ⇒ Object
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 #{post_date}? " 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, post_date, prov, check) manual.seed_claims_and_services manual.create_csv else manual_invoices end end end |