Class: Report::ChannelRevenue::Command
Overview
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
normalize
Instance Method Details
#execute ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/services/report/channel_revenue/command.rb', line 23
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
19
20
21
|
# File 'app/services/report/channel_revenue/command.rb', line 19
def invoice_types=(new_invoice_types)
super((new_invoice_types || []).filter_map(&:presence).uniq)
end
|
#period1_humanized ⇒ Object
44
45
46
|
# File 'app/services/report/channel_revenue/command.rb', line 44
def period1_humanized
"From #{period1_range.first} until #{period1_range.last}"
end
|
#period1_range ⇒ Object
36
37
38
|
# File 'app/services/report/channel_revenue/command.rb', line 36
def period1_range
(period1_gteq && period1_lteq && period1_gteq)..period1_lteq
end
|
#period2_humanized ⇒ Object
48
49
50
|
# File 'app/services/report/channel_revenue/command.rb', line 48
def period2_humanized
"From #{period2_range.first} until #{period2_range.last}"
end
|
#period2_range ⇒ Object
40
41
42
|
# File 'app/services/report/channel_revenue/command.rb', line 40
def period2_range
(period2_gteq && period2_lteq && period2_gteq)..period2_lteq
end
|
#success? ⇒ Boolean
52
53
54
|
# File 'app/services/report/channel_revenue/command.rb', line 52
def success?
valid? && @results.present?
end
|