Skip to content

Commit

Permalink
Update irr composition
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jan 28, 2024
1 parent 9ee36f3 commit 0a744e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/presentation/dashboard_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class DashboardPresenter extends Presenter<DashboardViewState> {

for (var investment in investments) {
double investmentValue = investment.getValueOn(date: DateTime.now());
double investedAmount = investment.getTotalInvestedAmount(till: DateTime.now());
double investedAmount =
investment.getTotalInvestedAmount(till: DateTime.now());
totalInvestedAmount += investedAmount;
totalValueOfInvestment += investmentValue;
riskComposition.update(
Expand All @@ -30,9 +31,10 @@ class DashboardPresenter extends Presenter<DashboardViewState> {
investment.basketName ?? '-', (value) => value + investmentValue,
ifAbsent: () => investmentValue);
irrComposition.update((investment.getIRR()).roundToDouble(),
(value) => value + (investmentValue-investedAmount),
ifAbsent: () => (investmentValue-investedAmount));
(value) => value + (investmentValue - investedAmount),
ifAbsent: () => (investmentValue - investedAmount));
}
irrComposition.removeWhere((key, value) => value == 0);

updateViewState((viewState) {
viewState.invested = totalInvestedAmount;
Expand Down Expand Up @@ -90,7 +92,7 @@ class DashboardPresenter extends Presenter<DashboardViewState> {
totalValue += investment.getValueOn(date: DateTime.now());
totalInvested += investment.getTotalInvestedAmount(till: DateTime.now());
}

List<DateTime> investmentDates = dateInvestmentMap.keys.toList();
investmentDates.sort((a, b) => a.compareTo(b));

Expand Down
2 changes: 2 additions & 0 deletions lib/ui/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ class _DashboardPage
formatToPercentage(element.key, forceRound: true),
element.value));
}
contribution.add(MapEntry("Current Value", valueOfInvestment));
return SfCartesianChart(
primaryXAxis: const CategoryAxis(),
series: [
WaterfallSeries(
totalSumPredicate: (datum, index) => index == contribution.length-1,
dataSource: contribution,
xValueMapper: (data, _) => data.key,
yValueMapper: (data, _) => data.value,
Expand Down

0 comments on commit 0a744e0

Please sign in to comment.