Module: Spree::DerivedNumber
- Extended by:
- ActiveSupport::Concern
- Included in:
- Fulfillment, Payment
- Defined in:
- app/models/concerns/spree/derived_number.rb
Overview
A number derived from the parent purchase rather than generated and
stored (docs/plans/6.0-document-numbers.md): R1001-F1, R1001-P2.
Fulfillments and payments are children of one order, and a number that
names its parent reads better everywhere it appears — a merchant reading
R1001-F2 in a support conversation knows immediately which order and
which parcel, where F0000123456 told them nothing. It also costs
nothing to maintain: no counter, no collision handling, and the child
automatically follows whatever format the merchant chose for orders.
Rows created before 6.0 keep their stored number, so gateway references and packing slips already in the wild still resolve. New rows never write the column — it is frozen legacy data awaiting the 6.3 drop.
Instance Method Summary collapse
-
#number ⇒ String?
The stored number on legacy rows, otherwise one derived from the parent purchase and this record's position among its siblings.
Instance Method Details
#number ⇒ String?
Returns the stored number on legacy rows, otherwise one derived from the parent purchase and this record's position among its siblings.
29 30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/spree/derived_number.rb', line 29 def number stored = self[:number] return stored if stored.present? parent = owner return if parent.nil? "#{parent.number}-#{self.class.number_infix}#{position_among_siblings}" end |