use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class AccountContextMenu method menuAboutToShow.
public void menuAboutToShow(IMenuManager manager, final Account account, final Security security) {
if (account == null)
return;
for (final AccountTransaction.Type type : //
EnumSet.of(//
AccountTransaction.Type.DEPOSIT, //
AccountTransaction.Type.REMOVAL, //
AccountTransaction.Type.TAXES, //
AccountTransaction.Type.TAX_REFUND, //
AccountTransaction.Type.FEES, //
AccountTransaction.Type.FEES_REFUND, //
AccountTransaction.Type.INTEREST, AccountTransaction.Type.INTEREST_CHARGE)) {
// $NON-NLS-1$
new OpenDialogAction(owner, type.toString() + "...").type(//
AccountTransactionDialog.class).parameters(//
type).with(//
account).with(//
security).addTo(manager);
}
manager.add(new Separator());
//
new OpenDialogAction(owner, Messages.AccountMenuTransfer).type(//
AccountTransferDialog.class).with(//
account).addTo(manager);
manager.add(new Separator());
if (!owner.getClient().getActivePortfolios().isEmpty() && !owner.getClient().getSecurities().isEmpty()) {
// preselect a portfolio that has the current
// account as a reference account
final Portfolio[] portfolio = new Portfolio[1];
for (Portfolio p : owner.getClient().getActivePortfolios()) {
if (p.getReferenceAccount().equals(account)) {
portfolio[0] = p;
break;
}
}
// $NON-NLS-1$
new OpenDialogAction(owner, Messages.SecurityMenuBuy + "...").type(//
SecurityTransactionDialog.class).parameters(//
PortfolioTransaction.Type.BUY).with(//
portfolio[0]).with(//
security).addTo(manager);
// $NON-NLS-1$
new OpenDialogAction(owner, Messages.SecurityMenuSell + "...").type(//
SecurityTransactionDialog.class).parameters(//
PortfolioTransaction.Type.SELL).with(//
portfolio[0]).with(//
security).addTo(manager);
// $NON-NLS-1$
new OpenDialogAction(owner, Messages.SecurityMenuDividends + "...").type(//
AccountTransactionDialog.class).parameters(//
AccountTransaction.Type.DIVIDENDS).with(//
account).with(//
security).addTo(manager);
}
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class ClientFilterMenu method buildItem.
private Item buildItem(Object[] selected) {
List<Portfolio> portfolios = Arrays.stream(selected).filter(o -> o instanceof Portfolio).map(o -> (Portfolio) o).collect(Collectors.toList());
List<Account> accounts = Arrays.stream(selected).filter(o -> o instanceof Account).map(o -> (Account) o).collect(Collectors.toList());
String label = // $NON-NLS-1$
String.join(// $NON-NLS-1$
", ", Arrays.stream(selected).map(String::valueOf).collect(Collectors.toList()));
String uuids = // $NON-NLS-1$
String.join(// $NON-NLS-1$
",", Arrays.stream(selected).map(o -> o instanceof Account ? ((Account) o).getUUID() : ((Portfolio) o).getUUID()).collect(Collectors.toList()));
return new Item(label, uuids, new PortfolioClientFilter(portfolios, accounts));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testNoForexGrossValueExistsIfCurrenciesMatch.
@Test
public void testNoForexGrossValueExistsIfCurrenciesMatch() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_INBOUND);
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("USD", 2_00), BigDecimal.valueOf(0.5)));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testNoForexGrossValueExistsIfCurrenciesMatchEvenIfNoForex.
@Test
public void testNoForexGrossValueExistsIfCurrenciesMatchEvenIfNoForex() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_INBOUND);
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00)));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionTaxesAndFeesAddUpForOutboundDeliveries.
@Test
public void testTransactionTaxesAndFeesAddUpForOutboundDeliveries() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
Unit tax = new Unit(Unit.Type.TAX, Money.of("EUR", 5_00));
Unit fee = new Unit(Unit.Type.FEE, Money.of("EUR", 5_00));
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_OUTBOUND);
t.setMonetaryAmount(Money.of("EUR", 20_00));
t.setSecurity(security);
t.addUnit(fee);
t.addUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setMonetaryAmount(Money.of("EUR", 7_00));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
t.setType(Type.DELIVERY_INBOUND);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setType(Type.DELIVERY_OUTBOUND);
t.removeUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setMonetaryAmount(Money.of("EUR", 3_00));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
t.setType(Type.DELIVERY_INBOUND);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
}
Aggregations