use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CrossEntryCheckTest method testThatNotTheSamePortfolioIsMatched.
@Test
public void testThatNotTheSamePortfolioIsMatched() {
Portfolio second = new Portfolio();
client.addPortfolio(second);
LocalDateTime date = LocalDateTime.now();
portfolio.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_IN, 1, 0));
PortfolioTransaction umatched = new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_OUT, 1, 0);
portfolio.addTransaction(umatched);
second.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 3, security, 1, PortfolioTransaction.Type.TRANSFER_OUT, 1, 0));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(1));
assertThat(issues.get(0), is(instanceOf(MissingPortfolioTransferIssue.class)));
assertThat(portfolio.getTransactions(), hasItem(umatched));
assertThat(second.getTransactions().get(0).getCrossEntry(), notNullValue());
assertThat(second.getTransactions().get(0).getType(), is(PortfolioTransaction.Type.TRANSFER_OUT));
applyFixes(client, issues);
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CrossEntryCheckTest method testThatAccountTransactionsWithoutSecurity.
@Test
public void testThatAccountTransactionsWithoutSecurity() {
Portfolio second = new Portfolio();
client.addPortfolio(second);
account.addTransaction(new AccountTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, null, AccountTransaction.Type.BUY));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(1));
assertThat(issues.get(0).getAvailableFixes().get(0), is(instanceOf(DeleteTransactionFix.class)));
applyFixes(client, issues);
ClientSnapshot.create(client, new TestCurrencyConverter(), LocalDate.now());
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesBuySellEntryTest method testBuySellEntry.
@Test
public void testBuySellEntry() {
Account account = new Account();
account.setCurrencyCode("EUR");
Security security = new Security();
security.setCurrencyCode("USD");
Portfolio portfolio = new Portfolio();
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
entry.setSecurity(security);
entry.setMonetaryAmount(Money.of("EUR", 100_00));
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 80_00), Money.of("USD", 100_00), BigDecimal.valueOf(0.8)));
assertThat(action.process(entry, account, portfolio).getCode(), is(Status.Code.OK));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionHasGrossValueMatchingSecurityCurrency.
@Test
public void testTransactionHasGrossValueMatchingSecurityCurrency() {
Portfolio portfolio = new Portfolio();
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));
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_INBOUND);
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(unit);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.removeUnit(unit);
assertThat(action.process(t, portfolio).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, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Portfolio in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionForexTaxesAndFees.
@Test
public void testTransactionForexTaxesAndFees() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "USD");
Unit grossValue = new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 10_00), Money.of("USD", 20_00), BigDecimal.valueOf(0.5));
Unit tax = new Unit(Unit.Type.TAX, Money.of("EUR", 5_00), Money.of("USD", 10_00), BigDecimal.valueOf(0.5));
Unit tax2 = new Unit(Unit.Type.TAX, Money.of("EUR", 1_00));
Unit fee = new Unit(Unit.Type.FEE, 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(grossValue);
t.addUnit(fee);
t.addUnit(tax);
t.addUnit(tax2);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.removeUnit(fee);
t.addUnit(new Unit(Unit.Type.FEE, Money.of("EUR", 5_00), Money.of("JPY", 10_00), BigDecimal.valueOf(0.5)));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
Aggregations