Sha256: 6fe76c448c249500c3f1050622d0d52722c7160b75197b965860415d9e7bdca7
Contents?: true
Size: 489 Bytes
Versions: 13
Compression:
Stored size: 489 Bytes
Contents
require_dependency 'spree/calculator' module Spree class Calculator::FlatPercentItemTotal < Calculator preference :flat_percent, :decimal, default: 0 def self.description Spree.t(:flat_percent) end def compute(object) return unless object.present? and object.respond_to?(:item_total) item_total = object.item_total value = item_total * BigDecimal(self.preferred_flat_percent.to_s) / 100.0 (value * 100).round.to_f / 100 end end end
Version data entries
13 entries across 13 versions & 1 rubygems