sunnyside 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ module Sunnyside
2
+ def self.advanced_opts
3
+ puts "1.) Add new provider"
4
+ puts "2.) Export A/R denials"
5
+
6
+ case gets.chomp
7
+ when '1'
8
+ print "Type in the provider name _EXACTLY_ how it appears on the SanData archive report files (e.g. Guildnet is always GUILDNET): "
9
+ provider = gets.chomp
10
+ print "Now type in the abbreviation (batch initials - e.g. MetroPlus Health is MPH): "
11
+ abbrev = gets.chomp
12
+ print "Now type in the CREDIT account that is used in FUND EZ: "
13
+ credit = gets.chomp
14
+ print "Now type in the DEBIT account that is used in FUND EZ: "
15
+ debit = gets.chomp
16
+ print "And finally, type in the FUND number that is used in FUND EZ: "
17
+ fund = gets.chomp
18
+ puts "---------------------------------------------------"
19
+ puts "--------Please review the below information--------"
20
+ puts ""
21
+ puts "Name: #{provider}, Credit Account: #{credit}, Debit Account: #{debit}, Fund: #{fund}, Abbreviation: #{abbrev}"
22
+ puts ""
23
+ puts "---------------------------------------------------"
24
+ print "Is this correct? (Y for yes, N for No): "
25
+ raise 'You have an empty field! Start over!' if [provider, credit, debit, fund, abbrev].any? { |elem| elem.empty? }
26
+ if gets.chomp.upcase == 'Y'
27
+ provider = Provider.insert(name: provider, credit_account: credit, debit_account: debit, fund: fund, abbreviation: abbrev)
28
+ puts "#{Provider[provider].name} added."
29
+ else
30
+ Sunnyside.advanced_opts
31
+ end
32
+ else
33
+ exit
34
+ end
35
+ end
36
+
37
+ def self.rails_server
38
+ puts "Open your web browser and type in this in the address bar (and then press enter): http://localhost:3000/providers"
39
+ puts "Please wait..."
40
+ Dir.chdir("#{DRIVE}/Program Files/Mozilla Firefox")
41
+
42
+ %x(start /max http://localhost:3000/providers)
43
+
44
+ puts "Web browser launched. Now launching server..."
45
+
46
+ Dir.chdir("#{DRIVE}/sunnyside-files/sunnyside-app")
47
+
48
+ %x(rails s)
49
+ end
50
+ end
@@ -53,9 +53,17 @@ module Sunnyside
53
53
  print "Enter in the check number: "
54
54
  check = gets.chomp
55
55
  invoices = invoice_selection
56
- manual = ManualPayment.new(invoices, post_date, prov, check)
57
- manual.seed_claims_and_services
58
- manual.create_csv
56
+ if invoices_exist?(invoices)
57
+ manual = ManualPayment.new(invoices, post_date, prov, check)
58
+ manual.seed_claims_and_services
59
+ manual.create_csv
60
+ else
61
+ manual_invoices
62
+ end
63
+ end
64
+
65
+ def invoices_exist?(invoices)
66
+ invoices.map { |invoice| invoice.gsub(/-d/, '') }.all? { |invoice| !Invoice[invoice].nil? }
59
67
  end
60
68
  end
61
69
 
@@ -87,7 +95,7 @@ module Sunnyside
87
95
  def collate
88
96
  puts "Total Amount Paid for this check is: #{total}\nProcessing..."
89
97
  populated_data.each do |clm|
90
- if not_paid_fully?(clm)
98
+ if !not_fully_paid?(clm)
91
99
  self.receivable_csv(clm, payment, post_date)
92
100
  else
93
101
  print "#{clm.invoice_id} was not added to the spreadsheet because the invoice was already fully paid for.\n"
@@ -105,13 +113,13 @@ module Sunnyside
105
113
  end
106
114
 
107
115
  def denied_services
108
- Service.where(payment_id: payment.id).exclude(denial_reason: nil).count
116
+ Service.where(payment_id: payment.id).exclude(denial_reas on: nil).count
109
117
  end
110
118
  end
111
119
 
112
120
  class ManualPayment
113
121
  include Sunnyside
114
- attr_reader :denied_invoices, :paid_invoices, :post_date, :provider, :check, :payment_id
122
+ attr_reader :denied_invoices, :paid_invoices, :post_date, :provider, :check, :payment_id, :total
115
123
 
116
124
  def initialize(invoices, post_date, prov, check)
117
125
  @denied_invoices = invoices.select { |inv| inv.include?('-d') }.map { |inv| Invoice[inv.gsub(/-d/, '')] }
@@ -120,6 +128,7 @@ module Sunnyside
120
128
  @provider = prov
121
129
  @check = check
122
130
  @payment_id = Payment.insert(check_number: check, post_date: post_date, provider_id: prov.id)
131
+ @total = 0.0
123
132
  end
124
133
 
125
134
  def seed_claims_and_services
@@ -130,8 +139,17 @@ module Sunnyside
130
139
  edit_services if denied_invoices.length > 0
131
140
  end
132
141
 
142
+ def not_fully_paid?(clm)
143
+ Claim.where(invoice_id: clm.invoice_id).sum(:paid).round(2) < clm.paid
144
+ end
145
+
133
146
  def create_csv
134
- claims.each { |clm| self.receivable_csv(clm, Payment[payment_id], post_date) if clm.paid > 0.0 }
147
+ claims.each { |clm|
148
+ if clm.paid > 0.0 && !not_fully_paid?(clm)
149
+ puts "-----------------------Total so far: #{total += clm.paid}"
150
+ self.receivable_csv(clm, Payment[payment_id], post_date)
151
+ end
152
+ }
135
153
  end
136
154
 
137
155
  def claims
data/lib/sunnyside/ftp.rb CHANGED
@@ -3,46 +3,23 @@ require 'rubygems'
3
3
 
4
4
  module Sunnyside
5
5
  def self.access_ftp
6
- puts "1.) GUILDNET"
7
- puts "2.) ELDERSERVE"
8
- puts "3.) CPHL"
9
- print "Select option: "
10
- case gets.chomp
11
- when '1'
12
- print 'Username for Guildnet? '
13
- username = gets.chomp
14
- print 'Password for Guildnet? '
15
- pass = gets.chomp
16
- access = SunnyFTP.new(username, pass, 'GUILDNET')
17
- when '2'
18
- print 'Username for ELDERSERVE? '
19
- username = gets.chomp
20
- print 'Password for ELDERSERVE? '
21
- pass = gets.chomp
22
- access = SunnyFTP.new(username, pass, 'ELDERSERVE')
23
- when '3'
24
- print 'Username for CPHL? '
25
- username = gets.chomp
26
- print 'Password for CPHL? '
27
- pass = gets.chomp
28
- access = SunnyFTP.new(username, pass, 'CPHL')
29
- else
30
- exit
6
+ CSV.foreach("#{DRIVE}/sunnyside-files/ftp/login.csv") do |row|
7
+ access = SunnyFTP.new(username: row[1], password: row[2], provider: row[0])
8
+ access.log_on
9
+ puts "Logged into #{access.name}..."
10
+ access.download_files
11
+ access.upload_files
31
12
  end
32
- access.log_on
33
- puts "Logged into #{access.name}..."
34
- access.download_files
35
- access.upload_files
36
13
  end
37
14
 
38
15
  class SunnyFTP
39
16
  attr_reader :ftp, :username, :password, :name, :directory
40
17
 
41
- def initialize(username, password, name)
18
+ def initialize(login = {})
42
19
  @ftp = Net::FTP.new('depot.per-se.com')
43
- @username = username
44
- @password = password
45
- @name = name
20
+ @username = login[:username]
21
+ @password = login[:password]
22
+ @name = login[:provider]
46
23
  end
47
24
 
48
25
  def log_on
@@ -93,12 +70,18 @@ module Sunnyside
93
70
  provider_folder.include?(file)
94
71
  end
95
72
 
73
+ def timestamp(file)
74
+ ftp.mtime(file).strftime('%Y-%m-%d')
75
+ end
76
+
96
77
  def download_files
97
78
  download_folder.each do |file|
98
79
  if !provider_folder.include?(file)
99
- puts "Downloading #{file}..."
100
- ftp.getbinaryfile(file, "#{DRIVE}/sunnyside-files/ftp/835/#{name}/#{file}") if File.basename(file).include?('835')
101
- puts "#{file} placed."
80
+ if file.include?('835')
81
+ puts "Downloading #{file}..."
82
+ ftp.getbinaryfile(file, "#{DRIVE}/sunnyside-files/ftp/835/#{name}/#{timestamp(file)}-#{file}")
83
+ puts "#{file} placed, dated: #{timestamp(file)}."
84
+ end
102
85
  end
103
86
  end
104
87
  ftp.close
@@ -2,20 +2,26 @@ module Sunnyside
2
2
  def self.edi_parser
3
3
  print "checking for new files...\n"
4
4
  Dir["#{DRIVE}/sunnyside-files/835/*.txt"].each do |file|
5
- print "processing #{file}...\n"
6
- file_data = File.open(file)
7
- data = file_data.read
8
- # Detect to see if the EDI file already has new lines inserted. If so, the newlines are removed before the file gets processed.
5
+
6
+ if Filelib.where(filename: file).count > 0
7
+ puts "This file has been processed already. File removed."
8
+ File.delete(file)
9
+ else
10
+ print "processing #{file}...\n"
11
+ file_data = File.open(file)
12
+ data = file_data.read
13
+ # Detect to see if the EDI file already has new lines inserted. If so, the newlines are removed before the file gets processed.
9
14
 
10
- data.gsub!(/\n/, '')
15
+ data.gsub!(/\n/, '')
11
16
 
12
- data = data.split(/~CLP\*/)
17
+ data = data.split(/~CLP\*/)
13
18
 
14
- edi_file = EdiReader.new(data)
15
- edi_file.parse_claims
16
- Filelib.insert(filename: file, purpose: '835')
17
- file_data.close
18
- FileUtils.mv(file, "#{DRIVE}/sunnyside-files/835/archive/#{File.basename(file)}")
19
+ edi_file = EdiReader.new(data)
20
+ edi_file.parse_claims
21
+ Filelib.insert(filename: file, purpose: '835')
22
+ file_data.close
23
+ FileUtils.mv(file, "#{DRIVE}/sunnyside-files/835/archive/#{File.basename(file)}")
24
+ end
19
25
  end
20
26
  end
21
27
 
@@ -30,8 +36,6 @@ module Sunnyside
30
36
  data.select { |clm| clm =~ /^\d+/ }.map { |clm| clm.split(/~(?=SVC)/) }
31
37
  end
32
38
 
33
-
34
-
35
39
  def check_number
36
40
  check = data[0][/(?<=~TRN\*\d\*)\w+/]
37
41
  return check.include?('E') ? check[/\d+$/] : check
@@ -11,6 +11,8 @@ module Sunnyside
11
11
  puts " 7.) EXPIRING AUTHORIZATION REPORT"
12
12
  puts " 9.) MCO - MLTC HOURS UPDATE"
13
13
  puts "10.) CUSTOM QUERY"
14
+ puts "11.) ADD A NEW PROVIDER"
15
+ puts "12.) VIEW DATABASE ON WEB BROWSER"
14
16
  print "select option: "
15
17
  case gets.chomp
16
18
  when '1'
@@ -34,6 +36,10 @@ module Sunnyside
34
36
  Sunnyside.run_mco_mltc
35
37
  when '10'
36
38
  Sunnyside.query
39
+ when '11'
40
+ Sunnyside.advanced_opts
41
+ when '12'
42
+ Sunnyside.rails_server
37
43
  else
38
44
  exit
39
45
  end
@@ -2,6 +2,24 @@ module Sunnyside
2
2
 
3
3
  class << self
4
4
 
5
+ def create_ftp_login_data
6
+ CSV.open("#{DRIVE}/sunnyside-files/ftp/login.csv", 'a+') do |row|
7
+ print "How many providers do you want to enter? "
8
+ gets.chomp.to_i.times do
9
+ print 'Enter in the name of the provider (please omit the use of special characters - make it a single word, if possible): '
10
+ provider = gets.chomp.upcase
11
+ puts "Enter in the username and the password for #{provider}, each seperated by a single space."
12
+ username, pass = gets.chomp.split
13
+
14
+ row << [provider, username, pass]
15
+
16
+ if !Dir.exist?("#{DRIVE}/sunnyside-files/ftp/#{provider}")
17
+ ["#{provider}" ,"#{provider}/835", "#{provider}/837"].each { |prov| Dir.mkdir("#{DRIVE}/sunnyside-files/ftp/#{prov}/") }
18
+ end
19
+ end
20
+ end
21
+ end
22
+
5
23
  def create_folders
6
24
  folders = ['db', '835', '837', 'summary', 'cash_receipts', 'new-ledger', 'private', 'private/archive',
7
25
  'summary/archive', '837/archive', '835/archive', 'ftp', 'ftp/837', 'ftp/837/GUILDNET', 'ftp/837/CPHL', 'ftp/837/ELDERSERVE',
@@ -12,27 +12,7 @@ module Sunnyside
12
12
  @file = file
13
13
  @selected = []
14
14
  end
15
-
16
- def tabickman
17
- selected_pages('TABICKMAN')
18
- end
19
-
20
- def jibaja
21
- selected_pages('JIBAJA')
22
- end
23
-
24
- def community
25
- selected_pages('SUNNYSIDE COMMUNITY')
26
- end
27
-
28
- def jensen
29
- selected_pages('JENSEN')
30
- end
31
-
32
- def barrow
33
- selected_pages('BARROW')
34
- end
35
-
15
+
36
16
  def selected_pages(name)
37
17
  PDF::Reader.new(file).pages.select { |page| page.text.include?(name) && page.text.include?('Client Copy') }.map { |page| page.number }
38
18
  end
@@ -1,3 +1,3 @@
1
1
  module Sunnyside
2
- VERSION = "0.0.7" # stupid, no-good, lousy rubygems not letting me yank my bad install. grumble grumble...
2
+ VERSION = "0.0.8" # stupid, no-good, lousy rubygems not letting me yank my bad install. grumble grumble...
3
3
  end
data/lib/sunnyside.rb CHANGED
@@ -16,13 +16,15 @@ require 'sunnyside/ftp'
16
16
  require 'sunnyside/menu'
17
17
  require 'sunnyside/expiring_auth'
18
18
  require 'sunnyside/models/db_setup'
19
+ require 'sunnyside/advanced'
19
20
 
20
21
  module Sunnyside
21
22
  DRIVE = ENV["HOMEDRIVE"]
22
23
 
23
24
  Sunnyside.create_folders if !Dir.exist?("#{DRIVE}/sunnyside-files")
24
-
25
- DB = Sequel.connect("sqlite:/#{DRIVE}/sunnyside-files/db/sunnyside.db")
25
+ Sunnyside.create_ftp_login_data if !File.exist?("#{DRIVE}/sunnyside-files/ftp/login.csv")
26
+ Dir.chdir("R:/Departments/AR Department")
27
+ DB = Sequel.connect("sqlite://sunnyside.db")
26
28
 
27
29
  if DB.tables.empty?
28
30
  Sunnyside.create_tables
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunnyside
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-28 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -115,6 +115,7 @@ executables:
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - lib/sunnyside/advanced.rb
118
119
  - lib/sunnyside/cash_receipts/cash_receipt.rb
119
120
  - lib/sunnyside/expiring_auth.rb
120
121
  - lib/sunnyside/ftp.rb