Merge pull request #10442 from mkllnk/enterprise-fee-summary-report

Report deleted fees in Enterprise Fee Summary
This commit is contained in:
Konrad
2023-02-26 19:28:01 +01:00
committed by GitHub
2 changed files with 44 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ module Reporting
return DataRepresentations::PaymentMethodFee if for_payment_method?
return DataRepresentations::ShippingMethodFee if for_shipping_method?
enterprise_fee_adjustment_presentation_klass if for_enterprise_fee?
enterprise_fee_adjustment_presentation_klass
end
def enterprise_fee_adjustment_presentation_klass
@@ -50,10 +50,6 @@ module Reporting
data["shipping_method_name"].present?
end
def for_enterprise_fee?
data["fee_name"].present?
end
def for_coordinator_fee?
data["placement_enterprise_role"] == "coordinator"
end

View File

@@ -0,0 +1,43 @@
# frozen_string_literal: true
require "spec_helper"
describe Reporting::Reports::EnterpriseFeeSummary::Summarizer do
let(:row) {
{
"total_amount" => 1, "payment_method_name" => nil,
"shipping_method_name" => nil, "hub_name" => "Kimchi Hub",
"enterprise_name" => nil, "fee_type" => nil,
"customer_name" => "Fermented Greens",
"customer_email" => "kimchi@example.com", "fee_name" => nil,
"tax_category_name" => nil,
"enterprise_fee_inherits_tax_category" => nil,
"product_tax_category_name" => nil,
"placement_enterprise_role" => nil,
"adjustment_adjustable_type" => nil,
"adjustment_source_distributor_name" => nil,
"incoming_exchange_enterprise_name" => nil,
"outgoing_exchange_enterprise_name" => nil,
"id" => nil
}
}
it "represents a transaction fee" do
data = row.merge(
"payment_method_name" => "cash",
"adjustment_adjustable_type" => "Spree::Payment",
)
summarizer = described_class.new(data)
expect(summarizer.fee_type).to eq "Payment Transaction"
end
it "represents an enterprise fee without name" do
data = row.merge(
"fee_name" => nil,
"placement_enterprise_role" => "coordinator",
"adjustment_adjustable_type" => "Spree::LineItem",
)
summarizer = described_class.new(data)
expect(summarizer.fee_type).to eq nil
end
end