Class: Spree::Discount
- Inherits:
-
Object
- Object
- Spree::Discount
- Includes:
- TypedAdjustmentLine
- Defined in:
- app/models/spree/discount.rb
Overview
A promotion or manual discount on a line item or fulfillment. Amount is
enforced non-positive (validation + DB CHECK). Provenance snapshots
(+code+, value, value_type) keep rows meaningful after the promotion
is deleted — the promotion FKs are nullified, never cascaded.
Order-level discounts are distributed proportionally across line items at application time (largest-remainder) — there are no order-attached rows.
Constant Summary collapse
- KINDS =
promotionrows are written by promotion actions,manualones by an admin on a placed order. %w[promotion manual].freeze
Instance Method Summary collapse
Methods included from TypedAdjustmentLine
Instance Method Details
#adjustable ⇒ Spree::LineItem, ...
37 38 39 |
# File 'app/models/spree/discount.rb', line 37 def adjustable line_item || fulfillment end |
#promotion? ⇒ Boolean
41 42 43 |
# File 'app/models/spree/discount.rb', line 41 def promotion? kind == 'promotion' end |