Class: Spree::Calculator::PercentOnLineItem

Inherits:
Spree::Calculator show all
Defined in:
app/models/spree/calculator/percent_on_line_item.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::Calculator

#available?, calculators, #description, register, #to_s

Methods inherited from Base

page

Methods included from Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.descriptionObject


6
7
8
# File 'app/models/spree/calculator/percent_on_line_item.rb', line 6

def self.description
  Spree.t(:percent_per_item)
end

Instance Method Details

#compute(object) ⇒ Object


10
11
12
# File 'app/models/spree/calculator/percent_on_line_item.rb', line 10

def compute(object)
  (object.amount * preferred_percent) / 100
end