cirandas.net

ref: master

plugins/orders_cycle/serializers/orders_cycle_plugin/sale_serializer.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module OrdersCyclePlugin
  class SaleSerializer < ApplicationSerializer

    attribute :total_price
    attribute :status
    has_one :date
    has_one :cycle
    has_one :value_ordered
    has_one :final_value

    def date
      object.created_at.strftime "%d/%m/%Y"
    end
    def cycle
      object.cycle.name
    end
    def value_ordered
      object.total_price_consumer_ordered_as_currency
    end
    def final_value
      object.total_price_consumer_received_as_currency
    end
  end
end