Sha256: 5698a645c0b5ed514570aee267916ae9bd2b6a19dfb70fb750c1b2938a234ea2

Contents?: true

Size: 839 Bytes

Versions: 3

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

example :list_events, 'Basic list events' do |t|
  Thinreports::Report.generate filename: t.output_filename do |report|
    report.use_layout t.layout_filename

    report.list.header title: 'Prices'

    report.list do |list|
      price_for = { page: 0, all: 0 }

      list.on_page_finalize do
        price_for[:all] += price_for[:page]
        price_for[:page] = 0
      end

      list.on_page_footer_insert do |footer|
        footer.item(:price).value(price_for[:page])
      end

      list.on_footer_insert do |footer|
        footer.item(:price).value(price_for[:all])
      end

      [100, 200, 250, 50, 100, 20, 30, 50, 100, 100].each do |price|
        list.add_row price: price
        # Calculate sum price for each page of list
        price_for[:page] += price
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.10.2 examples/list_events/list_events.rb
thinreports-0.10.1 examples/list_events/list_events.rb
thinreports-0.10.0 examples/list_events/list_events.rb