Search in sources :

Example 1 with AssetCategory

use of name.abuchen.portfolio.snapshot.AssetCategory in project portfolio by buchen.

the class CurrencyTestCase method testAssetCategories.

private void testAssetCategories(GroupByTaxonomy grouping) {
    AssetCategory cash = getAssetCategoryByName(grouping, "Barvermögen");
    Money cashValuation = Money.of(CurrencyUnit.EUR, 1000_00 + Math.round(1000_00 * (1 / 1.1588)));
    assertThat(cash.getValuation(), is(cashValuation));
    AssetPosition positionEUR = getAssetPositionByName(grouping, accountEUR.getName());
    assertThat(positionEUR.getValuation(), is(Money.of(CurrencyUnit.EUR, 1000_00)));
    AssetPosition positionUSD = getAssetPositionByName(grouping, accountUSD.getName());
    assertThat(positionUSD.getValuation(), is(Money.of(CurrencyUnit.EUR, Math.round(1000_00 * (1 / 1.1588)))));
    Money equityEURvaluation = Money.of(CurrencyUnit.EUR, Math.round(20 * securityEUR.getSecurityPrice(grouping.getDate()).getValue() / Values.Quote.dividerToMoney()));
    Money equityUSDvaluation = Money.of("USD", Math.round(10 * securityUSD.getSecurityPrice(grouping.getDate()).getValue() / Values.Quote.dividerToMoney())).with(converter.at(grouping.getDate()));
    Money equityValuation = Money.of(CurrencyUnit.EUR, equityEURvaluation.getAmount() + equityUSDvaluation.getAmount());
    AssetCategory equity = getAssetCategoryByName(grouping, "Eigenkapital");
    assertThat(equity.getValuation(), is(equityValuation));
    AssetPosition equityEUR = getAssetPositionByName(grouping, securityEUR.getName());
    assertThat(equityEUR.getValuation(), is(equityEURvaluation));
    AssetPosition equityUSD = getAssetPositionByName(grouping, securityUSD.getName());
    assertThat(equityUSD.getValuation(), is(equityUSDvaluation));
    assertThat(grouping.getValuation(), is(cashValuation.add(equityValuation)));
}
Also used : Money(name.abuchen.portfolio.money.Money) AssetCategory(name.abuchen.portfolio.snapshot.AssetCategory) AssetPosition(name.abuchen.portfolio.snapshot.AssetPosition)

Aggregations

Money (name.abuchen.portfolio.money.Money)1 AssetCategory (name.abuchen.portfolio.snapshot.AssetCategory)1 AssetPosition (name.abuchen.portfolio.snapshot.AssetPosition)1