Class: AddOns::AddOn
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AddOns::AddOn
- Extended by:
- Enumerize
- Includes:
- IdentityCache, MultilingualCacheInvalidation
- Defined in:
- app/models/add_ons/add_on.rb
Overview
Schema Information
Table name: add_ons
id :bigint not null, primary key
accept_refund_guarantee :boolean default(FALSE), not null
commission :decimal(5, 2)
cover_image :string(191)
description :text(65535)
limit_per_booking :integer
limit_per_day :integer
limit_per_pax :integer
menu_links :text(65535)
menu_type :string(191)
minimum_booking_time_in_advance :integer default(0)
name :string(191)
original_price_cents :integer default(0), not null
original_price_currency :string(191) default("THB"), not null
price_currency :string(255) default("THB")
refund_amount :integer default(0)
refund_hours_in_advance :integer default(0)
refund_type :string(255) default("no_refund")
special_agenda :boolean default(FALSE)
tnc_image :string(191)
use_kids_price :boolean default(FALSE)
created_at :datetime not null
updated_at :datetime not null
country_id :bigint
custom_label_id :bigint
custom_menu_id :string(191)
package_group_id :bigint
Indexes
index_add_ons_on_custom_label_id (custom_label_id)
Foreign Keys
fk_rails_... (custom_label_id => custom_labels.id)
Constant Summary collapse
- COLOR_CODE =
Constants
'FF883E'.freeze
- SHORT_TYPE =
'add_on'.freeze
- TYPE_NAME =
'Add-On'.freeze
- REFUND_TYPE_PERCENTAGE =
:percentage- REFUND_TYPE_FIXED_AMOUNT =
:fixed_amount
Instance Method Summary collapse
-
#refund_amount_value ⇒ String, Integer
Define the add-on refund amount value based on the refund type If refund_type is 'percentage', append '%' to the refund_amount If refund_type is 'fixed_amount', format it as currency If refund_type is 'no_refund' or any other value, return 0.
Methods inherited from ApplicationRecord
Instance Method Details
#refund_amount_value ⇒ String, Integer
Define the add-on refund amount value based on the refund type If refund_type is 'percentage', append '%' to the refund_amount If refund_type is 'fixed_amount', format it as currency If refund_type is 'no_refund' or any other value, return 0
117 118 119 120 121 122 123 124 125 126 |
# File 'app/models/add_ons/add_on.rb', line 117 def refund_amount_value case refund_type.to_sym when REFUND_TYPE_PERCENTAGE "#{refund_amount}%" when REFUND_TYPE_FIXED_AMOUNT HhMoney.new(refund_amount, price_currency).default_format else 0 end end |