Class: Report::ItemSale::ItemSaleCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::ItemSale::ItemSaleCommand
- Defined in:
- app/services/report/item_sale/item_sale_command.rb
Overview
Command pattern to encapsulate parameters necessary to run a presence report
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
19 20 21 22 |
# File 'app/services/report/item_sale/item_sale_command.rb', line 19 def execute return unless valid? @result = Report::ItemSale::ItemSale.total_report(attributes) end |
#success? ⇒ Boolean
37 38 39 |
# File 'app/services/report/item_sale/item_sale_command.rb', line 37 def success? valid? && @result.success? end |
#to_csv ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/report/item_sale/item_sale_command.rb', line 24 def to_csv return unless valid? @result = Report::ItemSale::ItemSale.total_report(attributes) return unless @result.data_table.present? attributes = @result.data_table.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.data_table.each do |r| csv << r end end end |