mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Do not use ReportData::EnterpriseFeeTypeTotals
This commit is contained in:
@@ -11,7 +11,7 @@ module OrderManagement
|
||||
CSV.generate do |csv|
|
||||
render_header(csv)
|
||||
|
||||
report_data.enterprise_fee_type_totals.list.each do |data|
|
||||
report_data.list.each do |data|
|
||||
render_data_row(csv, data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def data_rows
|
||||
report_data.enterprise_fee_type_totals.list.map do |data|
|
||||
report_data.list.map do |data|
|
||||
data_row_attributes.map do |attribute|
|
||||
data.public_send(attribute)
|
||||
end
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
module OrderManagement
|
||||
module Reports
|
||||
module EnterpriseFeeSummary
|
||||
module ReportData
|
||||
class EnterpriseFeeTypeTotals < ::Reports::ReportData::Base
|
||||
attr_accessor :list
|
||||
|
||||
def initialize(*args)
|
||||
@list = []
|
||||
|
||||
super(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
require "order_management/reports/enterprise_fee_summary/scope"
|
||||
require "order_management/reports/enterprise_fee_summary/enterprise_fee_type_total_summarizer"
|
||||
require "order_management/reports/enterprise_fee_summary/report_data/enterprise_fee_type_totals"
|
||||
require "order_management/reports/enterprise_fee_summary/report_data/enterprise_fee_type_total"
|
||||
|
||||
module OrderManagement
|
||||
@@ -18,8 +17,8 @@ module OrderManagement
|
||||
Scope.new.apply_filters(permission_filters).apply_filters(parameters).result
|
||||
end
|
||||
|
||||
def enterprise_fee_type_totals
|
||||
ReportData::EnterpriseFeeTypeTotals.new(list: enterprise_fee_type_total_list.sort)
|
||||
def list
|
||||
enterprise_fee_type_total_list.sort
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -23,9 +23,8 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::CsvRenderer
|
||||
end
|
||||
|
||||
let!(:enterprise_fee_type_totals) do
|
||||
instance = report_klass::ReportData::EnterpriseFeeTypeTotals.new
|
||||
instance.tap do |totals|
|
||||
totals.list << report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
[
|
||||
report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
fee_type: "Fee Type A",
|
||||
enterprise_name: "Enterprise A",
|
||||
fee_name: "Fee A",
|
||||
@@ -34,9 +33,8 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::CsvRenderer
|
||||
fee_calculated_on_transfer_through_name: "Transfer Enterprise A",
|
||||
tax_category_name: "Tax Category A",
|
||||
total_amount: "1.00"
|
||||
)
|
||||
|
||||
totals.list << report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
),
|
||||
report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
fee_type: "Fee Type B",
|
||||
enterprise_name: "Enterprise B",
|
||||
fee_name: "Fee C",
|
||||
@@ -46,13 +44,13 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::CsvRenderer
|
||||
tax_category_name: "Tax Category G",
|
||||
total_amount: "2.00"
|
||||
)
|
||||
end
|
||||
]
|
||||
end
|
||||
|
||||
let(:current_user) { nil }
|
||||
|
||||
before do
|
||||
allow(service).to receive(:enterprise_fee_type_totals) { enterprise_fee_type_totals }
|
||||
allow(service).to receive(:list) { enterprise_fee_type_totals }
|
||||
end
|
||||
|
||||
it "generates CSV header" do
|
||||
|
||||
@@ -15,9 +15,8 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::HtmlRenderer
|
||||
let!(:renderer) { described_class.new(service) }
|
||||
|
||||
let!(:enterprise_fee_type_totals) do
|
||||
instance = report_klass::ReportData::EnterpriseFeeTypeTotals.new
|
||||
instance.tap do |totals|
|
||||
totals.list << report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
[
|
||||
report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
fee_type: "Fee Type A",
|
||||
enterprise_name: "Enterprise A",
|
||||
fee_name: "Fee A",
|
||||
@@ -26,9 +25,8 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::HtmlRenderer
|
||||
fee_calculated_on_transfer_through_name: "Transfer Enterprise A",
|
||||
tax_category_name: "Tax Category A",
|
||||
total_amount: "1.00"
|
||||
)
|
||||
|
||||
totals.list << report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
),
|
||||
report_klass::ReportData::EnterpriseFeeTypeTotal.new(
|
||||
fee_type: "Fee Type B",
|
||||
enterprise_name: "Enterprise B",
|
||||
fee_name: "Fee C",
|
||||
@@ -38,13 +36,13 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::Renderers::HtmlRenderer
|
||||
tax_category_name: "Tax Category G",
|
||||
total_amount: "2.00"
|
||||
)
|
||||
end
|
||||
]
|
||||
end
|
||||
|
||||
let(:current_user) { nil }
|
||||
|
||||
before do
|
||||
allow(service).to receive(:enterprise_fee_type_totals) { enterprise_fee_type_totals }
|
||||
allow(service).to receive(:list) { enterprise_fee_type_totals }
|
||||
end
|
||||
|
||||
it "generates header values" do
|
||||
|
||||
@@ -89,9 +89,9 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:service) { described_class.new(permissions, parameters) }
|
||||
|
||||
it "groups and sorts entries correctly" do
|
||||
totals = service.enterprise_fee_type_totals
|
||||
totals = service.list
|
||||
|
||||
expect(totals.list.length).to eq(16)
|
||||
expect(totals.length).to eq(16)
|
||||
|
||||
# Data is sorted by the following, in order:
|
||||
# * fee_type
|
||||
@@ -139,7 +139,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
]
|
||||
|
||||
expected_result.each_with_index do |expected_attributes, row_index|
|
||||
expect_total_attributes(totals.list[row_index], expected_attributes)
|
||||
expect_total_attributes(totals[row_index], expected_attributes)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -171,7 +171,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let!(:current_user) { create(:admin_user) }
|
||||
|
||||
it "includes all order cycles" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 2, fee_type: "Shipment")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor A")
|
||||
@@ -183,7 +183,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let!(:current_user) { distributor_a.owner }
|
||||
|
||||
it "does not include unrelated order cycles" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor A")
|
||||
@@ -225,7 +225,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { start_at: timestamp } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 0, fee_type: "Shipment", customer_name: "Customer A")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", customer_name: "Customer B")
|
||||
@@ -237,7 +237,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { end_at: timestamp } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", customer_name: "Customer A")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", customer_name: "Customer B")
|
||||
@@ -267,7 +267,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { distributor_ids: [distributor_a.id, distributor_b.id] } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor A")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor B")
|
||||
@@ -305,7 +305,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { producer_ids: [producer_a.id, producer_b.id] } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_name: "Fee A", enterprise_name: "Producer A")
|
||||
expect_total_matches(totals, 1, fee_name: "Fee B", enterprise_name: "Producer B")
|
||||
@@ -342,7 +342,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { order_cycle_ids: [order_cycle_a.id, order_cycle_b.id] } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor A")
|
||||
expect_total_matches(totals, 1, fee_type: "Shipment", enterprise_name: "Distributor B")
|
||||
@@ -362,7 +362,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
let(:parameters_attributes) { { enterprise_fee_ids: [fee_a.id, fee_b.id] } }
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_name: "Fee A")
|
||||
expect_total_matches(totals, 1, fee_name: "Fee B")
|
||||
@@ -390,7 +390,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
end
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_name: "Shipping A")
|
||||
expect_total_matches(totals, 1, fee_name: "Shipping B")
|
||||
@@ -418,7 +418,7 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
|
||||
end
|
||||
|
||||
it "filters entries" do
|
||||
totals = service.enterprise_fee_type_totals.list
|
||||
totals = service.list
|
||||
|
||||
expect_total_matches(totals, 1, fee_name: "Payment A")
|
||||
expect_total_matches(totals, 1, fee_name: "Payment B")
|
||||
|
||||
Reference in New Issue
Block a user