Skip to content

Use outstanding_entry_fees_with_donation instead of entry_fee_with_donation - #15406

Open
FinnIckler wants to merge 2 commits into
thewca:mainfrom
FinnIckler:fix-fee-calculation
Open

Use outstanding_entry_fees_with_donation instead of entry_fee_with_donation#15406
FinnIckler wants to merge 2 commits into
thewca:mainfrom
FinnIckler:fix-fee-calculation

Conversation

@FinnIckler

Copy link
Copy Markdown
Member

The non hotfix parts of #15405.

Adds some tests and removes dead code.

Comment thread app/models/registration.rb Outdated
def entry_fee_with_donation(iso_donation_amount = 0)
entry_fee + Money.new(iso_donation_amount, entry_fee.currency)
def outstanding_entry_fees_with_donation(iso_donation_amount = 0)
outstanding_entry_fees + Money.new(iso_donation_amount.clamp(0..), competition.currency_code)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the exact point of using outstanding_entry_fees as opposed to entry_fee here?

I think I understand the gist of it from the method names already, but why didn't this blow up into our faces already six million times?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very rare case which why I assumed this has never happened:

  1. User pays x money for their registration
  2. User actually has to pay y for their registration so needs to pay again
  3. It doesn't take into account what he has already paid

This can only happen when registration fee was changed or the user was partially refunded, but then is not eligible for that refund anymore.

Comment thread app/models/registration.rb Outdated
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