Class: Warranty::Product
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Warranty::Product
- Defined in:
- app/models/warranty/product.rb
Overview
One registered UNIT under a Warranty — a qty-3 roll line is three
products, because every roll/cable has its own serial and resistance
readings on the card, and every product line its own term (TempZone 25yr,
snow melting 10yr, …) and therefore its own expiry.
Constant Summary
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Belongs to collapse
-
#line_item ⇒ LineItem
The order line this unit came from (order-matched registrations).
- #warranty ⇒ Warranty
Delegated Instance Attributes collapse
-
#coverage_starts_on ⇒ Object
Alias for Warranty#coverage_starts_on.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Whether the stored expiration has passed.
-
#product_line_label ⇒ String
Human label for the product line.
-
#term_in_years ⇒ Integer?
Warranty duration in years: the printed-term override when set, otherwise the TERMS default for the line.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Method Details
#coverage_starts_on ⇒ Object
Alias for Warranty#coverage_starts_on
42 |
# File 'app/models/warranty/product.rb', line 42 delegate :coverage_starts_on, to: :warranty, allow_nil: true |
#expired? ⇒ Boolean
Returns whether the stored expiration has passed.
82 83 84 |
# File 'app/models/warranty/product.rb', line 82 def expired? valid_until.present? && valid_until < Date.current end |
#line_item ⇒ LineItem
The order line this unit came from (order-matched registrations).
37 |
# File 'app/models/warranty/product.rb', line 37 belongs_to :line_item, optional: true |
#product_line_label ⇒ String
Returns human label for the product line.
69 70 71 |
# File 'app/models/warranty/product.rb', line 69 def product_line_label Warranty::PRODUCT_LINE_LABELS.fetch(product_line, product_line.to_s.humanize) end |
#term_in_years ⇒ Integer?
Warranty duration in years: the printed-term override when set,
otherwise the TERMS default for the line.
77 78 79 |
# File 'app/models/warranty/product.rb', line 77 def term_in_years (term_years.presence || Warranty::TERMS[product_line])&.to_i end |
#warranty ⇒ Warranty
35 |
# File 'app/models/warranty/product.rb', line 35 belongs_to :warranty, inverse_of: :products |