Fork me on GitHub

Query report demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  def index
    reporter(Invoice.scoped, template_class: PdfReportTemplate) do
      filter :title, type: :text, default: 'Invoice'
      filter :invoiced_on, type: :date
      filter :paid, type: :boolean

      column(:title) { |invoice| link_to invoice.title, invoice }
      column :invoiced_on, sortable: true, pdf: {width: 65}
      column :total_paid
      column :total_charged
      column :paid
      column(:received_by_id, sortable: true) { |invoice| invoice.received_by.try(:name) }

      chart(:pie, 'Unpaid VS Paid') do |chart|
        chart.sum_with 'Un paid' => :total_charged, 'Paid' => :total_paid
      end
    end
  end

Title Invoiced on Total paid Total charged Paid Received by
Invoice #1 2013-08-15 115.0 115.0 true Sharmin Sultana
Invoice #2 2013-08-30 196.0 138.0 true A.K.M. Ashrafuzzaman
Invoice #3 2013-08-23 120.0 192.0 false A.K.M. Ashrafuzzaman
Invoice #4 2013-08-11 197.0 197.0 true A.K.M. Zahiduzzaman
Invoice #5 2013-08-17 194.0 197.0 false A.K.M. Ashrafuzzaman
Invoice #6 2013-08-18 128.0 162.0 false A.K.M. Zahiduzzaman
Invoice #7 2013-09-04 116.0 192.0 false Sharmin Sultana
Invoice #8 2013-08-23 176.0 193.0 false Sharmin Sultana
Invoice #9 2013-08-24 195.0 176.0 true A.K.M. Zahiduzzaman
Invoice #10 2013-08-21 120.0 185.0 false A.K.M. Ashrafuzzaman
Invoice #11 2013-08-15 115.0 157.0 false Sharmin Sultana
Invoice #12 2013-08-13 117.0 168.0 false A.K.M. Ashrafuzzaman
Invoice #13 2013-08-10 142.0 179.0 false A.K.M. Ashrafuzzaman
Invoice #14 2013-08-11 160.0 138.0 true Sharmin Sultana
Invoice #15 2013-08-20 192.0 122.0 true A.K.M. Ashrafuzzaman
Invoice #16 2013-08-25 100.0 155.0 false Sharmin Sultana
Invoice #17 2013-08-07 168.0 198.0 false Sharmin Sultana
Invoice #18 2013-08-31 173.0 129.0 true Sharmin Sultana
Invoice #19 2013-08-17 125.0 186.0 false A.K.M. Zahiduzzaman
Invoice #20 2013-08-18 161.0 103.0 true A.K.M. Ashrafuzzaman
Invoice #21 2013-09-04 147.0 146.0 true A.K.M. Ashrafuzzaman
Invoice #22 2013-08-30 191.0 181.0 true Sharmin Sultana
Invoice #23 2013-08-30 187.0 176.0 true A.K.M. Ashrafuzzaman
Invoice #24 2013-08-13 131.0 165.0 false A.K.M. Ashrafuzzaman
Invoice #25 2013-09-03 197.0 105.0 true Sharmin Sultana