Module: SpreeCmCommissioner::LineItemDurationable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spree_cm_commissioner/line_item_durationable.rb
Instance Method Summary collapse
- #amount_per_date_unit ⇒ Object
- #date_present? ⇒ Boolean
- #date_range ⇒ Object
- #date_range_excluding_checkout ⇒ Object
- #date_range_including_checkout ⇒ Object
- #date_unit ⇒ Object
Instance Method Details
#amount_per_date_unit ⇒ Object
14 15 16 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 14 def amount_per_date_unit amount / date_unit end |
#date_present? ⇒ Boolean
10 11 12 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 10 def date_present? from_date.present? && to_date.present? end |
#date_range ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 38 def date_range if accommodation? date_range_excluding_checkout else date_range_including_checkout end end |
#date_range_excluding_checkout ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 24 def date_range_excluding_checkout return [] unless date_present? date_range = (from_date.to_date..to_date.to_date).to_a date_range.pop if date_range.size > 1 date_range end |
#date_range_including_checkout ⇒ Object
32 33 34 35 36 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 32 def date_range_including_checkout return [] unless date_present? (from_date.to_date..to_date.to_date).to_a end |
#date_unit ⇒ Object
18 19 20 21 22 |
# File 'app/models/concerns/spree_cm_commissioner/line_item_durationable.rb', line 18 def date_unit return nil unless permanent_stock? date_range_excluding_checkout.size if accommodation? end |