mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add turnover for admin
Admin can see the turnover amount for each ticket type.
This commit is contained in:
parent
0d70832f5b
commit
03c9f7deb1
3 changed files with 7 additions and 6 deletions
|
|
@ -496,7 +496,7 @@ class Conference < ActiveRecord::Base
|
||||||
if tickets && ticket_purchases
|
if tickets && ticket_purchases
|
||||||
tickets.each do |ticket|
|
tickets.each do |ticket|
|
||||||
result[ticket.title] = {
|
result[ticket.title] = {
|
||||||
'value' => ApplicationController.helpers.humanized_money(ticket.tickets_turnover).delete(',').to_i,
|
'value' => ApplicationController.helpers.humanized_money(ticket.tickets_turnover_total(ticket.id)).delete(',').to_i,
|
||||||
'color' => "\##{Digest::MD5.hexdigest(ticket.title)[0..5]}"
|
'color' => "\##{Digest::MD5.hexdigest(ticket.title)[0..5]}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,13 @@ class Ticket < ActiveRecord::Base
|
||||||
tickets.inject(0){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) }
|
tickets.inject(0){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def tickets_sold
|
def tickets_turnover_total(id)
|
||||||
ticket_purchases.paid.sum(:quantity)
|
tickets = TicketPurchase.where(ticket_id: id)
|
||||||
|
tickets.inject(0){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def tickets_turnover
|
def tickets_sold
|
||||||
tickets_sold * price
|
ticket_purchases.paid.sum(:quantity)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
%td
|
%td
|
||||||
= ticket.tickets_sold
|
= ticket.tickets_sold
|
||||||
%td
|
%td
|
||||||
= humanized_money_with_symbol ticket.tickets_turnover
|
= humanized_money_with_symbol ticket.tickets_turnover_total(ticket.id)
|
||||||
%td
|
%td
|
||||||
= ticket.registration_ticket? ? 'Yes' : 'No'
|
= ticket.registration_ticket? ? 'Yes' : 'No'
|
||||||
%td
|
%td
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue