Created
February 22, 2018 00:10
-
-
Save nmcolome/4004c6c13e1a2473f8c48b806e5ab31a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DashboardSerializer < ActiveModel::Serializer | |
attributes :clusters, | |
:products, | |
:categories, | |
:net_sales_curr_year, | |
:segment_contribution, | |
:net_sales_prev_year, | |
:discounts_17 | |
def net_sales_prev_year | |
object.sales_16 + object.discounts_16 | |
end | |
def net_sales_curr_year | |
object.sales_17 + object.discounts_17 | |
end | |
def segment_contribution | |
(net_sales_curr_year / Sale.get_global_net_sales).round(4) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment