Commit bc3f3b7
committed
fix: prevent Infinity in effectiveAnnualReturn when initialBalance is 0
When initialBalance is 0, the effectiveAnnualReturn calculation was
dividing by zero, resulting in Infinity. Now handles this edge case by:
- Using totalContributions as the base when initialBalance is 0
- Returning 0 when both initialBalance and totalContributions are 0
- Maintaining original calculation for non-zero initial balances
This ensures accurate return metrics for accounts starting from zero.1 parent 488e314 commit bc3f3b7
2 files changed
+11
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
549 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
550 | 558 | | |
551 | 559 | | |
552 | 560 | | |
| |||
0 commit comments