From fb2279d26db980fb58adcf09ae8ed4ea027ff688 Mon Sep 17 00:00:00 2001 From: lin-d-hop Date: Wed, 25 May 2022 22:08:05 +0100 Subject: [PATCH] Draft PR with potential fix to the reports S1. Untested. --- lib/reporting/reports/orders_and_fulfillment/base.rb | 6 ------ .../orders_and_fulfillment/order_cycle_customer_totals.rb | 6 ++++++ .../order_cycle_distributor_totals_by_supplier.rb | 6 ++++++ .../orders_and_fulfillment/order_cycle_supplier_totals.rb | 6 ++++++ .../order_cycle_supplier_totals_by_distributor.rb | 6 ++++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/reporting/reports/orders_and_fulfillment/base.rb b/lib/reporting/reports/orders_and_fulfillment/base.rb index 72ca34a83d..70ac309fc1 100644 --- a/lib/reporting/reports/orders_and_fulfillment/base.rb +++ b/lib/reporting/reports/orders_and_fulfillment/base.rb @@ -21,12 +21,6 @@ module Reporting report_line_items.orders end - def query_result - report_line_items.list(line_item_includes).group_by { |e| - [e.variant_id, e.price, e.order_id] - }.values - end - private def order_permissions diff --git a/lib/reporting/reports/orders_and_fulfillment/order_cycle_customer_totals.rb b/lib/reporting/reports/orders_and_fulfillment/order_cycle_customer_totals.rb index 1c3739aed6..9523d7e4cd 100644 --- a/lib/reporting/reports/orders_and_fulfillment/order_cycle_customer_totals.rb +++ b/lib/reporting/reports/orders_and_fulfillment/order_cycle_customer_totals.rb @@ -95,6 +95,12 @@ module Reporting :user, :distributor, :shipments] }] end + def query_result + report_line_items.list(line_item_includes).group_by { |e| + [e.variant_id, e.price, e.order_id] + }.values + end + private def row_header(row) diff --git a/lib/reporting/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier.rb b/lib/reporting/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier.rb index 4c5c093d36..ec6aae5af2 100644 --- a/lib/reporting/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier.rb +++ b/lib/reporting/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier.rb @@ -44,6 +44,12 @@ module Reporting variant: [{ option_values: :option_type }, { product: :supplier }] }] end + + def query_result + report_line_items.list(line_item_includes).group_by { |e| + [e.variant_id, e.price] + }.values + end end end end diff --git a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb index 1a1a085cf0..3b242225df 100644 --- a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb +++ b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb @@ -35,6 +35,12 @@ module Reporting def line_item_includes [{ variant: [{ option_values: :option_type }, { product: :supplier }] }] end + + def query_result + report_line_items.list(line_item_includes).group_by { |e| + [e.variant_id, e.price] + }.values + end end end end diff --git a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor.rb b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor.rb index 4152731bcf..993f4ce7f1 100644 --- a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor.rb +++ b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor.rb @@ -42,6 +42,12 @@ module Reporting [{ order: :distributor, variant: [{ option_values: :option_type }, { product: :supplier }] }] end + + def query_result + report_line_items.list(line_item_includes).group_by { |e| + [e.variant_id, e.price] + }.values + end end end end