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