Class: Report::ChannelRevenue::Command

Inherits:
BaseCommand show all
Defined in:
app/services/report/channel_revenue/command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::ARRAY_TYPE_NAMES

Instance Attribute Summary

Attributes inherited from BaseCommand

#results

Instance Method Summary collapse

Methods inherited from BaseCommand

#attributes, #email_parameters, #email_partial, #initialize

Constructor Details

This class inherits a constructor from Report::BaseCommand

Instance Method Details

#executeObject



22
23
24
25
26
27
28
29
30
31
# File 'app/services/report/channel_revenue/command.rb', line 22

def execute
  return unless valid?
  @results = Report::ChannelRevenue::Query.report(
                      period1_range: period1_range,
                      period2_range: period2_range,
                      primary_sales_rep_ids: primary_sales_rep_ids.presence,
                      invoice_types: invoice_types,
                      company_ids: company_ids,
                      consolidated_currency: consolidated_currency)
end

#invoice_types=(new_invoice_types) ⇒ Object



18
19
20
# File 'app/services/report/channel_revenue/command.rb', line 18

def invoice_types=(new_invoice_types)
  super (new_invoice_types || []).map(&:presence).compact.uniq
end

#period1_humanizedObject



41
42
43
# File 'app/services/report/channel_revenue/command.rb', line 41

def period1_humanized
  "From #{period1_range.first} until #{period1_range.last}"
end

#period1_rangeObject



33
34
35
# File 'app/services/report/channel_revenue/command.rb', line 33

def period1_range
  period1_gteq && period1_lteq && period1_gteq..period1_lteq
end

#period2_humanizedObject



45
46
47
# File 'app/services/report/channel_revenue/command.rb', line 45

def period2_humanized
  "From #{period2_range.first} until #{period2_range.last}"
end

#period2_rangeObject



37
38
39
# File 'app/services/report/channel_revenue/command.rb', line 37

def period2_range
  period2_gteq && period2_lteq && period2_gteq..period2_lteq
end

#success?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/services/report/channel_revenue/command.rb', line 49

def success?
  valid? && @results.present?
end