Skip to content
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

Can only update a competition's currency code if there are no unrefunded payments #10497

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dunkOnIT
Copy link
Contributor

Addresses #1356 - in draft because I've asked WCAT if this is something that's still needed.

If this is needed, then I think this implementation may be a bit thin. If we get the mega-edge-case of a user having been over-refunded, and another user still having a not-yet-refunded payment, the total amount paid for a competition will be $0 even though there are still two unresolved payments.

As such, it might be better to find a registration with a non-zero sum of its registration_payments

Also - it seems like we don't track the overall status of a payment (eg, whether it has been refunded) - we only infer this by summing registration_payments related to a given registration.

@gregorbg
Copy link
Member

Hm, the original issue also mentions another interesting edge case: Simple questions like "How much income does this competition have?" also rely on a (competition-)global currency. So even if there are no unrefunded payments, you would still sum up existing payments and then treat them as the new currency.
TL;DR I think we should just straight out forbid changing the currency as long as payments exist.

@gregorbg
Copy link
Member

gregorbg commented Feb 20, 2025

Another alternative would be to only allow updating the currency if all payments are fully refunded. If I have ten payments worth 1500 Something-Dollars each, and I refund every last one, then the sum evaluates to zero, which pretty much has the same meaning in any currency.

@dunkOnIT
Copy link
Contributor Author

dunkOnIT commented Feb 20, 2025

Another alternative would be to only allow updating the currency if all payments are fully refunded. If I have ten payments worth 1500 Something-Dollars each, and I refund every last one, then the sum evaluates to zero, which pretty much has the same meaning in any currency.

I think this is what I'm already doing? If you check the diff this is my logic to check for "unrefunded" payments:

registrations.joins(:registration_payments).sum('registration_payments.amount_lowest_denomination')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants