Class: HhPackage::Pricing

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Includes:
ModelConcerns::DynamicPricingsForPricing, IdentityCache
Defined in:
app/models/hh_package/pricing.rb

Overview

selected_days are integers representing the day of the week, 0 is Sunday, 6 is Saturday

Constant Summary collapse

ACCEPT_MANY_QUANTITIES =
[:per_pack, :per_set, :per_item, :ala_carte].freeze
PER_SET_DEFAULT =
1.0
DEFAULT_CURRENCY =
'THB'
PER_PACK_DEFAULT_WHEN_MISSING =
1
MIN_SEAT =
1
MAX_SEAT =
1_000_000
MIN_SPENDING_PER_PERSON_TYPE =
'per_person'
MIN_SPENDING_PER_BOOKING_TYPE =
'per_booking'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModelConcerns::DynamicPricingsForPricing

#decide_max_seat, #decide_min_seat, #net_price_cents_per_person, #pricing_as_json, #pricing_type

Methods inherited from ApplicationRecord

sync_carrierwave_url

Instance Attribute Details

#skip_validationObject

Returns the value of attribute skip_validation.



65
66
67
# File 'app/models/hh_package/pricing.rb', line 65

def skip_validation
  @skip_validation
end

Instance Method Details

#marketing_priceObject



112
113
114
115
116
117
118
119
120
121
# File 'app/models/hh_package/pricing.rb', line 112

def marketing_price
  case pricing_model
  when :per_pack
    (price_cents / per_pack.to_f).ceil
  when :per_set
    (price_cents / HhPackage::Pricing::PER_SET_DEFAULT).ceil
  else
    price_cents
  end
end