Class: Admin::TicketTransactionsController
Constant Summary
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary
collapse
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
#append_info_to_payload
#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?
#setup_locale
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#download ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 95
def download
if params['ticket_transaction'].present?
permitted_parameters = params.require(:ticket_transaction).permit(
:start_date, :end_date, :restaurant_id, :date_type, :start_time, :end_time, :date_filter_type
)
if permitted_parameters[:start_date].present?
date_filter_type = permitted_parameters[:date_filter_type]
start_time = permitted_parameters[:start_time]
end_time = permitted_parameters[:end_time]
restaurant_id = permitted_parameters[:restaurant_id]
restaurant_group_id = permitted_parameters[:restaurant_group_id]
restaurant_id = nil if restaurant_group_id.present?
if date_filter_type != 'single' && (permitted_parameters[:start_date].blank? || permitted_parameters[:end_date].blank?)
render json: { message: 'Start date and End date must be present' }
return
end
if date_filter_type == 'single' && (start_time.blank? || end_time.blank?)
render json: { message: "Start time or end time can't be blank" }
return
end
start_date = Date.strptime(permitted_parameters.require(:start_date), '%m/%d/%Y')
end_date = if date_filter_type == 'single'
start_date
else
Date.strptime(
permitted_parameters.require(:end_date), '%m/%d/%Y'
)
end
emails = if Rails.env.development?
[SUPPORT_EMAIL]
else
[current_user&.email].compact
end
NotificationWorkers::VoucherReport.fix_queue_perform_async(
:hh_staff,
{
emails: emails,
restaurant_id: restaurant_id,
start_date: start_date,
end_date: end_date,
start_time: start_time,
end_time: end_time,
date_filter_type: date_filter_type,
},
)
render json: { message: 'System will send you an email to download the report file' }
else
render json: { message: 'Start date must be present' }
nil
end
else
render layout: nil
end
end
|
#find_ticket ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 31
def find_ticket
ticket_code = params[:ticket_code].strip.upcase
ticket = Ticket.find_by(ticket_code: "VC-#{ticket_code}")
if ticket.blank?
redirect_back(fallback_location: admin_ticket_transactions_path, alert: 'Voucher code not found')
nil
else
redirect_to admin_ticket_transaction_tickets_url(ticket.ticket_transaction_id, ticket_code: ticket.ticket_code)
end
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 10
def index
set_meta_tags title: 'Voucher Order List'
@ticket_transactions = TicketTransaction.where(for_locking_system: false).
includes(:restaurant, :booking_channel, :guest, ticket_bundles: :package_type).
order(created_at: :desc)
if params[:transaction_id].present?
@ticket_transactions = @ticket_transactions.where(
'ticket_transactions.id = :transaction_id OR ticket_transactions.vendor_order_id = :transaction_id',
transaction_id: params[:transaction_id],
)
end
per_page = params[:perPage].present? ? params[:perPage].to_i : 20
@pagy, @ticket_transactions = pagy @ticket_transactions, items: per_page
return unless stale? @ticket_transactions
@ticket_transactions = @ticket_transactions.includes(:user, :tickets)
end
|
#mark_as_paid ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 42
def mark_as_paid
charge = TicketTransaction.find(params.require(:id)).charges.pending_scope.last
if charge.blank?
redirect_back(fallback_location: admin_ticket_transactions_path, alert: 'Omise Charge ID is not found')
return
end
charge_id = charge.omise_charge_id
service = PaymentProcessService::MarkAsPaid.new(charge_id, 'by-admin')
if service.execute
respond_to do |format|
format.json do
render json: { success: true }
end
format.html do
redirect_back(fallback_location: admin_ticket_transactions_path, notice: 'success')
end
end
else
respond_to do |format|
format.json do
render json: { success: false }
end
format.html do
redirect_back(fallback_location: admin_ticket_transactions_path,
alert: "failed #{service.error_message_simple}")
end
end
end
end
|
#mark_tickets_as_active ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 84
def mark_tickets_as_active
transaction = TicketTransaction.find(params.require(:ticket_transaction_id))
transaction.mark_tickets_as_active!
transaction.mark_partner_tickets_as_sold!
transaction. = 'mark all tickets as active by admin'
transaction.save
redirect_back(fallback_location: admin_ticket_transaction_tickets_path(transaction.id),
notice: 'Successfully Activate all tickets')
end
|
#resend_email ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 74
def resend_email
transaction = TicketTransaction.find(params.require(:id))
UserMailer.ticket_confirmation(transaction.id).deliver_later!
OwnerMailer.ticket_confirmation(transaction.id).deliver_later!
redirect_back(fallback_location: admin_ticket_transactions_path,
notice: 'success re-send email for customer and restaurant owner')
end
|
#show ⇒ Object
6
7
8
|
# File 'app/controllers/admin/ticket_transactions_controller.rb', line 6
def show
@ticket_transaction = TicketTransaction.find(params.require(:id))
end
|