Sha256: 8ee3faf35e70963827b19c44316bd70b5556a21d50a35999fd865dba81b21252
Contents?: true
Size: 792 Bytes
Versions: 17
Compression:
Stored size: 792 Bytes
Contents
require_dependency 'spree/calculator' # This is a calculator for line item adjustment actions. It accepts a line item # and calculates its weighted adjustment amount based on the value of the # preferred amount and the price of the other line items. More expensive line # items will receive a greater share of the preferred amount. module Spree class Calculator::DistributedAmount < Calculator preference :amount, :decimal, default: 0 preference :currency, :string, default: -> { Spree::Config[:currency] } def compute_line_item(line_item) if line_item && preferred_currency.casecmp(line_item.currency).zero? Spree::DistributedAmountsHandler.new( line_item, preferred_amount ).amount else 0 end end end end
Version data entries
17 entries across 17 versions & 1 rubygems