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

RecurringContributions: Fix wrong amounts being displayed #5245

Merged
merged 1 commit into from Oct 15, 2020

Conversation

Betree
Copy link
Member

@Betree Betree commented Oct 15, 2020

Fix an issue that was reported by user for https://opencollective.com/lea-sonda-and-ira-jaffe#section-recurring-contributions

The "Amount contributed" displayed was incorrect, showing total amount + platform tip as the total amount. For this user, it was displaying $120 instead of $110:

image


There's another issue on the "Contributed to date" amount, but it's API side so we'll do that separately.

@Betree Betree self-assigned this Oct 15, 2020
@render
Copy link

render bot commented Oct 15, 2020

@vercel
Copy link

vercel bot commented Oct 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/opencollective/opencollective-frontend/lc8fz7sxc
✅ Preview: https://opencollective-frontend-git-fix-recurring-contribution-amount.opencollective.vercel.app

<FormattedMoneyAmount
amount={contribution.platformContributionAmount.value * 100}
amount={contribution.platformContributionAmount.valueInCents}
Copy link
Member Author

Choose a reason for hiding this comment

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

@sbinlondon I replaced all the value * 100 by valueInCents, it's simpler and it avoids an issue with float numbers precision. Let's imagine that someone is contributing $1.10 per month, now please try and type 1.10 * 100 in your console and check the result. What you'll see is the reason why we avoid dealing with floats in general 🙂

For more info about that: https://floating-point-gui.de/

currency={contribution.amount.currency}
showCurrencyCode={false}
precision={0}
precision="auto"
Copy link
Member Author

Choose a reason for hiding this comment

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

We want to avoid truncating the number, this was showing:

$17.25 USD / month
($15 + $2)

precision="auto" is a good fit for that, it hides the ,00 if there's no decimals but show them if there's any.

@Betree Betree marked this pull request as ready for review October 15, 2020 07:59
@Betree Betree merged commit b3c28a7 into master Oct 15, 2020
@Betree Betree deleted the fix/recurring-contribution-amount branch October 15, 2020 08:48
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.

None yet

1 participant