Class: Spree::Fee

Inherits:
Object
  • Object
show all
Includes:
TypedAdjustmentLine
Defined in:
app/models/spree/fee.rb

Overview

An extensible charge (surcharge, handling, gift wrap, COD, payment fee). May target a line item or fulfillment, or be order-level (both adjustable FKs nil). Fees are taxable — the tax provider writes TaxLine rows against them. Ad-hoc credits are manual Discounts, never negative fees (amount is enforced non-negative by validation + DB CHECK).

Constant Summary collapse

KINDS =

Extensions may append their own kinds — the list is validated, not frozen. duty rows are written by a duties provider's adjuster and snapshot the classification they were calculated from in metadata — never re-derive a duty from the live catalog. exchange is what a customer owes when an exchange's replacement costs more, put on the order for the merchant to collect.

%w[surcharge handling gift_wrap cod payment duty exchange]

Instance Method Summary collapse

Methods included from TypedAdjustmentLine

#currency, #order=, #owner

Instance Method Details

#adjustable ⇒ Spree::LineItem, ...

Returns nil for order-level fees.

Returns:



34
35
36
# File 'app/models/spree/fee.rb', line 34

def adjustable
  line_item || fulfillment
end

#order_level? ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/spree/fee.rb', line 38

def order_level?
  line_item_id.nil? && fulfillment_id.nil?
end