Class: ReservationProperty
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ReservationProperty
- Includes:
- ArTransactionChanges
- Defined in:
- app/models/reservation_property.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
- #add_on? ⇒ Boolean
- #custom_package_pricing ⇒ Object
- #custom_package_pricing? ⇒ Boolean
- #package? ⇒ Boolean
-
#price_cents ⇒ Integer, BigDecimal
price_cents column is a virtual column in the database it is calculated as the sum of package price_cents and add-on price_cents if either package or add-on is nil, it is treated as 0 so needs to create an instance method to access the value correctly.
-
#revenue ⇒ Integer, BigDecimal
revenue column is a virtual column in the database it is calculated as the sum of package revenue and add-on revenue if either package or add-on is nil, it is treated as 0 so needs to create an instance method to access the value correctly.
Methods inherited from ApplicationRecord
Instance Method Details
#add_on? ⇒ Boolean
54 55 56 |
# File 'app/models/reservation_property.rb', line 54 def add_on? add_on.present? end |
#custom_package_pricing ⇒ Object
62 63 64 65 66 |
# File 'app/models/reservation_property.rb', line 62 def custom_package_pricing return nil unless package? package['custom_package_data'] end |
#custom_package_pricing? ⇒ Boolean
58 59 60 |
# File 'app/models/reservation_property.rb', line 58 def custom_package_pricing? package? && package['custom_package_data'].present? end |
#package? ⇒ Boolean
50 51 52 |
# File 'app/models/reservation_property.rb', line 50 def package? package.present? end |
#price_cents ⇒ Integer, BigDecimal
price_cents column is a virtual column in the database it is calculated as the sum of package price_cents and add-on price_cents if either package or add-on is nil, it is treated as 0 so needs to create an instance method to access the value correctly
85 86 87 88 |
# File 'app/models/reservation_property.rb', line 85 def price_cents value = (self[:price_cents] || 0).to_d value % 1 == 0 ? value.to_i : value end |
#revenue ⇒ Integer, BigDecimal
revenue column is a virtual column in the database it is calculated as the sum of package revenue and add-on revenue if either package or add-on is nil, it is treated as 0 so needs to create an instance method to access the value correctly
74 75 76 77 |
# File 'app/models/reservation_property.rb', line 74 def revenue value = (self[:revenue] || 0).to_d value % 1 == 0 ? value.to_i : value end |