mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Move data representation translations to class
This commit is contained in:
@@ -9,12 +9,12 @@ module OrderManagement
|
||||
include UsingEnterpriseFee
|
||||
|
||||
def fee_calculated_on_transfer_through_name
|
||||
context.i18n_translate("fee_calculated_on_transfer_through_all")
|
||||
i18n_translate("fee_calculated_on_transfer_through_all")
|
||||
end
|
||||
|
||||
def tax_category_name
|
||||
return context.data["tax_category_name"] if context.data["tax_category_name"].present?
|
||||
context.i18n_translate("tax_category_various") if inherits_tax_category?
|
||||
i18n_translate("tax_category_various") if inherits_tax_category?
|
||||
end
|
||||
|
||||
def inherits_tax_category?
|
||||
|
||||
@@ -9,12 +9,12 @@ module OrderManagement
|
||||
include UsingEnterpriseFee
|
||||
|
||||
def fee_calculated_on_transfer_through_name
|
||||
context.i18n_translate("fee_calculated_on_transfer_through_entire_orders",
|
||||
distributor: context.data["adjustment_source_distributor_name"])
|
||||
i18n_translate("fee_calculated_on_transfer_through_entire_orders",
|
||||
distributor: context.data["adjustment_source_distributor_name"])
|
||||
end
|
||||
|
||||
def tax_category_name
|
||||
context.data["tax_category_name"] || context.i18n_translate("tax_category_various")
|
||||
context.data["tax_category_name"] || i18n_translate("tax_category_various")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,8 @@ module OrderManagement
|
||||
module EnterpriseFeeSummary
|
||||
module DataRepresentations
|
||||
class PaymentMethodFee
|
||||
include WithI18n
|
||||
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@@ -13,7 +15,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def fee_type
|
||||
context.i18n_translate("fee_type.payment_method")
|
||||
i18n_translate("fee_type.payment_method")
|
||||
end
|
||||
|
||||
def enterprise_name
|
||||
|
||||
@@ -6,6 +6,8 @@ module OrderManagement
|
||||
module EnterpriseFeeSummary
|
||||
module DataRepresentations
|
||||
class ShippingMethodFee
|
||||
include WithI18n
|
||||
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@@ -13,7 +15,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def fee_type
|
||||
context.i18n_translate("fee_type.shipping_method")
|
||||
i18n_translate("fee_type.shipping_method")
|
||||
end
|
||||
|
||||
def enterprise_name
|
||||
@@ -29,7 +31,7 @@ module OrderManagement
|
||||
def fee_calculated_on_transfer_through_name; end
|
||||
|
||||
def tax_category_name
|
||||
context.i18n_translate("tax_category_name.shipping_instance_rate")
|
||||
i18n_translate("tax_category_name.shipping_instance_rate")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,8 @@ module OrderManagement
|
||||
module EnterpriseFeeSummary
|
||||
module DataRepresentations
|
||||
module UsingEnterpriseFee
|
||||
include WithI18n
|
||||
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@@ -29,7 +31,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def fee_placement
|
||||
context.i18n_translate("fee_placements.#{context.data['placement_enterprise_role']}")
|
||||
i18n_translate("fee_placements.#{context.data['placement_enterprise_role']}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -19,10 +19,6 @@ module OrderManagement
|
||||
data["total_amount"]
|
||||
end
|
||||
|
||||
def i18n_translate(translation_key, options = {})
|
||||
I18n.t("order_management.reports.enterprise_fee_summary.#{translation_key}", options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def representation
|
||||
|
||||
Reference in New Issue
Block a user