Move data representation translations to class

This commit is contained in:
Kristina Lim
2019-01-24 03:06:14 +08:00
parent bc95560598
commit ddc788ed5d
7 changed files with 30 additions and 13 deletions

View File

@@ -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?

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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