Class: HhPackage::PackageAttr

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Includes:
IdentityCache
Defined in:
app/models/hh_package/package_attr.rb

Constant Summary collapse

DEFAULT_MIN_SEAT =

Constants

1
DEFAULT_MAX_SEAT =
1_000_000
REFUND_TYPE_PERCENTAGE =
:percentage
REFUND_TYPE_FIXED_AMOUNT =
:fixed_amount

Instance Method Summary collapse

Methods inherited from ApplicationRecord

sync_carrierwave_url

Instance Method Details

#limit_per_user_per_day_configObject

dipake untuk menentukan apakah user boleh membeli suatu package lebih dari jumlah tertentu. Ini digunakan ketika ada diskon besar besaran oleh restoran mereka mau membatasi berapa kali user boleh membeli suatu package dalam satu hari



138
139
140
141
142
143
144
# File 'app/models/hh_package/package_attr.rb', line 138

def limit_per_user_per_day_config
  if limit_per_user_per_day.zero?
    Float::INFINITY
  else
    limit_per_user_per_day
  end
end

#refund_amount_valueString, Integer

Define the package refund amount based on package 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

Returns:

  • (String, Integer)

    formatted refund amount



151
152
153
154
155
156
157
158
159
160
# File 'app/models/hh_package/package_attr.rb', line 151

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