use of name.abuchen.portfolio.AccountBuilder in project portfolio by buchen.
the class ClientPerformanceSnapshotTest method testFeesRefund.
@Test
public void testFeesRefund() {
Client client = new Client();
//
new AccountBuilder().fees_refund("2011-01-01", //
Values.Amount.factorize(100)).addTo(client);
CurrencyConverter converter = new TestCurrencyConverter();
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, startDate, endDate);
assertThat(snapshot.getValue(CategoryType.FEES), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(-100))));
assertThat(snapshot.getFees().size(), is(1));
assertThat(snapshot.getFees().get(0).getTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100))));
assertThatCalculationWorksOut(snapshot, converter);
}
use of name.abuchen.portfolio.AccountBuilder in project portfolio by buchen.
the class ClientPerformanceSnapshotTest method testInterestCharge.
@Test
public void testInterestCharge() {
Client client = new Client();
Account account = //
new AccountBuilder().interest_charge("2011-01-01", //
Values.Amount.factorize(100)).addTo(client);
CurrencyConverter converter = new TestCurrencyConverter();
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, startDate, endDate);
assertThat(snapshot.getValue(CategoryType.EARNINGS), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(-100))));
assertThat(snapshot.getCategoryByType(CategoryType.EARNINGS).getPositions().size(), is(1));
assertThat(snapshot.getCategoryByType(CategoryType.EARNINGS).getPositions().get(0).getValuation(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(-100))));
assertThat(snapshot.getEarnings().size(), is(1));
assertThat(snapshot.getEarnings().get(0).getTransaction().getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100))));
GroupEarningsByAccount grouping = new GroupEarningsByAccount(snapshot);
assertThat(grouping.getItems().size(), is(1));
assertThat(grouping.getItems().get(0).getAccount(), is(account));
assertThat(grouping.getItems().get(0).getSum(), is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(-100))));
assertThatCalculationWorksOut(snapshot, converter);
}
use of name.abuchen.portfolio.AccountBuilder in project portfolio by buchen.
the class ClientPerformanceSnapshotTest method testCapitalGainsWithPartialSellDuringReportPeriod.
@Test
public void testCapitalGainsWithPartialSellDuringReportPeriod() {
Client client = new Client();
Security security = //
new SecurityBuilder().addPrice("2010-01-01", //
Values.Quote.factorize(100)).addPrice("2011-06-01", //
Values.Quote.factorize(110)).addTo(client);
Account account = //
new AccountBuilder().deposit_("2010-01-01", //
1_00).withdraw("2011-01-15", //
99_00).addTo(client);
//
new PortfolioBuilder(account).buy(security, "2010-01-01", Values.Share.factorize(10), //
1_00).sell(security, "2011-01-15", Values.Share.factorize(1), //
99_00).addTo(client);
CurrencyConverter converter = new TestCurrencyConverter();
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, startDate, endDate);
assertThat(snapshot.getValue(CategoryType.INITIAL_VALUE), is(Money.of(CurrencyUnit.EUR, 1000_00)));
assertThat(snapshot.getValue(CategoryType.EARNINGS), is(Money.of(CurrencyUnit.EUR, 0)));
assertThat(snapshot.getValue(CategoryType.CAPITAL_GAINS), is(Money.of(CurrencyUnit.EUR, 10_00 * 9 + (99_00 - 100_00))));
assertThat(snapshot.getValue(CategoryType.FINAL_VALUE), is(Money.of(CurrencyUnit.EUR, 110_00 * 9)));
assertThat(snapshot.getAbsoluteDelta(), is(snapshot.getValue(CategoryType.FINAL_VALUE).subtract(snapshot.getValue(CategoryType.TRANSFERS)).subtract(snapshot.getValue(CategoryType.INITIAL_VALUE))));
}
Aggregations