Skip to content

Instantly share code, notes, and snippets.

@nmcolome
Created February 22, 2018 00:10
Show Gist options
  • Save nmcolome/4004c6c13e1a2473f8c48b806e5ab31a to your computer and use it in GitHub Desktop.
Save nmcolome/4004c6c13e1a2473f8c48b806e5ab31a to your computer and use it in GitHub Desktop.
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