summaryrefslogtreecommitdiff
path: root/engines/billing/app/controllers/billing_admin_controller.rb
blob: 7a1de30c72a51fb4c2f1c3d6697964ebc07f6bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class BillingAdminController < BillingBaseController
  before_filter :require_admin
  respond_to :html

  #not sure if this controller is still needed. Admin can easly acess
  #braintree's dashboard and check subscriptions. Don't know if everything
  #should be 'self contained' in web_app""
  def show

    br_atleast_90_days = Braintree::Subscription.search do |search|
      search.days_past_due >= 90
    end
    @past_due_atleast_90_days = braintree_resource_collection_to_array(br_atleast_90_days)

    br_all_past_due = Braintree::Subscription.search do |search|
      search.status.is Braintree::Subscription::Status::PastDue
      #cannot search by balance.
    end
    @all_past_due = braintree_resource_collection_to_array(br_all_past_due)

  end

  private

  def braintree_resource_collection_to_array(braintree_resource_collection)
    array = []
    braintree_resource_collection.each do |object|
      array << object
    end
    array
  end

end