Class: Crm::Reports::ItemSaleController

Inherits:
CrmController
  • Object
show all
Includes:
Controllers::ReportCommandFlashable
Defined in:
app/controllers/crm/reports/item_sale_controller.rb

Constant Summary collapse

COMMAND_PARAM_KEYS =

Keys accepted for Report::ItemSale::ItemSaleCommand (must match attribute names).

%i[
  period1_gteq period1_lteq period2_gteq period2_lteq
  report_groupings product_lines customer_ids item_ids company_ids
  native_currency state_codes
].freeze

Instance Method Summary collapse

Instance Method Details

#showObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/crm/reports/item_sale_controller.rb', line 15

def show
  @report_command = ::Report::ItemSale::ItemSaleCommand.new(item_sale_command_params)
  @result = @report_command.execute

  return render partial: 'mini_view', layout: false if request.headers['Turbo-Frame'].present?

  flash_report_command_errors
  respond_to do |format|
    format.html do
      render partial: 'mini_view', layout: false if request.xhr?
    end
    format.turbo_stream
    format.csv { send_data @report_command.to_csv, filename: "item-sale-#{Date.current}.csv" }
  end
end