sunnyside 0.0.5 → 0.0.7

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.
@@ -1,69 +0,0 @@
1
- # Not implemented yet
2
-
3
- module Sunnyside
4
- def self.ics_file
5
- Dir['data/icseop/*.csv'].each { |file| ICS.new(file).process }
6
- end
7
-
8
- class ICS
9
- attr_reader :rows
10
-
11
- def initialize(file)
12
- p "processing #{file}..."
13
- @rows = CSV.read(file)
14
- end
15
-
16
- def checks
17
- rows.map { |row| row[0] }.uniq
18
- end
19
-
20
- def invoices(check)
21
- rows.select { |row| row[0] == check }.map { |row| row[1] }.uniq.map { |inv| Invoice[inv] }
22
- end
23
-
24
- def paid(inv, check)
25
- rows.select { |row| row[1].to_i == inv.get(:invoice_number) && row[0] == check }.map { |i| i[3].to_f }.inject { |x, y| x + y}.round(2)
26
- end
27
-
28
- def seed_claims
29
- checks.each do |check|
30
- payment_id = Payment.insert(check_number: check)
31
- invoices(check).each { |invoice|
32
- Claim.insert(
33
- :payment_id => payment_id,
34
- :invoice_id => invoice,
35
- :client_name => invoice.get(:client_name),
36
- :amount_charged => invoice.get(:amount),
37
- :amount_paid => paid(invoice, check),
38
- :provider => invoice.get(:provider) )
39
- }
40
- end
41
- end
42
-
43
- def process
44
- seed_claims
45
- rows.each { |row| ICSEop.new(row).write }
46
- end
47
- end
48
-
49
- class ICSEop < ICS
50
- attr_reader :check, :invoice, :charged, :paid, :dos, :service_code, :provider
51
-
52
- def initialize(row)
53
- @check, @invoice, @charged, @paid, @dos, @service_code = row
54
- @provider = Provider[13]
55
- end
56
-
57
- def write
58
- Service.insert(claim_id: claim_id, service_code: service_code, amount_charged: charged, amount_paid: paid, dos: date, check_number: check)
59
- end
60
-
61
- def date
62
- Date.strptime(dos, '%m/%d/%Y')
63
- end
64
-
65
- def claim_id
66
- Claim.where(invoice_number: invoice, check_number: check).get(:id)
67
- end
68
- end
69
- end