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
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
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
35 36 37 38 39 40 41 42 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 35 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
23 24 25 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 23 def period1 periods[0] end |
#period2 ⇒ Object
27 28 29 |
# File 'app/services/report/customer_performance/customer_performance_result.rb', line 27 def period2 periods[1] end |