mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Initialize data representation classes with data
There is no more need to pass the summarizer.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,7 @@ module OrderManagement
|
||||
private
|
||||
|
||||
def representation
|
||||
@representation ||= representation_klass.new(self)
|
||||
@representation ||= representation_klass.new(data)
|
||||
end
|
||||
|
||||
def representation_klass
|
||||
|
||||
Reference in New Issue
Block a user