Class: SpreeCmCommissioner::Calculators::ServiceFeePercent

Inherits:
Spree::Calculator
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/calculators/service_fee_percent.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.description ⇒ Object



6
7
8
# File 'app/models/spree_cm_commissioner/calculators/service_fee_percent.rb', line 6

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

Instance Method Details

#compute(line_item) ⇒ Object

discounted_amount (price net of taxable promotions, before tax) rather than pre_tax_amount: the latter is only ever populated as a side effect of Spree::TaxRate.store_pre_tax_amount running for this line item, so it would make service-fee computation order-dependent on tax having already run. discounted_amount is a live computed value (amount + taxable_adjustment_total) with no such dependency.



15
16
17
# File 'app/models/spree_cm_commissioner/calculators/service_fee_percent.rb', line 15

def compute(line_item)
  line_item.discounted_amount * preferred_percent / 100
end