Search in sources :

Example 1 with Category

use of name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot.Category in project portfolio by buchen.

the class ClientPerformanceSnapshotTest method testDepositPlusInterest.

@Test
public void testDepositPlusInterest() {
    Client client = new Client();
    Account account = new Account();
    account.addTransaction(new AccountTransaction(LocalDateTime.of(2010, Month.JANUARY, 1, 0, 0), CurrencyUnit.EUR, 1000_00, null, AccountTransaction.Type.DEPOSIT));
    account.addTransaction(new AccountTransaction(LocalDateTime.of(2011, Month.JUNE, 1, 0, 0), CurrencyUnit.EUR, 50_00, null, AccountTransaction.Type.INTEREST));
    client.addAccount(account);
    CurrencyConverter converter = new TestCurrencyConverter();
    ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, startDate, endDate);
    assertNotNull(snapshot);
    assertNotNull(snapshot.getStartClientSnapshot());
    assertEquals(startDate, snapshot.getStartClientSnapshot().getTime());
    assertNotNull(snapshot.getEndClientSnapshot());
    assertEquals(endDate, snapshot.getEndClientSnapshot().getTime());
    List<Category> categories = snapshot.getCategories();
    assertNotNull(categories);
    assertThat(categories.size(), is(ClientPerformanceSnapshot.CategoryType.values().length));
    assertThat(snapshot.getValue(CategoryType.INITIAL_VALUE), is(Money.of(CurrencyUnit.EUR, 1000_00)));
    assertThat(snapshot.getValue(CategoryType.EARNINGS), is(Money.of(CurrencyUnit.EUR, 50_00)));
    assertThat(snapshot.getValue(CategoryType.FINAL_VALUE), is(Money.of(CurrencyUnit.EUR, 1050_00)));
    assertThat(snapshot.getAbsoluteDelta(), is(snapshot.getValue(CategoryType.FINAL_VALUE).subtract(snapshot.getValue(CategoryType.TRANSFERS)).subtract(snapshot.getValue(CategoryType.INITIAL_VALUE))));
}
Also used : Account(name.abuchen.portfolio.model.Account) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Category(name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot.Category) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Client(name.abuchen.portfolio.model.Client) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) Test(org.junit.Test)

Aggregations

TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)1 Account (name.abuchen.portfolio.model.Account)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 Client (name.abuchen.portfolio.model.Client)1 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)1 Category (name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot.Category)1 Test (org.junit.Test)1