Files
openfoodnetwork/app/serializers/api/current_order_serializer.rb
Pau Perez 05aeb03839 Tag all methods that require refactor
These rely on order.shipping_method which needs to be replaced with
order.shipments.shipping_method
2017-07-01 13:56:49 +02:00

20 lines
589 B
Ruby

class Api::CurrentOrderSerializer < ActiveModel::Serializer
# SHIPPING_METHOD
attributes :id, :item_total, :email, :shipping_method_id,
:display_total, :payment_method_id
has_one :bill_address, serializer: Api::AddressSerializer
has_one :ship_address, serializer: Api::AddressSerializer
has_many :line_items, serializer: Api::LineItemSerializer
has_many :finalised_line_items, serializer: Api::LineItemSerializer
def payment_method_id
object.payments.first.andand.payment_method_id
end
def display_total
object.display_total.money.to_f
end
end