mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Add payments data, reformat dates
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
class Api::OrderSerializer < ActiveModel::Serializer
|
||||
attributes :id, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money
|
||||
attributes :id, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money, :payments
|
||||
|
||||
has_many :payments, serializer: Api::PaymentSerializer
|
||||
|
||||
def completed_at
|
||||
object.completed_at.blank? ? "" : object.completed_at.strftime("%F %T")
|
||||
object.completed_at.blank? ? "" : object.completed_at.to_formatted_s(:long_ordinal)
|
||||
end
|
||||
|
||||
def total_money
|
||||
|
||||
14
app/serializers/api/payment_serializer.rb
Normal file
14
app/serializers/api/payment_serializer.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Api::PaymentSerializer < ActiveModel::Serializer
|
||||
attributes :identifier, :amount, :updated_at, :payment_method
|
||||
def payment_method
|
||||
object.payment_method.name
|
||||
end
|
||||
|
||||
def amount
|
||||
object.amount.to_money.to_s
|
||||
end
|
||||
|
||||
def updated_at
|
||||
object.updated_at.to_formatted_s(:long_ordinal)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user