Initialize data representation classes with data

There is no more need to pass the summarizer.
This commit is contained in:
Kristina Lim
2019-01-24 06:10:53 +11:00
parent ddc788ed5d
commit 5e8a336e24
8 changed files with 26 additions and 26 deletions

View File

@@ -13,12 +13,12 @@ module OrderManagement
end
def tax_category_name
return context.data["tax_category_name"] if context.data["tax_category_name"].present?
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?
context.data["enterprise_fee_inherits_tax_category"] == "t"
data["enterprise_fee_inherits_tax_category"] == "t"
end
end
end

View File

@@ -10,11 +10,11 @@ module OrderManagement
def fee_calculated_on_transfer_through_name
i18n_translate("fee_calculated_on_transfer_through_entire_orders",
distributor: context.data["adjustment_source_distributor_name"])
distributor: data["adjustment_source_distributor_name"])
end
def tax_category_name
context.data["tax_category_name"] || i18n_translate("tax_category_various")
data["tax_category_name"] || i18n_translate("tax_category_various")
end
end
end

View File

@@ -9,11 +9,11 @@ module OrderManagement
include UsingEnterpriseFee
def fee_calculated_on_transfer_through_name
context.data["incoming_exchange_enterprise_name"]
data["incoming_exchange_enterprise_name"]
end
def tax_category_name
context.data["tax_category_name"] || context.data["product_tax_category_name"]
data["tax_category_name"] || data["product_tax_category_name"]
end
end
end

View File

@@ -9,11 +9,11 @@ module OrderManagement
include UsingEnterpriseFee
def fee_calculated_on_transfer_through_name
context.data["outgoing_exchange_enterprise_name"]
data["outgoing_exchange_enterprise_name"]
end
def tax_category_name
context.data["tax_category_name"] || context.data["product_tax_category_name"]
data["tax_category_name"] || data["product_tax_category_name"]
end
end
end

View File

@@ -8,10 +8,10 @@ module OrderManagement
class PaymentMethodFee
include WithI18n
attr_reader :context
attr_reader :data
def initialize(context)
@context = context
def initialize(data)
@data = data
end
def fee_type
@@ -19,11 +19,11 @@ module OrderManagement
end
def enterprise_name
context.data["hub_name"]
data["hub_name"]
end
def fee_name
context.data["payment_method_name"]
data["payment_method_name"]
end
def fee_placement; end

View File

@@ -8,10 +8,10 @@ module OrderManagement
class ShippingMethodFee
include WithI18n
attr_reader :context
attr_reader :data
def initialize(context)
@context = context
def initialize(data)
@data = data
end
def fee_type
@@ -19,11 +19,11 @@ module OrderManagement
end
def enterprise_name
context.data["hub_name"]
data["hub_name"]
end
def fee_name
context.data["shipping_method_name"]
data["shipping_method_name"]
end
def fee_placement; end

View File

@@ -12,26 +12,26 @@ module OrderManagement
module UsingEnterpriseFee
include WithI18n
attr_reader :context
attr_reader :data
def initialize(context)
@context = context
def initialize(data)
@data = data
end
def fee_type
context.data["fee_type"].try(:capitalize)
data["fee_type"].try(:capitalize)
end
def enterprise_name
context.data["enterprise_name"]
data["enterprise_name"]
end
def fee_name
context.data["fee_name"]
data["fee_name"]
end
def fee_placement
i18n_translate("fee_placements.#{context.data['placement_enterprise_role']}")
i18n_translate("fee_placements.#{data['placement_enterprise_role']}")
end
end
end

View File

@@ -22,7 +22,7 @@ module OrderManagement
private
def representation
@representation ||= representation_klass.new(self)
@representation ||= representation_klass.new(data)
end
def representation_klass