diff --git a/lib/domain/models/irr_calculator.dart b/lib/domain/models/irr_calculator.dart index caddd62..cad7137 100644 --- a/lib/domain/models/irr_calculator.dart +++ b/lib/domain/models/irr_calculator.dart @@ -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); } } } \ No newline at end of file diff --git a/web/index.html b/web/index.html index 5a5d519..c429d5f 100644 --- a/web/index.html +++ b/web/index.html @@ -1,5 +1,5 @@ - +