Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance trade activity widget - allows to filter by specific transaction types #3600

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ public class Messages extends NLS
public static String LabelAllSecurities;
public static String LabelAllTrades;
public static String LabelAllTransactions;
public static String LabelAllInbound;
public static String LabelAllOutbound;
public static String LabelAssetChart;
public static String LabelAvailableAttributes;
public static String LabelAverageHoldingPeriod;
Expand All @@ -522,6 +524,7 @@ public class Messages extends NLS
public static String LabelBeforeTaxAndFees;
public static String LabelBenchmarks;
public static String LabelBiggerSize;
public static String LabelBuysOnly;
public static String LabelEarningsByTaxonomy;
public static String LabelCapitalGains;
public static String LabelCategoryOtherMovements;
Expand Down Expand Up @@ -760,6 +763,7 @@ public class Messages extends NLS
public static String LabelSelectedTransactions;
public static String LabelSelectYear;
public static String LabelSelectYearSince;
public static String LabelSellsOnly;
public static String LabelSemiVolatility;
public static String LabelSettings;
public static String LabelShowOnlyOneYear;
Expand Down Expand Up @@ -830,6 +834,7 @@ public class Messages extends NLS
public static String LabelTradesTurnoverRate;
public static String LabelTradingActivityChart;
public static String LabelTransactionCount;
public static String LabelTransactionFilter;
public static String LabelTransactions;
public static String LabelTransferals;
public static String LabelTransfer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,10 @@ LabelAllTrades = All trades

LabelAllTransactions = All transactions

LabelAllInbound = Inbound deliveries and buys

LabelAllOutbound = Outbound deliveries and sells

LabelAssetChart = Statement of Assets - Chart

LabelAvailableAttributes = Add new attribute
Expand All @@ -1056,6 +1060,8 @@ LabelBenchmarks = Benchmarks

LabelBiggerSize = Bigger

LabelBuysOnly = Buys only

LabelCapitalGains = Capital Gains

LabelCategoryOtherMovements = Other Movements
Expand Down Expand Up @@ -1596,6 +1602,8 @@ LabelSelectYearSince = Since

LabelSelectedTransactions = Selected transactions

LabelSellsOnly = Sells only

LabelSemiVolatility = Semivariance

LabelSettings = Settings
Expand Down Expand Up @@ -1662,6 +1670,8 @@ LabelTradingActivityChart = Trading activity

LabelTransactionCount = {0} transactions

LabelTransactionFilter = Transaction filter

LabelTransactions = Transactions

LabelTransfer = Transfer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@ LabelAllTrades = Alle Trades

LabelAllTransactions = Alle Buchungen

LabelAllInbound = Einlieferungen und K\u00E4ufe

LabelAllOutbound = Auslieferungen und Verk\u00E4ufe

LabelAssetChart = Verm\u00F6gensaufstellung - Diagramm

LabelAvailableAttributes = Neues Attribut hinzuf\u00FCgen
Expand All @@ -1049,6 +1053,8 @@ LabelBenchmarks = Benchmarks

LabelBiggerSize = Gr\u00F6\u00DFer

LabelBuysOnly = Nur K\u00E4ufe

LabelCapitalGains = Kurserfolge

LabelCategoryOtherMovements = Sonstige Bewegungen
Expand Down Expand Up @@ -1589,6 +1595,8 @@ LabelSelectYearSince = Seit

LabelSelectedTransactions = Ausgew\u00E4hlte Buchungen

LabelSellsOnly = Nur Verk\u00E4ufe

LabelSemiVolatility = Semivolatilit\u00E4t

LabelSettings = Einstellungen
Expand Down Expand Up @@ -1655,6 +1663,8 @@ LabelTradingActivityChart = Handelsaktivit\u00E4t

LabelTransactionCount = {0} Buchungen

LabelTransactionFilter = Transaktionsfilter

LabelTransactions = Buchungen

LabelTransfer = Umbuchung
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,38 @@ public ChartTypeConfig(WidgetDelegate<?> delegate)
}
}

public enum TransactionFilter
{

ALL_TRANSACTIONS(Messages.LabelAllTransactions), //
BUYS_ONLY(Messages.LabelBuysOnly), //
SELLS_ONLY(Messages.LabelSellsOnly), //
ALL_INBOUND(Messages.LabelAllInbound), //
ALL_OUTBOUND(Messages.LabelAllOutbound);

private String label;

private TransactionFilter(String label)
{
this.label = label;
}

@Override
public String toString()
{
return label;
}
}

