thewca / worldcubeassociation.org

All of the code that runs on worldcubeassociation.org
https://www.worldcubeassociation.org/
GNU General Public License v3.0
330 stars 176 forks source link

Autofill refund amount with the correct amount from refund policy #7070

Open sarahstrong314 opened 2 years ago

sarahstrong314 commented 2 years ago

Is your feature request related to a problem? Please describe. When an organizer goes to refunds a competitor, the refund amount is autofilled with the full amount instead of the expected amount.

Describe the solution you'd like The refund amount should be autofilled the expected amount. For example, if the refund policy is that competitors get 95% of their registration fee back as long as they cancel their registration by a specific date, the amount that is shown by default should be 95% of the registration fee up until that specific date. This is more ideal than the current way since the organizer can always refund more if needed (e.g. if the competitor didn't qualify or make it off the waiting list then it would be a 100% refund), but they cannot easily get funds back that have already been refunded. It would also prevent the organizer from needing to do the calculation themself and potentially making a calculation error.

JonEsparaz commented 2 years ago

@dunkOnIt can I take on this issue please? Also, duplicate of #5162.

dunkOnIT commented 2 years ago

@JonEsparaz by all means! Thanks for the ping re duplication - in my view the "cancel registration" button is out of scope, so I'm creating a new issue for it. If it proves to be easy/logical to implement as part of this, feel free to, but don't go out of your way in my opinion.

dunkOnIT commented 2 years ago

Issue text from #5162, which was closed in favour of this issue:

I don't really like the idea of organizers/delegates calculating the percentage because there is a chance of incorrect calculation. Additionally, one can always mistype. I think that having the default refund amount follow the policy makes the most sense.

We should obviously still keep the ability to manually edit the refund amount (for example, competitors on the waitlist that have paid in full, etc.). Just makes it easier to hit the "Refund" button when dealing with a cancelled registration :/

Additionally, maybe have a cancel registration button that's separate from a refund button? The cancel registration button would automatically delete the competitor's registration and would refund the correct percentage. This could be confusing though as refund and cancelling might not be as distinct as I think it is (or the distinction may be less obvious to some people).

JonEsparaz commented 2 years ago

I haven't had much time to work on this, but I've had some issues with testing (a couple things I need to figure out with the unit tests and haven't been able to manual test locally).

I might switch to #7059 in the meantime as that would be more useful for competition organizers in my area.

dunkOnIT commented 2 years ago

@JonEsparaz am I understanding correctly that the PR has been written, you're just trying to get tests to pass?

If so my suggestion would be that you submit the PR with failing tests (I don't see one linked on this unless I'm being silly), and we can ping some WST members for their input - as we wouldn't want to lose work that's close to completion!

Please let me know if I'm misunderstanding though.

JonEsparaz commented 2 years ago

@dunkOnIT the tests I wrote aren't passing and I wasn't able to manually test locally since Stripe is not active in the local env.

tbh, I haven’t done anything substantial (someone on the WST could likely recreate my work in a few mins), but here’s a branch with very rough work: https://github.com/JonEsparaz/worldcubeassociation.org/tree/wip/refund-percentage