Skip to content

Commit

Permalink
Condense things a bit, fix logic with with tallying
Browse files Browse the repository at this point in the history
  • Loading branch information
Edge7481 committed Apr 5, 2024
1 parent 2968d9f commit b44006e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/osem-tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function update_price($this){

// Calculate total price
var total = 0;
$('.total_row').each(function() {
total += parseFloat($(this).text().trim());
$('span[id^="total_row_"]').each(function() {
total += parseFloat($(this).text());
});
$('#total-currency-symbol').text(conversionData.symbol);
$('#total-price').text(total.toFixed(2));
Expand Down
9 changes: 2 additions & 7 deletions app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ def load_tickets

def load_currency_conversions
@currency_conversions = @conference.currency_conversions
@currencies = [@conference.tickets.first.price_currency]
@currencies |= @currency_conversions.map(&:to_currency).uniq
@currencies = [@conference.tickets.first.price_currency] | @currency_conversions.map(&:to_currency).uniq
@currency_meta = @currencies.map do |currency|
currency_conversion = @currency_conversions.find { |c| c.to_currency == currency }
rate = if currency_conversion
currency_conversion.rate
else
1
end
rate = currency_conversion ? currency_conversion.rate : 1
symbol = Money::Currency.new(currency).symbol
{ currency: currency, rate: rate, symbol: symbol }
end
Expand Down

0 comments on commit b44006e

Please sign in to comment.