calculateOpportunity.tsx 646 B

1234567891011121314
  1. // Calculate the potential opportunity to increase projectScore by increasing transactionScore to 100
  2. export const calculateOpportunity = (
  3. projectScore: number,
  4. totalCount: number,
  5. transactionScore: number,
  6. transactionCount: number
  7. ) => {
  8. const cumulativeProjectScore = projectScore * totalCount;
  9. const cumulativeComplementScore = (100 - transactionScore) * transactionCount;
  10. const cumulativeNewProjectScore = cumulativeProjectScore + cumulativeComplementScore;
  11. const newProjectScore = cumulativeNewProjectScore / totalCount;
  12. const opportunity = newProjectScore - projectScore;
  13. return Math.round(opportunity * 100) / 100;
  14. };