Class: Sunnyside::AuthReport
- Inherits:
-
Object
- Object
- Sunnyside::AuthReport
- Defined in:
- lib/sunnyside/expiring_auth.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#client_auth ⇒ Object
readonly
Returns the value of attribute client_auth.
-
#invoices ⇒ Object
readonly
Returns the value of attribute invoices.
-
#visits ⇒ Object
readonly
Returns the value of attribute visits.
Instance Method Summary collapse
- #create_csv ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(client, auth) ⇒ AuthReport
constructor
A new instance of AuthReport.
Constructor Details
#initialize(client, auth) ⇒ AuthReport
Returns a new instance of AuthReport.
79 80 81 82 83 |
# File 'lib/sunnyside/expiring_auth.rb', line 79 def initialize(client, auth) @auth = auth @client_auth = client @visits = Visit.where(member_id: client.get(:client_number)).all.select { |visit| auth.end_date < visit.dos } end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
77 78 79 |
# File 'lib/sunnyside/expiring_auth.rb', line 77 def auth @auth end |
#client_auth ⇒ Object (readonly)
Returns the value of attribute client_auth.
77 78 79 |
# File 'lib/sunnyside/expiring_auth.rb', line 77 def client_auth @client_auth end |
#invoices ⇒ Object (readonly)
Returns the value of attribute invoices.
77 78 79 |
# File 'lib/sunnyside/expiring_auth.rb', line 77 def invoices @invoices end |
#visits ⇒ Object (readonly)
Returns the value of attribute visits.
77 78 79 |
# File 'lib/sunnyside/expiring_auth.rb', line 77 def visits @visits end |
Instance Method Details
#create_csv ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/sunnyside/expiring_auth.rb', line 85 def create_csv if expired? CSV.open('auth_report', 'a+') { |row| row << ['EXPIRED', auth.client, auth.provider, auth.start_date, auth.end_date, auth.auth] } if visits.count > 0 # puts visits visits.each { |visit| CSV.open('auth_report', 'a+') { |row| row << ['' , visit.dos, visit.service_code, visit.units, visit.amount] } } end else CSV.open('auth_report', 'a+') { |row| row << ['PENDING', auth.client, auth.provider, auth.start_date, auth.end_date, auth.auth] } end end |
#expired? ⇒ Boolean
97 98 99 |
# File 'lib/sunnyside/expiring_auth.rb', line 97 def expired? auth.end_date < Date.today end |