Skip to content

Commit

Permalink
fix start value of Portfolio chart
Browse files Browse the repository at this point in the history
as portfolio.getTransactions is not sorted by default
Issue : #3969
  • Loading branch information
mierin12 authored and buchen committed May 20, 2024
1 parent 282970f commit 22b0977
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

Expand All @@ -29,6 +30,7 @@
import name.abuchen.portfolio.model.Client;
import name.abuchen.portfolio.model.Portfolio;
import name.abuchen.portfolio.model.PortfolioTransaction;
import name.abuchen.portfolio.model.Transaction;
import name.abuchen.portfolio.money.CurrencyConverter;
import name.abuchen.portfolio.money.CurrencyConverterImpl;
import name.abuchen.portfolio.money.ExchangeRateProviderFactory;
Expand Down Expand Up @@ -147,6 +149,8 @@ private void computeChart()
if (tx.isEmpty())
return;

Collections.sort(tx, Transaction.BY_DATE);

LocalDate now = LocalDate.now();
LocalDate start = tx.get(0).getDateTime().toLocalDate();
LocalDate end = tx.get(tx.size() - 1).getDateTime().toLocalDate();
Expand Down

0 comments on commit 22b0977

Please sign in to comment.