Class: TicketGroup
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- TicketGroup
- Extended by:
- Enumerize
- Includes:
- IdentityCache
- Defined in:
- app/models/ticket_group.rb
Constant Summary collapse
- V_LABELS =
{ hide: 'Hide In Store Page', show: 'Show In Store Page', vendor: 'Show for Vendors Only', }.freeze
Instance Attribute Summary collapse
-
#visibility ⇒ String
We use this column to toggle visibility of ticket group in our restaurant store page.
Instance Method Summary collapse
-
#force_update_witness_quota ⇒ Object
allow admin to update ticket group quantity without checking availability.
- #is_full? ⇒ Boolean
- #limit_user_should_be_unchecked_if_show_in_vendors_is_checked ⇒ Object
- #quota ⇒ Object
- #will_oversold?(new_transaction_quantity) ⇒ Boolean
Methods inherited from ApplicationRecord
Instance Attribute Details
#visibility ⇒ String
Returns we use this column to toggle visibility of ticket group in our restaurant store page. the valid value is `show` or `hide`.
65 66 67 68 |
# File 'app/models/ticket_group.rb', line 65 translates :name, :description, touch: true, fallbacks_for_empty_translations: true |
Instance Method Details
#force_update_witness_quota ⇒ Object
allow admin to update ticket group quantity without checking availability
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'app/models/ticket_group.rb', line 143 def force_update_witness_quota total_orders = TicketBundle.joins(ticket_transaction: :charges). where(ticket_transactions: { for_locking_system: false, active: true }, externals_omise_charges: { status: 'successful', }).where(ticket_group_id: id).sum(:quantity) self.total_orders = total_orders if save qw = InvQuotaWitness.new qw.update_restaurant_ticket_group_list(restaurants) qw.delete_keys(id) qw.generate_by_quota(id, quota, self) else APMErrorHandler.report("Failed to update total_orders for TicketGroup #{id}: #{errors..join(', ')}") end end |
#is_full? ⇒ Boolean
161 162 163 |
# File 'app/models/ticket_group.rb', line 161 def is_full? total_orders.to_i >= quantity.to_i end |
#limit_user_should_be_unchecked_if_show_in_vendors_is_checked ⇒ Object
131 132 133 134 135 136 |
# File 'app/models/ticket_group.rb', line 131 def limit_user_should_be_unchecked_if_show_in_vendors_is_checked if visibility == 'vendor' && limit_user errors.add(:base, "Validation Error: Visibility is 'Show for Vendors Only' so you need to uncheck 'Limit User' option") end end |
#quota ⇒ Object
138 139 140 |
# File 'app/models/ticket_group.rb', line 138 def quota quantity.to_i - total_orders.to_i end |
#will_oversold?(new_transaction_quantity) ⇒ Boolean
165 166 167 |
# File 'app/models/ticket_group.rb', line 165 def will_oversold?(new_transaction_quantity) total_orders.to_i + new_transaction_quantity > quantity.to_i end |