Skip to content

Commit

Permalink
fix stats to include donations
Browse files Browse the repository at this point in the history
remove addons, add donations
  • Loading branch information
beingmattlevy committed Aug 20, 2024
1 parent 3f2abb5 commit 613d456
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
5 changes: 3 additions & 2 deletions app/controllers/ticket_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def index
requests: requests.count,
adults: requests.sum(&:adults),
kids: requests.sum(&:kids),
donations: requests.sum(&:donation),
addon_passes: requests.sum(&:active_addon_pass_sum),
addon_camping: requests.sum(&:active_addon_camp_sum),
raised: requests.sum(&:price)
raised: requests.sum(&:cost)
}
end

@stats[:total] ||= Hash.new { |h, k| h[k] = 0 }
%i[requests adults kids addon_passes addon_camping raised].each do |measure|
%i[requests adults kids donations addon_passes addon_camping raised].each do |measure|
%i[pending awaiting_payment completed].each do |status|
@stats[:total][measure] += @stats[status][measure]
end
Expand Down
14 changes: 14 additions & 0 deletions app/views/ticket_requests/_table_ticket_request_statuses.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
%th.bg-dark-subtle.text-end Tickets
- if event.kid_ticket_price
%th.bg-dark-subtle.text-end Kids
- if event.allow_donations
%th.bg-dark-subtle.text-end Donations
- if event.active_event_addons_passes_count > 0
%th.bg-dark-subtle.text-end
=Addon::HUMANIZED_CATEGORIES[Addon::CATEGORY_PASS]
Expand All @@ -41,6 +43,10 @@
- if event.kid_ticket_price
%td.text-end.bg-success-subtle
%span= stats[:completed][:kids]
- if event.allow_donations
%td.text-end.bg-success-subtle
%span
= number_to_currency(stats[:completed][:donations], precision: 0)
- if event.active_event_addons_passes_count > 0
%td.text-end.bg-success-subtle
%span= stats[:completed][:addon_passes]
Expand All @@ -58,6 +64,9 @@
%td.text-end.bg-warning= stats[:pending][:adults]
- if event.kid_ticket_price
%td.text-end.bg-warning= stats[:pending][:kids]
- if event.allow_donations
%td.text-end.bg-warning
= number_to_currency(stats[:pending][:donations], precision: 0)
- if event.active_event_addons_passes_count > 0
%td.text-end.bg-warning= stats[:pending][:addon_passes]
- if event.active_event_addons_camping_count > 0
Expand All @@ -72,6 +81,9 @@
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:adults]
- if event.kid_ticket_price
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:kids]
- if event.allow_donations
%td.text-end.bg-warning-subtle
= number_to_currency(stats[:awaiting_payment][:donations], precision: 0)
- if event.active_event_addons_passes_count > 0
%td.text-end.bg-warning-subtle= stats[:awaiting_payment][:addon_passes]
- if event.active_event_addons_camping_count > 0
Expand All @@ -87,6 +99,8 @@
%td.bg-dark-subtle.text-end= stats[:total][:adults]
- if event.kid_ticket_price
%td.bg-dark-subtle.text-end= stats[:total][:kids]
- if event.allow_donations
%td.bg-dark-subtle.text-end= number_to_currency(stats[:total][:donations], precision: 0)
- if event.active_event_addons_passes_count > 0
%td.bg-dark-subtle.text-end= stats[:total][:addon_passes]
- if event.active_event_addons_camping_count > 0
Expand Down
13 changes: 7 additions & 6 deletions app/views/ticket_requests/_table_ticket_requests.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
%th.bg-dark-subtle.text-end.optional-medium Tickets
- if event.kid_ticket_price
%th.bg-dark-subtle.text-end.optional-medium Kids
- if event.active_event_addons?
%th.bg-dark-subtle.text-end.optional-medium Addons
- if event.allow_donations
%th.bg-dark-subtle.text-end.optional-medium Donation
%th.bg-dark-subtle.text-end Total
%th.bg-dark-subtle.text-end.optional-medium Date Requested
%th.bg-dark-subtle.text-center Status
Expand Down Expand Up @@ -57,14 +57,15 @@
- if event.kid_ticket_price
%td.align-content-center.text-end.optional-medium= ticket_request.kids
- if event.active_event_addons?
%td.align-content-center.text-end.optional-medium= ticket_request.active_addons_sum
- if event.allow_donations
%td.align-content-center.text-end
= number_to_currency(ticket_request.donation, precision: 0)
%td.align-content-center.text-end
%span{ class: ('label label-info' if ticket_request.special_price) }
= number_to_currency(ticket_request.price, precision: 0)
= number_to_currency(ticket_request.cost, precision: 0)
%td.align-content-center.text-end.optional-medium.text-nowrap.small
%td.align-content-center.text-end
= ticket_request.created_at.to_date
%td.align-content-center.text-center.ticket-status
Expand Down

0 comments on commit 613d456

Please sign in to comment.