Class: Report::CustomerPerformance::CustomerPerformanceResult
- Inherits:
-
Object
- Object
- Report::CustomerPerformance::CustomerPerformanceResult
- Includes:
- ActiveModel::API, ActiveModel::Attributes, ActiveModel::Validations::Callbacks, StripAttributes
- Defined in:
- app/services/report/customer_performance/customer_performance_result.rb
Overview
Service object: customer performance result.
Class Method Summary collapse
-
.build(grouping_method, group_identifier, periods) ⇒ Object
Build a new instance and initialize periods, pass an object that respond to the required method.
Instance Method Summary collapse
-
#period1 ⇒ Object
Period1.
-
#period2 ⇒ Object
Period2.
Class Method Details
.build(grouping_method, group_identifier, periods) ⇒ Object
Build a new instance and initialize periods, pass an object that respond
to the required method. group_identifier, grouping, etc. such as the one
returned from a query
Periods is an array of Ranges to initialize
44 45 46 47 48 49 50 51 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 44 def self.build(grouping_method, group_identifier, periods) cpr = new cpr.group_identifier = group_identifier cpr.grouping = grouping_method.to_sym # Initialize each period cpr.periods = periods.map { |p| Report::CustomerPerformance::PeriodData.new(period: p, sales_revenue: BigDecimal('0.0'), sales_count: 0) } cpr end |
Instance Method Details
#period1 ⇒ Object
Period1.
27 28 29 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 27 def period1 periods[0] end |
#period2 ⇒ Object
Period2.
33 34 35 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 33 def period2 periods[1] end |