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

Customizable Host contributor information requirement #10935

Merged
merged 10 commits into from
Feb 7, 2025
Merged

Conversation

kewitz
Copy link
Contributor

@kewitz kewitz commented Jan 23, 2025

@kewitz kewitz self-assigned this Jan 23, 2025
Copy link

vercel bot commented Jan 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
opencollective-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 10:07am

Copy link
Member

@Betree Betree left a comment

Choose a reason for hiding this comment

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

The code looks clean, no blocker on my side 👍

Comment on lines +344 to +346
if (selectedProfile) {
totalAmount += selectedProfile.totalContributedToHost?.valueInCents || 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

Potential edge case here: we theoretically support tiers that have a different currency than the collective. I'm ok with just documenting that in an issue if we don't have the appetite for it now.

totalAmount is in tier currency, while totalContributedToHost is in collective currency.

select *
from "Tiers" t
INNER JOIN "Collectives" c ON t."CollectiveId" = c.id
WHERE c."deletedAt" IS NULL
AND t."deletedAt" IS NULL
AND c.currency != t.currency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not an issue, totalContributedToHost is calculated using Transactions.amountInHostCurrency and then converted to either collective or host currency (depending on what was requested).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the scenario I shared above is one where you have a USD collective with a JPY tier. In this case:

  • totalAmount, which comes from stepDetails, will use the tier currency (JPY)
  • totalContributedToHost will be calculated in host currency, then converted in collective currency (USD)
  • As a consequence, this function will end up doing:
  let totalAmount = getTotalYearlyAmount(stepDetails); // JPY5000
  const selectedProfile = profiles.find(p => p.account.id === stepProfile?.id);
  if (selectedProfile) {
    // JPY5000 += USD100 || 0;
    totalAmount += selectedProfile.totalContributedToHost?.valueInCents || 0;
  }

@kewitz kewitz merged commit 13b6740 into main Feb 7, 2025
19 checks passed
@kewitz kewitz deleted the refact/policies branch February 7, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants