From 4cb91da8b228340518424799853d06ffdde327bb Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Wed, 2 Aug 2023 18:25:38 +0100 Subject: [PATCH] load only enterprise fees connected to incoming exchanges on the OC --- .../enterprise_fees_with_tax_report_by_producer.rb | 10 ++++++++++ ...summary_fee_with_tax_report_by_producer_spec.rb | 14 -------------- 2 files changed, 10 insertions(+), 14 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 4ca3848346..d7aa97d9b2 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 @@ -85,6 +85,7 @@ module Reporting query = order .all_adjustments .enterprise_fee + .where(originator_id: enterprise_fees_related_to_incoming_exchanges_ids(order)) if enterprise_fee_filters? query = query.where(originator_id: enterprise_fee_filtered_ids) @@ -101,6 +102,15 @@ module Reporting end end + def enterprise_fees_related_to_incoming_exchanges_ids(order) + order + .order_cycle + .exchanges + .incoming + .flat_map(&:enterprise_fee_ids) + .uniq + end + def join_tax_rate proc do |item| tax_rate_ids = item[:order].all_adjustments.tax.where( diff --git a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb index 9407607895..2250fdde0a 100644 --- a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb +++ b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb @@ -276,8 +276,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do context "with line items from a single supplier" do it 'generates the report and displays fees for the respective suppliers' do - pending "removal from distributor and coordinator fees from results" - login_as distributor_owner visit admin_reports_path click_on "Enterprise Fees With Tax Report By Producer" @@ -315,8 +313,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do end it "should filter by distributor and order cycle" do - pending "removal from distributor and coordinator fees from results" - page.find("#s2id_autogen1").click find('li', text: distributor.name).click # selects Distributor @@ -495,8 +491,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do end it "should filter by distributor and order cycle" do - pending "removal from distributor and coordinator fees from results" - page.find("#s2id_autogen1").click find('li', text: distributor.name).click # selects Distributor @@ -531,8 +525,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do end it "should filter by producer" do - pending "removal from distributor and coordinator fees from results" - page.find("#s2id_supplier_id_in").click find('li', text: supplier2.name).click @@ -705,8 +697,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do context "with line items from a single supplier" do it 'generates the report and displays fees for the respective suppliers' do - pending "removal from distributor and coordinator fees from results" - login_as distributor_owner visit admin_reports_path click_on "Enterprise Fees With Tax Report By Producer" @@ -849,8 +839,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do } it 'should list all the tax rates' do - pending "removal from distributor and coordinator fees from results" - login_as distributor_owner visit admin_reports_path click_on "Enterprise Fees With Tax Report By Producer" @@ -950,8 +938,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do } it 'should list all the tax rates' do - pending "removal from distributor and coordinator fees from results" - login_as distributor_owner visit admin_reports_path click_on "Enterprise Fees With Tax Report By Producer"