Class: Report::SalesProfit::SalesProfitCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
app/services/report/sales_profit/sales_profit_command.rb

Overview

Command pattern to encapsulate parameters necessary to run a presence report

Constant Summary collapse

SALES_OPTIONS =

Available sales options.

[%w[SO SO], %w[MO MO], %w[TO TO], %w[CI CI]].freeze
GRANULARITY_OPTIONS =

Available granularity options.

[['Product Line > Category > Sku', 1], ['Channel > Product Line > Customer', 2], ['State/Province > Channel > Product Line', 3], ['Channel > Product Line > Subcategory', 4]].freeze
ORDER_BY_OPTIONS =

Available order by options.

[['Profit', 1],
['Total Sales', 2],
['COGS', 3],
['Variable Costs', 4],
['Sales Taxes', 5],
['Sales Commissions', 6],
['Credit Card and Paypal Commissions', 7],
['Shipping', 8],
['Bad Credit', 9],
['Returns', 10]].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.company_optionsObject

Company options.

Returns:

  • (Object)


16
17
18
# File 'app/services/report/sales_profit/sales_profit_command.rb', line 16

def self.company_options
  Company.select_options_sales_companies
end

Instance Method Details

#executeObject

Run the report with the given filters and store the result.

Returns:

  • (Object)


40
41
42
43
44
# File 'app/services/report/sales_profit/sales_profit_command.rb', line 40

def execute
  return unless valid?

  @result = Report::SalesProfit::SalesProfit.result_report(attributes)
end

#success?Boolean

Whether the command validated and ran successfully.

Returns:

  • (Boolean)


48
49
50
# File 'app/services/report/sales_profit/sales_profit_command.rb', line 48

def success?
  valid? && @result.success?
end