Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3283 [Enterprise Fee Summary] Fix values when calculator is order-based #3337

Merged
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2697,6 +2697,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using
date_end_before_start_error: "must be after start"
parameter_not_allowed_error: "You are not authorized to use one or more selected filters for this report."
fee_calculated_on_transfer_through_all: "All"
fee_calculated_on_transfer_through_entire_orders: "Entire Orders through %{distributor}"
tax_category_various: "Various"
fee_type:
payment_method: "Payment Transaction"
shipping_method: "Shipment"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for coordinator fees
# in an order cycle.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
class CoordinatorFee
include UsingEnterpriseFee

def fee_calculated_on_transfer_through_name
i18n_translate("fee_calculated_on_transfer_through_all")
end

def tax_category_name
return data["tax_category_name"] if data["tax_category_name"].present?
i18n_translate("tax_category_various") if inherits_tax_category?
end

def inherits_tax_category?
data["enterprise_fee_inherits_tax_category"] == "t"
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for exchange fees
# that use order-based calculators.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
class ExchangeOrderFee
include UsingEnterpriseFee

def fee_calculated_on_transfer_through_name
i18n_translate("fee_calculated_on_transfer_through_entire_orders",
distributor: data["adjustment_source_distributor_name"])
end

def tax_category_name
data["tax_category_name"] || i18n_translate("tax_category_various")
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for incoming
# exchange fees that use line item -based calculators.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this namespace provide other than making the nesting level pretty wide? These model classes won't clash with any other within the EnterpriseFeeSummary namespace, so I'd just remove DataRepresentations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree about removing DataRepresentations, @sauloperez.

The class ends up more deeply nested, but DataRepresentations I think makes it easier to find/ignore these classes and gives you an idea about their purpose.

If we reduce the nesting, I would want to rename the individual classes to reflect that they map DB query row attributes to report row attributes. For example, append "Representation" or "Presenter" (both terms actually from review of @mkllnk). Compared to this, I prefer nesting.

Let me know if you are okay with keeping this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this way of using namespaces to organize your code! #java

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me, it's pretty obvious already. The class name is a noun named after a domain concept. What else could it be? But if you guys prefer it, I don't mind.

class IncomingExchangeLineItemFee
include UsingEnterpriseFee

def fee_calculated_on_transfer_through_name
data["incoming_exchange_enterprise_name"]
end

def tax_category_name
data["tax_category_name"] || data["product_tax_category_name"]
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for outgoing
# exchange fees that use line item -based calculators.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
class OutgoingExchangeLineItemFee
include UsingEnterpriseFee

def fee_calculated_on_transfer_through_name
data["outgoing_exchange_enterprise_name"]
end

def tax_category_name
data["tax_category_name"] || data["product_tax_category_name"]
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for payment method
# fees.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
class PaymentMethodFee
include WithI18n

attr_reader :data

def initialize(data)
@data = data
end

def fee_type
i18n_translate("fee_type.payment_method")
end

def enterprise_name
data["hub_name"]
end

def fee_name
data["payment_method_name"]
end

def fee_placement; end

def fee_calculated_on_transfer_through_name; end

def tax_category_name; end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This module provides EnterpriseFeeSummary::Scope DB result to report mappings for shipping method
# fees.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
class ShippingMethodFee
include WithI18n

attr_reader :data

def initialize(data)
@data = data
end

def fee_type
i18n_translate("fee_type.shipping_method")
end

def enterprise_name
data["hub_name"]
end

def fee_name
data["shipping_method_name"]
end

def fee_placement; end

def fee_calculated_on_transfer_through_name; end

def tax_category_name
i18n_translate("tax_category_name.shipping_instance_rate")
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Different EnterpriseFeeSummary::Scope DB result attributes are checked when dealing with
# enterprise fees that are attached to an order cycle in different ways.
#
# This module provides DB result to report mappings that are common among all rows for enterprise
# fees. These mappings are not complete and should be supplemented with mappings that are specific
# to the way that the enterprise fee is attached to the order cycle.

module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
module UsingEnterpriseFee
include WithI18n

attr_reader :data

def initialize(data)
@data = data
end

def fee_type
data["fee_type"].try(:capitalize)
end

def enterprise_name
data["enterprise_name"]
end

def fee_name
data["fee_name"]
end

def fee_placement
i18n_translate("fee_placements.#{data['placement_enterprise_role']}")
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module OrderManagement
module Reports
module EnterpriseFeeSummary
module DataRepresentations
module WithI18n
private

def i18n_translate(translation_key, options = {})
I18n.t("order_management.reports.enterprise_fee_summary.#{translation_key}", options)
end
end
end
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def permission_filters

def enterprise_fee_type_total_list
enterprise_fees_by_customer.map do |total_data|
summarizer = EnterpriseFeeTypeTotalSummarizer.new(total_data)
summarizer = Summarizer.new(total_data)

ReportData::EnterpriseFeeTypeTotal.new.tap do |total|
enterprise_fee_type_summarizer_to_total_attributes.each do |attribute|
Expand Down
Loading