Class: Report::GrossSalesReport::GrossSalesReportCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::GrossSalesReport::GrossSalesReportCommand
- Defined in:
- app/services/report/gross_sales_report/gross_sales_report_command.rb
Overview
Command pattern to encapsulate parameters necessary to run a presence report
Constant Summary collapse
- GROUPING_OPTIONS =
attribute :year, Integer, default: :default_year
[%w[year year], %w[quarter quarter], %w[month month], %w[week week]].freeze
Class Method Summary collapse
-
.company_options ⇒ Object
Company options.
-
.default_company_ids ⇒ Object
Default company ids.
Instance Method Summary collapse
-
#execute ⇒ Object
Run the report with the given filters and store the result.
-
#success? ⇒ Boolean
Whether the command validated and ran successfully.
Class Method Details
.company_options ⇒ Object
Company options.
15 16 17 |
# File 'app/services/report/gross_sales_report/gross_sales_report_command.rb', line 15 def self. @company_options ||= Company.sales_companies.pluck(:name, :country_iso3) end |
.default_company_ids ⇒ Object
Default company ids.
47 48 49 |
# File 'app/services/report/gross_sales_report/gross_sales_report_command.rb', line 47 def self.default_company_ids @default_company_ids ||= Company.sales_companies.ids end |
Instance Method Details
#execute ⇒ Object
Run the report with the given filters and store the result.
25 26 27 28 29 |
# File 'app/services/report/gross_sales_report/gross_sales_report_command.rb', line 25 def execute return unless valid? @result = Report::GrossSalesReport::GrossSalesReport.total_report(attributes) end |
#success? ⇒ Boolean
Whether the command validated and ran successfully.
33 34 35 |
# File 'app/services/report/gross_sales_report/gross_sales_report_command.rb', line 33 def success? valid? && @result.success? end |