Skip to content

Instantly share code, notes, and snippets.

@biagidp
Last active December 31, 2015 19:29
Show Gist options
  • Save biagidp/8034367 to your computer and use it in GitHub Desktop.
Save biagidp/8034367 to your computer and use it in GitHub Desktop.
module Spree
class Cause
has_many :products
def cumulative_impact
Spree::LineItem.select("sum((spree_line_items.price * spree_line_items.quantity * (1/spree_line_items.charity_percent::float)))").joins({variant: {product: :cause}}).where(causes: {id: self.id})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment