use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionCurrencyMatchesSecurity.
@Test
public void testTransactionCurrencyMatchesSecurity() {
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);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
security.setCurrencyCode("USD");
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 testTransactionForexTaxesAndFeesIfCurrenciesMatch.
@Test
public void testTransactionForexTaxesAndFeesIfCurrenciesMatch() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
Unit tax = new Unit(Unit.Type.TAX, Money.of("EUR", 5_00), Money.of("USD", 10_00), BigDecimal.valueOf(0.5));
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_OUTBOUND);
t.setMonetaryAmount(Money.of("EUR", 20_00));
t.setSecurity(security);
t.addUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class InsertActionTest method testConversionOfBuySellEntry.
@Test
public void testConversionOfBuySellEntry() {
Account account = client.getAccounts().get(0);
Portfolio portfolio = client.getPortfolios().get(0);
InsertAction action = new InsertAction(client);
action.setConvertBuySellToDelivery(true);
action.process(entry, account, portfolio);
assertThat(account.getTransactions().isEmpty(), is(true));
assertThat(portfolio.getTransactions().size(), is(1));
PortfolioTransaction delivery = portfolio.getTransactions().get(0);
assertThat(delivery.getType(), is(Type.DELIVERY_INBOUND));
assertTransaction(delivery);
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class InsertActionTest method testInsertOfBuySellEntry.
@Test
public void testInsertOfBuySellEntry() {
Account account = client.getAccounts().get(0);
Portfolio portfolio = client.getPortfolios().get(0);
InsertAction action = new InsertAction(client);
action.process(entry, account, portfolio);
assertThat(account.getTransactions().size(), is(1));
assertThat(portfolio.getTransactions().size(), is(1));
PortfolioTransaction t = portfolio.getTransactions().get(0);
assertThat(t.getType(), is(Type.BUY));
assertTransaction(t);
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class InsertActionTest method prepare.
@Before
public void prepare() {
client = new Client();
Security security = new Security();
client.addSecurity(security);
Portfolio portfolio = new Portfolio();
client.addPortfolio(portfolio);
Account account = new Account();
client.addAccount(account);
entry = new BuySellEntry();
entry.setType(Type.BUY);
entry.setMonetaryAmount(Money.of(CurrencyUnit.EUR, 9_99));
entry.setShares(99);
entry.setDate(transactionDate);
entry.setSecurity(security);
entry.setNote("note");
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(CurrencyUnit.EUR, 1_99)));
}
Aggregations