From a15cb58ab5441323656b7e59f973cb77229dc581 Mon Sep 17 00:00:00 2001 From: Abdul Aziz Ali Date: Tue, 21 Jan 2025 06:53:42 +0800 Subject: [PATCH] fetch variant enterprise fees from order lineitems adjustments #11529 --- .../enterprise_fees_with_tax_report_by_producer.rb | 8 +++----- .../enterprise_fees_with_tax_report_by_producer_spec.rb | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb index a9e487c2e7..4ee4d57d78 100644 --- a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb +++ b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb @@ -161,11 +161,9 @@ module Reporting # { variant: [enterprise_fee_ids] } def enterprise_fees_per_variant(order) hash = {} - order.order_cycle.exchanges.each do |exchange| - exchange.variants.each do |variant| - hash[variant] ||= order.order_cycle.coordinator_fee_ids - hash[variant] += exchange.enterprise_fee_ids - end + order.line_items.each do |li| + hash[li.variant] ||= order.order_cycle.coordinator_fee_ids + hash[li.variant] += li.adjustments.enterprise_fee.map(&:originator_id) end hash end diff --git a/spec/lib/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer_spec.rb b/spec/lib/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer_spec.rb index ae58f2e211..db4004a158 100644 --- a/spec/lib/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer_spec.rb +++ b/spec/lib/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer_spec.rb @@ -55,7 +55,6 @@ RSpec.describe Reporting::Reports::EnterpriseFeeSummary::EnterpriseFeesWithTaxRe report = described_class.new(current_user) - pending "https://github.com/openfoodfoundation/openfoodnetwork/issues/11529" expect(report.query_result.values).to eq [[order]] end end