Class: SolidusFriendlyPromotions::Calculators::Percent

Inherits:
Spree::Calculator
  • Object
show all
Includes:
PromotionCalculator
Defined in:
app/models/solidus_friendly_promotions/calculators/percent.rb

Instance Method Summary collapse

Methods included from PromotionCalculator

#description

Instance Method Details

#compute(object) ⇒ Object



12
13
14
15
16
# File 'app/models/solidus_friendly_promotions/calculators/percent.rb', line 12

def compute(object)
  preferred_currency = object.order.currency
  currency_exponent = ::Money::Currency.find(preferred_currency).exponent
  (object.discountable_amount * preferred_percent / 100).round(currency_exponent)
end