Add amount paid
Amount paid colum is added to ticket purchase to keep the record of money paid by the user. It is added to physical_ticket#index to show admin, price paid by each user for each ticket.
This commit is contained in:
parent
3f3cdef520
commit
b761e83b45
5 changed files with 28 additions and 17 deletions
|
|
@ -52,7 +52,8 @@ class TicketPurchase < ActiveRecord::Base
|
||||||
purchase = new(ticket_id: ticket.id,
|
purchase = new(ticket_id: ticket.id,
|
||||||
conference_id: conference.id,
|
conference_id: conference.id,
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
quantity: quantity)
|
quantity: quantity,
|
||||||
|
amount_paid: ticket.price)
|
||||||
purchase.pay(nil) if ticket.price_cents.zero?
|
purchase.pay(nil) if ticket.price_cents.zero?
|
||||||
end
|
end
|
||||||
purchase
|
purchase
|
||||||
|
|
|
||||||
16
app/views/admin/physical_tickets/_physical_ticket.html.haml
Normal file
16
app/views/admin/physical_tickets/_physical_ticket.html.haml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
%tr
|
||||||
|
%td= physical_ticket.id
|
||||||
|
%td= physical_ticket.ticket.title
|
||||||
|
%td= physical_ticket.user.email
|
||||||
|
%td= humanized_money_with_symbol physical_ticket.ticket_purchase.amount_paid
|
||||||
|
%td
|
||||||
|
.btn-group
|
||||||
|
= link_to 'Show',
|
||||||
|
conference_physical_ticket_path(conference.short_title,
|
||||||
|
physical_ticket.token),
|
||||||
|
class: 'btn btn-primary'
|
||||||
|
= link_to 'Generate PDF',
|
||||||
|
conference_physical_ticket_path(conference.short_title,
|
||||||
|
physical_ticket.token,
|
||||||
|
format: :pdf),
|
||||||
|
class: 'button btn btn-default btn-info'
|
||||||
|
|
@ -21,23 +21,11 @@
|
||||||
%th ID
|
%th ID
|
||||||
%th Type
|
%th Type
|
||||||
%th User
|
%th User
|
||||||
|
%th Paid
|
||||||
%th Actions
|
%th Actions
|
||||||
%tbody
|
%tbody
|
||||||
- @physical_tickets.each do |physical_ticket|
|
- @physical_tickets.each do |physical_ticket|
|
||||||
%tr
|
= render "physical_ticket", physical_ticket: physical_ticket,
|
||||||
%td= physical_ticket.id
|
conference: @conference
|
||||||
%td= physical_ticket.ticket.title
|
|
||||||
%td= physical_ticket.user.email
|
|
||||||
%td
|
|
||||||
.btn-group
|
|
||||||
= link_to 'Show',
|
|
||||||
conference_physical_ticket_path(@conference.short_title,
|
|
||||||
physical_ticket.token),
|
|
||||||
class: 'btn btn-primary'
|
|
||||||
= link_to 'Generate PDF',
|
|
||||||
conference_physical_ticket_path(@conference.short_title,
|
|
||||||
physical_ticket.token,
|
|
||||||
format: :pdf),
|
|
||||||
class: 'button btn btn-default btn-info'
|
|
||||||
- else
|
- else
|
||||||
%h5 No Tickets sold!
|
%h5 No Tickets sold!
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddAmountPaidToTicketPurchases < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :ticket_purchases, :amount_paid, :float, default: 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170816203325) do
|
ActiveRecord::Schema.define(version: 20170924190528) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: :cascade do |t|
|
create_table "ahoy_events", force: :cascade do |t|
|
||||||
t.uuid "visit_id", limit: 16
|
t.uuid "visit_id", limit: 16
|
||||||
|
|
@ -504,6 +504,7 @@ ActiveRecord::Schema.define(version: 20170816203325) do
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "payment_id"
|
t.integer "payment_id"
|
||||||
t.integer "week"
|
t.integer "week"
|
||||||
|
t.float "amount_paid"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "ticket_scannings", force: :cascade do |t|
|
create_table "ticket_scannings", force: :cascade do |t|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue