mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
This reverts commit e86e08b72e939fee61eddd41d56081395666a877. Conflicts: lib/open_food_network/order_and_distributor_report.rb spec/features/admin/variants_spec.rb spec/lib/open_food_network/order_and_distributor_report_spec.rb
26 lines
760 B
Ruby
26 lines
760 B
Ruby
class Api::VariantSerializer < ActiveModel::Serializer
|
|
attributes :id, :is_master, :count_on_hand, :name_to_display, :unit_to_display,
|
|
:options_text, :on_demand, :price, :fees, :price_with_fees, :product_name
|
|
|
|
def price
|
|
object.price
|
|
end
|
|
|
|
def fees
|
|
options[:enterprise_fee_calculator].andand.indexed_fees_by_type_for(object) ||
|
|
object.fees_by_type_for(options[:current_distributor], options[:current_order_cycle])
|
|
end
|
|
|
|
def price_with_fees
|
|
if options[:enterprise_fee_calculator]
|
|
object.price + options[:enterprise_fee_calculator].indexed_fees_for(object)
|
|
else
|
|
object.price_with_fees(options[:current_distributor], options[:current_order_cycle])
|
|
end
|
|
end
|
|
|
|
def product_name
|
|
object.product.name
|
|
end
|
|
end
|