use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class CheckCurrenciesAccountTransactionTest method testCheckTransactionUnitIfCurrenciesAreEqual.
@Test
public void testCheckTransactionUnitIfCurrenciesAreEqual() {
Account account = new Account();
account.setCurrencyCode("EUR");
Security security = new Security("", "EUR");
AccountTransaction t = new AccountTransaction();
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
Unit unit = new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("USD", 2_00), BigDecimal.valueOf(0.5));
t.addUnit(unit);
assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class CheckCurrenciesAccountTransactionTest method testCheckTransactionUnitIfCurrenciesAreDifferent.
@Test
public void testCheckTransactionUnitIfCurrenciesAreDifferent() {
Account account = new Account();
account.setCurrencyCode("EUR");
Security security = new Security("", "USD");
Unit unit = new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("USD", 2_00), BigDecimal.valueOf(0.5));
AccountTransaction t = new AccountTransaction();
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(unit);
assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
t.removeUnit(unit);
assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
Unit other = new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("JPY", 2_00), BigDecimal.valueOf(0.5));
t.addUnit(other);
assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Account 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.Account 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.Account 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