Skip to content

Commit

Permalink
Fix IRR Calculator logic
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Mar 29, 2024
1 parent d21df12 commit 72e4230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/domain/models/irr_calculator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ class IRRCalculator {
required final double currentValue,
required final DateTime currentValueUpdatedOn,
}) {
final double years = currentValueUpdatedOn
.difference(futureDate)
.inDays / 365;
final num irrFactor = pow(1 + irr / 100, years.abs());

double years = currentValueUpdatedOn.difference(futureDate).inDays / 365;
if (years == 0) {
return currentValue;
} else if (years < 1 && years > 0) {
return currentValue / pow(1 + irr / 100, 1);
} else if (years > -1 && years < 0) {
return currentValue / pow(1 + irr / 100, -1);
} else {
return currentValue / irrFactor;
return currentValue / pow(1 + irr / 100, years);
}
}
}
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<!--
If you are serving your web app in a path other than the root, change the
Expand Down

0 comments on commit 72e4230

Please sign in to comment.