Sha256: cdd849fd8e84595f7ab6b78e7efeede5088fd38ef8ceb39380e02e5aaf6fdb24

Contents?: true

Size: 531 Bytes

Versions: 34

Compression:

Stored size: 531 Bytes

Contents

module Workarea
  module Admin
    module Reports
      class SalesByDiscountViewModel < ApplicationViewModel
        def results
          @results ||= model.results.map do |result|
            discount = discounts.detect { |p| p.id.to_s == result['_id'] }
            OpenStruct.new({ discount: discount }.merge(result))
          end
        end

        def discounts
          @discounts ||= Pricing::Discount.any_in(
            id: model.results.map { |r| r['_id'] }
          ).to_a
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.44 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.43 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.42 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.41 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.40 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.39 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.38 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.37 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.36 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.35 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.34 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.33 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.32 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.31 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.30 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.29 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.28 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.27 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb
workarea-admin-3.4.26 app/view_models/workarea/admin/reports/sales_by_discount_view_model.rb