Skip to content

Commit

Permalink
Enable performance calculation without taxes
Browse files Browse the repository at this point in the history
Issue: #859
  • Loading branch information
buchen committed Dec 17, 2018
1 parent 4266a31 commit e8eca42
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ public class Messages extends NLS
public static String LabelPortfolioPerformanceFile;
public static String LabelPortfolios;
public static String LabelPortfolioTimeMachine;
public static String LabelPreTax;
public static String LabelQuote;
public static String LabelQuoteFeed;
public static String LabelQuoteFeedProvider;
Expand Down Expand Up @@ -591,6 +592,7 @@ public class Messages extends NLS
public static String MenuConfigureChart;
public static String MenuConfigureCurrentDashboard;
public static String MenuConfigureDashboards;
public static String MenuConfigureView;
public static String MenuConfirmDeleteAllTransactions;
public static String MenuConvertToBuy;
public static String MenuConvertToInboundDelivery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,8 @@ LabelPortfolioTimeMachine = Portfolio Time Machine
LabelPortfolios = Securities Accounts
LabelPreTax = Pre tax
LabelQuote = Quote
LabelQuoteFeed = Quote Feed
Expand Down Expand Up @@ -1183,6 +1185,8 @@ MenuConfigureCurrentDashboard = Configure dashboard
MenuConfigureDashboards = Configure dashboards
MenuConfigureView = Configure view
MenuConfirmDeleteAllTransactions = Delete all transactions of securities {0}?
MenuConvertToBuy = Convert to buy transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ LabelPortfolioTimeMachine = Portfolio Time Machine

LabelPortfolios = Depots

LabelPreTax = Vor Steuern

LabelQuote = Kursnotierung

LabelQuoteFeed = Kurslieferant
Expand Down Expand Up @@ -1179,6 +1181,8 @@ MenuConfigureCurrentDashboard = Dashboard konfigurieren

MenuConfigureDashboards = Dashboards konfigurieren

MenuConfigureView = Ansicht konfigurieren

MenuConfirmDeleteAllTransactions = Alle Buchungen f\u00FCr Wertpapier {0} l\u00F6schen?

MenuConvertToBuy = In Kaufbuchung umwandeln
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot;
import name.abuchen.portfolio.snapshot.GroupEarningsByAccount;
import name.abuchen.portfolio.snapshot.ReportingPeriod;
import name.abuchen.portfolio.snapshot.filter.WithoutTaxesFilter;
import name.abuchen.portfolio.ui.Images;
import name.abuchen.portfolio.ui.Messages;
import name.abuchen.portfolio.ui.selection.SecuritySelection;
Expand All @@ -70,6 +71,8 @@ public class PerformanceView extends AbstractHistoricView

private ClientFilterDropDown clientFilter;

private boolean preTax = false;

private TreeViewer calculation;
private StatementOfAssetsViewer snapshotStart;
private StatementOfAssetsViewer snapshotEnd;
Expand All @@ -93,6 +96,16 @@ protected void addButtons(ToolBar toolBar)
PerformanceView.class.getSimpleName(), filter -> notifyModelUpdated());

new ExportDropDown(toolBar); // NOSONAR

AbstractDropDown.create(toolBar, Messages.MenuConfigureView, Images.CONFIG.image(), SWT.NONE, manager -> {
SimpleAction action = new SimpleAction(Messages.LabelPreTax, a -> {
this.preTax = !this.preTax;
reportingPeriodUpdated();
});

action.setChecked(this.preTax);
manager.add(action);
});
}

@Override
Expand All @@ -101,6 +114,10 @@ public void reportingPeriodUpdated()
ReportingPeriod period = getReportingPeriod();
CurrencyConverter converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());
Client filteredClient = clientFilter.getSelectedFilter().filter(getClient());

if (preTax)
filteredClient = new WithoutTaxesFilter().filter(filteredClient);

ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(filteredClient, converter, period);

try
Expand Down Expand Up @@ -275,7 +292,7 @@ public Font getFont(Object element)

calculation.addSelectionChangedListener(event -> {
Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selection != null && selection instanceof ClientPerformanceSnapshot.Position
if (selection instanceof ClientPerformanceSnapshot.Position
&& ((ClientPerformanceSnapshot.Position) selection).getSecurity() != null)
selectionService.setSelection(new SecuritySelection(getClient(),
((ClientPerformanceSnapshot.Position) selection).getSecurity()));
Expand Down

0 comments on commit e8eca42

Please sign in to comment.