-
Notifications
You must be signed in to change notification settings - Fork 9
Add currency conversion donut chart to tickets sold page #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b9df28f
add new feature for counting the total sales for each currency
zhouyijun111 d8670ab
Add x86_64-linux platform to Gemfile.lock for CI
zhouyijun111 0de884b
Remove requirement that was breaking computer, rename README files
Ethan-Stone1 75d599e
Merge from main
Ethan-Stone1 b5d923a
Merge pull request #48 from cs169/feature/currency-donut-chart
cycomachead 09db14c
Add Bluejay spec
Ethan-Stone1 a1bfde3
Merge
Ethan-Stone1 a034461
Fix name in info.yml file
Ethan-Stone1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| project: | ||
| name: 'snapcon' # Your project name, e.g. Cue-to-cue | ||
| owner: 'CS169L-26' # Do not change | ||
| teamId: '04' # Your team number, e.g. 02 | ||
| identities: | ||
| heroku: 'https://sp26-04-snapcon.herokuapp.com' # Your Heroku app URL | ||
| members: | ||
| member1: # Add all project members | ||
| name: 'Ethan' # Member 1 name | ||
| surname: 'Stone' # Member 1 last name | ||
| githubUsername: 'Ethan-Stone1' # Member 1 GitHub username | ||
| herokuEmail: 'ethanstone@berkeley.edu' # Member 1 Heroku username | ||
| member2: | ||
| name: 'Benjamin' | ||
| surname: 'Sikes' | ||
| githubUsername: 'sikesbc' | ||
| herokuEmail: 'bcsikes@berkeley.edu' | ||
| member3: | ||
| name: 'Yijun' | ||
| surname: 'Zhou' | ||
| githubUsername: 'zhouyijun111' | ||
| herokuEmail: 'zhouyijun@berkeley.edu' | ||
| member4: | ||
| name: 'Xinwei' | ||
| surname: 'Li' | ||
| githubUsername: 'li-xinwei' | ||
| herokuEmail: 'xinweili@berkeley.edu' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| namespace :data do | ||
| desc 'Add demo paid ticket sales (USD + EUR) for testing "Gross ticket sales by currency" chart. Usage: CONF=123123 rake data:demo_ticket_sales' | ||
| task demo_ticket_sales: :environment do | ||
| short_title = ENV['CONF'] || Conference.first&.short_title | ||
| conference = Conference.find_by(short_title: short_title) | ||
| unless conference | ||
| puts "Conference not found. Set CONF=short_title (e.g. CONF=123123) or create a conference first." | ||
| next | ||
| end | ||
|
|
||
| base_currency = conference.tickets.first&.price_currency || 'USD' | ||
| # Ensure we have a non-free ticket for paid sales | ||
| paid_ticket = conference.tickets.find_by(registration_ticket: false).presence || conference.tickets.first | ||
| unless paid_ticket | ||
| puts "No ticket found for conference #{short_title}." | ||
| next | ||
| end | ||
|
|
||
| # If ticket is free, create a paid "Supporter" ticket | ||
| if paid_ticket.price_cents.zero? | ||
| paid_ticket = conference.tickets.create!( | ||
| title: 'Supporter', | ||
| price_cents: 2_000, | ||
| price_currency: base_currency, | ||
| description: 'Demo paid ticket', | ||
| registration_ticket: false, | ||
| visible: true | ||
| ) | ||
| puts "Created paid ticket: #{paid_ticket.title} (#{Money.new(paid_ticket.price_cents, base_currency).format})" | ||
| end | ||
|
|
||
| # Add EUR conversion so "enabled currencies" includes EUR | ||
| if base_currency == 'USD' && conference.currency_conversions.find_by(from_currency: 'USD', to_currency: 'EUR').blank? | ||
| conference.currency_conversions.create!(from_currency: 'USD', to_currency: 'EUR', rate: 0.92) | ||
| puts 'Added USD -> EUR conversion (rate 0.92).' | ||
| end | ||
|
|
||
| user1 = User.first || User.create!(email: 'demo1@example.com', name: 'Demo User 1', password: 'password123456', confirmed_at: Time.current) | ||
| user2 = User.second || User.create!(email: 'demo2@example.com', name: 'Demo User 2', password: 'password123456', confirmed_at: Time.current) | ||
|
|
||
| # Payment + purchase in USD | ||
| payment_usd = Payment.create!(conference: conference, user: user1, currency: 'USD', status: :success, amount: 5_000) | ||
| purchase_usd = TicketPurchase.new( | ||
| conference: conference, user: user1, ticket: paid_ticket, | ||
| quantity: 2, currency: 'USD', amount_paid_cents: 2_500, amount_paid: 25.0 | ||
| ) | ||
| purchase_usd.payment = payment_usd | ||
| purchase_usd.save!(validate: false) | ||
| purchase_usd.update_columns(paid: true) | ||
| purchase_usd.quantity.times { purchase_usd.physical_tickets.create! } | ||
| puts "Created USD purchase: 2 x #{paid_ticket.title} = $50 (5000 cents)." | ||
|
|
||
| # Payment + purchase in EUR (if base is USD and we have conversion) | ||
| if conference.currency_conversions.exists?(to_currency: 'EUR') | ||
| payment_eur = Payment.create!(conference: conference, user: user2, currency: 'EUR', status: :success, amount: 4_600) | ||
| purchase_eur = TicketPurchase.new( | ||
| conference: conference, user: user2, ticket: paid_ticket, | ||
| quantity: 1, currency: 'EUR', amount_paid_cents: 4_600, amount_paid: 46.0 | ||
| ) | ||
| purchase_eur.payment = payment_eur | ||
| purchase_eur.save!(validate: false) | ||
| purchase_eur.update_columns(paid: true) | ||
| purchase_eur.physical_tickets.create! | ||
| puts "Created EUR purchase: 1 x #{paid_ticket.title} = 46 EUR (4600 cents)." | ||
| end | ||
|
|
||
| puts "Done. Refresh the Ticket Purchases page to see the 'Gross ticket sales by currency' chart." | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a spurious space, but nbd.