static class TransactionFilterConfig extends EnumBasedConfig<TransactionFilter>
{
public TransactionFilterConfig(WidgetDelegate<?> delegate)
{
super(delegate, Messages.LabelTransactionFilter, TransactionFilter.class, Dashboard.Config.TRANSACTION_FILTER,
Policy.EXACTLY_ONE);
}
}

public static class TimeGridPaintListener implements ICustomPaintListener
{
private static final int INDENT = 5;
Expand Down Expand Up @@ -178,6 +210,7 @@ public ActivityWidget(Widget widget, DashboardData data)
addConfig(new ReportingPeriodConfig(this));
addConfig(new ClientFilterConfig(this));
addConfig(new ChartTypeConfig(this));
addConfig(new TransactionFilterConfig(this));
addConfig(new ChartHeightConfig(this));

this.converter = data.getCurrencyConverter();
Expand Down Expand Up @@ -311,16 +344,43 @@ public void update(List<TransactionPair<?>> transactions)
.collect(Collectors.toList()).toArray(new String[0]));
}

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.BUY, Colors.ICON_BLUE);
if (this.isAllTransactions())
{
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.BUY, Colors.ICON_BLUE);

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_INBOUND,
Colors.brighter(Colors.ICON_BLUE));

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.SELL, Colors.ICON_ORANGE);

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_OUTBOUND,
Colors.brighter(Colors.ICON_ORANGE));
}

if (this.isAllInbound())
{
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.BUY, Colors.ICON_BLUE);

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_INBOUND,
Colors.brighter(Colors.ICON_BLUE));
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_INBOUND,
Colors.brighter(Colors.ICON_BLUE));
}

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.SELL, Colors.ICON_ORANGE);
if (this.isAllOutbound())
{
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.SELL, Colors.ICON_ORANGE);

createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_OUTBOUND,
Colors.brighter(Colors.ICON_ORANGE));
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.DELIVERY_OUTBOUND,
Colors.brighter(Colors.ICON_ORANGE));
}
if (this.isBuysOnly())
{
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.BUY, Colors.ICON_BLUE);
}

if (this.isSellsOnly())
{
createSeries(chartType, interval, transactions, PortfolioTransaction.Type.SELL, Colors.ICON_ORANGE);
}
}
finally
{
Expand Down Expand Up @@ -404,4 +464,39 @@ private boolean isAggregateByYear()

return chartType == ChartType.SUM_BY_YEAR || chartType == ChartType.COUNT_BY_YEAR;
}

private boolean isAllTransactions()
{
TransactionFilter transactionFilter = get(TransactionFilterConfig.class).getValue();

return transactionFilter == transactionFilter.ALL_TRANSACTIONS;
}

private boolean isBuysOnly()
{
TransactionFilter transactionFilter = get(TransactionFilterConfig.class).getValue();

return transactionFilter == transactionFilter.BUYS_ONLY;
}

private boolean isAllInbound()
{
TransactionFilter transactionFilter = get(TransactionFilterConfig.class).getValue();

return transactionFilter == transactionFilter.ALL_INBOUND;
}

private boolean isSellsOnly()
{
TransactionFilter transactionFilter = get(TransactionFilterConfig.class).getValue();

return transactionFilter == transactionFilter.SELLS_ONLY;
}

private boolean isAllOutbound()
{
TransactionFilter transactionFilter = get(TransactionFilterConfig.class).getValue();

return transactionFilter == transactionFilter.ALL_OUTBOUND;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum Config
{
REPORTING_PERIOD, DATA_SERIES, SECONDARY_DATA_SERIES, CONFIG_UUID, AGGREGATION, EXCHANGE_RATE_SERIES, //
COLOR_SCHEMA, LAYOUT, HEIGHT, EARNING_TYPE, NET_GROSS, CLIENT_FILTER, CALCULATION_METHOD, METRIC, //
ATTRIBUTE_UUID, URL, SHOW_Y_AXIS, TAXONOMY, FLAG_INCLUDE_UNASSIGNED, SORT_DIRECTION, START_YEAR;
ATTRIBUTE_UUID, URL, SHOW_Y_AXIS, TAXONOMY, FLAG_INCLUDE_UNASSIGNED, SORT_DIRECTION, START_YEAR, TRANSACTION_FILTER;
}

public static final class Column
Expand Down