Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
More reporting methods for User class
Damian Legawiec8408d58b794f
diff --git a/core/app/models/concerns/spree/user_reporting.rb b/core/app/models/concerns/spree/user_reporting.rbindex ff36e8e6d8..f53019f914 100644--- a/core/app/models/concerns/spree/user_reporting.rb+++ b/core/app/models/concerns/spree/user_reporting.rb@@ -6,7 +6,7 @@ module Spreedef report_values_for(report_name, store)store ||= Store.default- completed_orders(store).pluck(:currency).uniq.each_with_object([]) do |currency, arr|+ completed_orders_for_store(store).pluck(:currency).uniq.each_with_object([]) do |currency, arr|arr << send("display_#{report_name}", store: store, currency: currency)endend@@ -31,16 +31,24 @@ module Spreecolumn: :all)end+ def amount_spent_in(currency)+ completed_orders.where(currency: currency).sum(:total)+ end++ def display_amount_spent_in(currency)+ Money.new(amount_spent_in(currency), currency: currency).to_html+ end+privatedef order_calculate(operation:, column:, store: nil, currency: nil)store ||= Store.defaultcurrency ||= store.default_currency- completed_orders(store).where(currency: currency).calculate(operation, column) || BigDecimal('0.00')+ completed_orders_for_store(store).where(currency: currency).calculate(operation, column) || BigDecimal('0.00')end- def completed_orders(store)+ def completed_orders_for_store(store)orders.for_store(store).complete.order(currency: :desc)endend